chore: remove switch wallet page (#1207)

This commit is contained in:
Thebora Kompanioni 2026-04-16 22:14:14 +02:00 committed by GitHub
parent 2541f8cd2f
commit 4500ca4129
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 0 additions and 227 deletions

View file

@ -19,7 +19,6 @@ import { toast } from 'sonner'
import { useStore } from 'zustand'
import { LogsPage } from '@/components/LogsPage'
import MainWalletPage from '@/components/MainWalletPage'
import SwitchWalletPage from '@/components/SwitchWalletPage'
import CreateWalletPage from '@/components/create/CreateWalletPage'
import { EarnPage } from '@/components/earn/EarnPage'
import ErrorPage from '@/components/error/ErrorPage'
@ -203,9 +202,6 @@ function App() {
</ProtectedRoute>
}
>
<Route id="protected-without-navbar" element={<Outlet />}>
<Route path={routes.switchWallet} element={<SwitchWalletPage walletFileName={walletFileName!} />} />
</Route>
<Route
id="protected-with-navbar"
element={

View file

@ -1,216 +0,0 @@
import { useState } from 'react'
import { listwalletsOptions, lockwalletOptions } from '@joinmarket-webui/joinmarket-api-ts/@tanstack/react-query'
import { useQuery } from '@tanstack/react-query'
import { LockIcon, RefreshCwIcon, UnlockIcon, WalletIcon } from 'lucide-react'
import { useTranslation } from 'react-i18next'
import { useNavigate } from 'react-router-dom'
import { toast } from 'sonner'
import { Button } from '@/components/ui/button'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
import { WalletLoadErrorAlert } from '@/components/ui/jam/WalletLoadErrorAlert'
import { Skeleton } from '@/components/ui/skeleton'
import { routes } from '@/constants/routes'
import { useApiClient } from '@/hooks/useApiClient'
import { getErrorReason } from '@/lib/errorReason'
import { queryClient } from '@/lib/queryClient'
import { shortenStringMiddle, sortWallets, walletDisplayName } from '@/lib/utils'
import type { WalletFileName } from '@/lib/utils'
import { authStore } from '@/store/authStore'
import { AuthPageShell } from './layout/AuthPageShell'
import { Spinner } from './ui/spinner'
const SwitchWalletFormSkeleton = () => {
return (
<>
<div className="flex flex-col space-y-6">
<Skeleton className="h-4 w-full" />
<div className="space-y-3">
<div className="space-y-1">
<Skeleton className="h-4 w-[75px]" />
<Skeleton className="h-10 w-full" />
</div>
<div className="space-y-1">
<Skeleton className="h-4 w-[75px]" />
<Skeleton className="h-10 w-full" />
</div>
<Skeleton className="h-12 w-full" />
</div>
</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
</>
)
}
interface SwitchWalletPageProps {
walletFileName: WalletFileName
}
const SwitchWalletPage = ({ walletFileName }: SwitchWalletPageProps) => {
const { t } = useTranslation()
const navigate = useNavigate()
const client = useApiClient()
const [currentWalletLocked, setCurrentWalletLocked] = useState(false)
const {
data: listWalletsData,
error: listWalletsError,
isLoading: listWalletsLoading,
isFetching: listWalletsFetching,
refetch: listWalletsRefetch,
} = useQuery({
...listwalletsOptions({ client }),
retry: false,
})
const lockCurrentWallet = useQuery({
...lockwalletOptions({
client,
path: { walletname: walletFileName },
}),
enabled: false,
staleTime: 1,
gcTime: 1,
retry: false,
})
const wallets = sortWallets((listWalletsData?.wallets || []) as WalletFileName[], walletFileName)
const handleLockCurrentWallet = async () => {
try {
await lockCurrentWallet.refetch({ throwOnError: true })
authStore.getState().clear()
queryClient.clear()
setCurrentWalletLocked(true)
toast.success(
t('wallets.wallet_preview.alert_wallet_locked_successfully', { walletName: walletDisplayName(walletFileName) }),
)
} catch (error: unknown) {
const reason = getErrorReason(error, t('global.errors.reason_unknown'))
toast.error(t('settings.error_lock_wallet_failed', { reason }))
console.error('Failed to lock wallet:', error)
}
}
return (
<AuthPageShell>
<Card className="w-full max-w-xl shadow-lg">
<CardHeader className="space-y-2 text-center">
<div className="bg-primary/10 mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full">
{listWalletsFetching ? (
<Spinner className="size-6" />
) : (
<WalletIcon className="text-primary h-6 w-6" onClick={() => void listWalletsRefetch()} />
)}
</div>
<CardTitle className="text-2xl font-bold">{t('settings.button_switch_wallet')}</CardTitle>
<CardDescription>
{currentWalletLocked
? t('settings.switch_wallet_current_wallet_locked_select_other')
: t('wallets.alert_wallet_open', {
currentWalletName: walletDisplayName(walletFileName),
})}
</CardDescription>
</CardHeader>
{listWalletsLoading ? (
<CardContent className="space-y-6">
<SwitchWalletFormSkeleton />
</CardContent>
) : (
<>
{listWalletsError ? (
<CardContent className="space-y-6">
<WalletLoadErrorAlert reason={listWalletsError.message} iconClassName="h-4 w-4" />
<Button variant="ghost" size="sm" onClick={() => void listWalletsRefetch()}>
<RefreshCwIcon className="h-4 w-4" /> {t('global.retry')}
</Button>
</CardContent>
) : (
<CardContent className="space-y-6">
<div className="space-y-3">
<div className="flex items-center gap-2">
<span className="font-medium">{t('wallets.title')}</span>
</div>
{wallets.length === 0 ? (
<div className="py-4 text-center">
<p className="text-muted-foreground text-sm">{t('wallets.subtitle_no_wallets')}</p>
</div>
) : (
<div className="space-y-2">
{wallets.map((wallet) => (
<div
key={wallet}
className={`rounded-lg border p-4 ${
wallet === walletFileName ? 'bg-primary/5 border-primary/20' : 'bg-muted/30'
}`}
>
<div className="flex items-center justify-between truncate">
<div className="flex items-center gap-2">
<WalletIcon className="h-4 w-4" />
<span className="text-sm font-medium">
{shortenStringMiddle(walletDisplayName(wallet) ?? '...', 63)}
</span>
</div>
{wallet === walletFileName && (
<span className="text-muted-foreground text-xs">
{currentWalletLocked
? t('wallets.wallet_preview.wallet_locked')
: t('wallets.wallet_preview.wallet_active')}
</span>
)}
</div>
{wallet === walletFileName && (
<div className="m-4 flex gap-4">
<Button
variant="outline"
size="sm"
onClick={() => void navigate(routes.home)}
className="flex-1"
>
<WalletIcon className="mr-2 h-4 w-4" />
{t('wallets.wallet_preview.button_open')}
</Button>
<Button
variant="default"
size="sm"
onClick={() => void handleLockCurrentWallet()}
disabled={lockCurrentWallet.isFetching || currentWalletLocked}
className="flex-1"
>
{lockCurrentWallet.isFetching ? (
<>
<Spinner className="motion-reduce:hidden" />
{t('settings.button_locking_wallet')}
</>
) : currentWalletLocked ? (
<>
<LockIcon className="h-4 w-4" />
{t('wallets.wallet_preview.wallet_locked')}
</>
) : (
<>
<UnlockIcon className="h-4 w-4" />
{t('settings.button_lock_wallet')}
</>
)}
</Button>
</div>
)}
</div>
))}
</div>
)}
</div>
</CardContent>
)}
</>
)}
</Card>
</AuthPageShell>
)
}
export default SwitchWalletPage

View file

@ -11,7 +11,6 @@ import {
BookIcon,
TerminalIcon,
PackageSearchIcon,
ArrowLeftRightIcon,
LockKeyholeIcon,
BookKeyIcon,
FoldHorizontalIcon,
@ -164,8 +163,6 @@ export const SettingsPage = ({ walletFileName, onLockWallet }: SettingPageProps)
disabled={lockWalletMutation.isPending}
/>
<Separator className="opacity-50" />
<SettingsLink icon={ArrowLeftRightIcon} title={t('settings.button_switch_wallet')} to={routes.switchWallet} />
<Separator className="opacity-50" />
<SettingsLink icon={PackageSearchIcon} title={t('settings.rescan_chain')} to={routes.rescan} />
<Separator className="opacity-50" />
<SettingsLink

View file

@ -3,7 +3,6 @@ export const routes = {
login: '/login',
createWallet: '/create-wallet',
importWallet: '/import-wallet',
switchWallet: '/switch-wallet',
receive: '/receive',
send: '/send',
rescan: '/settings/rescan',

View file

@ -116,7 +116,6 @@
"text_loading": "Loading wallets",
"button_new_wallet": "Create new wallet",
"button_import_wallet": "Import existing wallet",
"alert_wallet_open": "There can be only one active wallet. If you want to open another wallet, please lock '{{ currentWalletName }}' first.",
"error_loading_failed": "Loading wallets failed.",
"wallet_preview": {
"alert_wallet_already_unlocked": "{{ walletName }} is already unlocked.",
@ -258,8 +257,6 @@
"show_lock_confirmation": "Ask confirmation before locking",
"button_lock_wallet": "Lock wallet",
"button_locking_wallet": "Locking...",
"button_switch_wallet": "Switch wallet",
"switch_wallet_current_wallet_locked_select_other": "Current wallet is locked. Select a different wallet to continue.",
"error_lock_wallet_failed": "Failed to lock current wallet: {{ reason }}",
"error_loading_seed_failed": "Could not retrieve seed phrase.",
"seed_modal": {