fix: broken dashboard while loading

This commit is contained in:
Víctor Falcón 2026-01-16 11:30:04 +01:00
parent 21a4d87f85
commit 253fe447bd
2 changed files with 7 additions and 5 deletions

View File

@ -8,6 +8,7 @@ import {
} from '@/components/ui/card'; } from '@/components/ui/card';
import { cn } from '@/lib/utils'; import { cn } from '@/lib/utils';
import { cashflow } from '@/routes'; import { cashflow } from '@/routes';
import { SharedData } from '@/types';
import { Link, usePage } from '@inertiajs/react'; import { Link, usePage } from '@inertiajs/react';
import { endOfMonth, format, startOfMonth } from 'date-fns'; import { endOfMonth, format, startOfMonth } from 'date-fns';
import { ArrowRight, TrendingDown, TrendingUp } from 'lucide-react'; import { ArrowRight, TrendingDown, TrendingUp } from 'lucide-react';
@ -25,8 +26,8 @@ interface CashflowSummaryCardProps {
} }
export function CashflowSummaryCard({ loading }: CashflowSummaryCardProps) { export function CashflowSummaryCard({ loading }: CashflowSummaryCardProps) {
const { auth } = usePage<{ auth: { user: { currency_code: string } } }>() const { auth } = usePage<SharedData>().props;
.props;
const [data, setData] = useState<{ const [data, setData] = useState<{
current: CashflowSummary; current: CashflowSummary;
previous: CashflowSummary; previous: CashflowSummary;
@ -56,7 +57,7 @@ export function CashflowSummaryCard({ loading }: CashflowSummaryCardProps) {
fetchData(); fetchData();
}, []); }, []);
if (isLoading || loading) { if (!auth?.user || isLoading || loading) {
return ( return (
<Card className="col-span-3"> <Card className="col-span-3">
<CardHeader> <CardHeader>

View File

@ -8,6 +8,7 @@ import {
} from '@/components/ui/card'; } from '@/components/ui/card';
import { Progress } from '@/components/ui/progress'; import { Progress } from '@/components/ui/progress';
import { cn } from '@/lib/utils'; import { cn } from '@/lib/utils';
import { SharedData } from '@/types';
import { Category, getCategoryColorClasses } from '@/types/category'; import { Category, getCategoryColorClasses } from '@/types/category';
import { usePage } from '@inertiajs/react'; import { usePage } from '@inertiajs/react';
import * as Icons from 'lucide-react'; import * as Icons from 'lucide-react';
@ -43,9 +44,9 @@ export function TopCategoriesCard({
categories, categories,
loading, loading,
}: TopCategoriesCardProps) { }: TopCategoriesCardProps) {
const { auth } = usePage<{ auth: { user: { currency_code: string } } }>(); const { auth } = usePage<SharedData>().props;
if (loading) { if (loading || !auth?.user) {
return ( return (
<Card className="col-span-3"> <Card className="col-span-3">
<CardHeader> <CardHeader>