Skip to content

Commit 2f3f043

Browse files
committed
Only show Balances tab when its relevant
1 parent 49c6087 commit 2f3f043

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

client/src/components/AccountCard.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ function AccountDialog({
116116
prompt: 'Add' | 'Edit'
117117
} & VariantProps<typeof buttonVariants>) {
118118
const accounts = useAccounts()
119+
const { refetch: refetchOffchainAccounts } = useAccounts('offchain')
119120
const selectedAccount = accounts.data?.find(
120121
(account) => account.address === address
121122
)
@@ -137,6 +138,7 @@ function AccountDialog({
137138
loading: `${prompt}ing account...`,
138139
success: () => {
139140
accounts.refetch()
141+
refetchOffchainAccounts()
140142
return `${prompt}ed account`
141143
},
142144
error: {

client/src/components/Layout.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ArrowUpRight } from 'lucide-react'
22
import { Link, useLocation } from 'react-router-dom'
33

4+
import { useAccounts } from '@/hooks/useHono'
45
import { SERVER_URL } from '@/hooks/useHono'
56
import { useQueues } from '@/hooks/useQueues'
67
import { cn } from '@/lib/utils'
@@ -32,18 +33,27 @@ const links = [
3233
label: 'Balances',
3334
to: '/balances',
3435
},
35-
]
36+
] as const
37+
3638
export function Layout({ children }: { children: React.ReactNode }) {
3739
const { pathname } = useLocation()
3840
const queues = useQueues()
41+
const { data: offchainAccounts } = useAccounts('offchain')
3942

4043
return (
4144
<div className="grid grid-cols-[10rem_1fr] lg:grid-cols-[15rem_1fr]">
4245
<aside className="sticky top-0 flex h-svh flex-col justify-between border-r p-2 lg:p-6">
4346
<nav>
4447
<ul>
4548
{links.map((link) => (
46-
<li key={link.to}>
49+
<li
50+
key={link.to}
51+
className={cn(
52+
link.label === 'Balances' &&
53+
offchainAccounts?.length === 0 &&
54+
'hidden'
55+
)}
56+
>
4757
<Link
4858
to={link.to}
4959
className={cn(

0 commit comments

Comments
 (0)