Skip to content

Commit ac8f855

Browse files
committed
Only show graph when there are 5 data points
1 parent 64865e2 commit ac8f855

1 file changed

Lines changed: 22 additions & 10 deletions

File tree

client/src/screens/Home.tsx

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
useFiat,
1616
useNetworthTimeSeries,
1717
} from '@/hooks/useHono'
18-
import { formatCurrency } from '@/lib/utils'
18+
import { cn, formatCurrency } from '@/lib/utils'
1919

2020
const chartConfig = {
2121
value: {
@@ -44,19 +44,31 @@ export function Home() {
4444
<Card>
4545
<CardContent className="flex items-center justify-center gap-6">
4646
<div className="flex flex-col items-center justify-center gap-2">
47-
{fiat && currency && (
48-
<h1 className="text-5xl font-semibold">
49-
{formatCurrency(
50-
(balances.data?.totalEthValue ?? 0) / fiat.getRate(currency),
51-
currency
52-
)}
53-
</h1>
54-
)}
47+
<h1 className="text-5xl font-semibold">
48+
{(() => {
49+
if (fiat && currency) {
50+
return formatCurrency(
51+
(balances.data?.totalEthValue ?? 0) /
52+
fiat.getRate(currency),
53+
currency
54+
)
55+
}
56+
57+
return '...'
58+
})()}
59+
</h1>
5560

5661
<span className="text-muted-foreground text-sm">Total value</span>
5762
</div>
5863

59-
<div className="relative hidden w-full lg:block">
64+
<div
65+
className={cn(
66+
'relative hidden w-full',
67+
!!networthTimeSeries &&
68+
networthTimeSeries.length > 5 &&
69+
'lg:block'
70+
)}
71+
>
6072
<ChartContainer
6173
config={chartConfig}
6274
className="aspect-auto h-[250px] w-full"

0 commit comments

Comments
 (0)