From 253fe447bdd999db78f7fa96e2ffa34e8194e5ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vi=CC=81ctor=20Falco=CC=81n?= Date: Fri, 16 Jan 2026 11:30:04 +0100 Subject: [PATCH] fix: broken dashboard while loading --- .../js/components/dashboard/cashflow-summary-card.tsx | 7 ++++--- resources/js/components/dashboard/top-categories-card.tsx | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/resources/js/components/dashboard/cashflow-summary-card.tsx b/resources/js/components/dashboard/cashflow-summary-card.tsx index 6162cd29..e0933c85 100644 --- a/resources/js/components/dashboard/cashflow-summary-card.tsx +++ b/resources/js/components/dashboard/cashflow-summary-card.tsx @@ -8,6 +8,7 @@ import { } from '@/components/ui/card'; import { cn } from '@/lib/utils'; import { cashflow } from '@/routes'; +import { SharedData } from '@/types'; import { Link, usePage } from '@inertiajs/react'; import { endOfMonth, format, startOfMonth } from 'date-fns'; import { ArrowRight, TrendingDown, TrendingUp } from 'lucide-react'; @@ -25,8 +26,8 @@ interface CashflowSummaryCardProps { } export function CashflowSummaryCard({ loading }: CashflowSummaryCardProps) { - const { auth } = usePage<{ auth: { user: { currency_code: string } } }>() - .props; + const { auth } = usePage().props; + const [data, setData] = useState<{ current: CashflowSummary; previous: CashflowSummary; @@ -56,7 +57,7 @@ export function CashflowSummaryCard({ loading }: CashflowSummaryCardProps) { fetchData(); }, []); - if (isLoading || loading) { + if (!auth?.user || isLoading || loading) { return ( diff --git a/resources/js/components/dashboard/top-categories-card.tsx b/resources/js/components/dashboard/top-categories-card.tsx index 0176f2b4..43dc2ec7 100644 --- a/resources/js/components/dashboard/top-categories-card.tsx +++ b/resources/js/components/dashboard/top-categories-card.tsx @@ -8,6 +8,7 @@ import { } from '@/components/ui/card'; import { Progress } from '@/components/ui/progress'; import { cn } from '@/lib/utils'; +import { SharedData } from '@/types'; import { Category, getCategoryColorClasses } from '@/types/category'; import { usePage } from '@inertiajs/react'; import * as Icons from 'lucide-react'; @@ -43,9 +44,9 @@ export function TopCategoriesCard({ categories, loading, }: TopCategoriesCardProps) { - const { auth } = usePage<{ auth: { user: { currency_code: string } } }>(); + const { auth } = usePage().props; - if (loading) { + if (loading || !auth?.user) { return (