From e5598c0ff80680db347e4dde0c8aa55efb303675 Mon Sep 17 00:00:00 2001 From: Kiro Agent Date: Sat, 27 Jun 2026 00:34:09 +0100 Subject: [PATCH] feat: add data refresh button to dashboard - Add refresh button in dashboard header with spinning icon during load - Show last updated timestamp below refresh button - Auto-refresh dashboard data every 60 seconds - Implement manual refresh capability - Clear interval on component unmount --- backend/frontend/app/dashboard/page.tsx | 93 +++++++++++++++++++++++-- 1 file changed, 86 insertions(+), 7 deletions(-) diff --git a/backend/frontend/app/dashboard/page.tsx b/backend/frontend/app/dashboard/page.tsx index 77780d0b..b46a55dc 100644 --- a/backend/frontend/app/dashboard/page.tsx +++ b/backend/frontend/app/dashboard/page.tsx @@ -1,5 +1,6 @@ 'use client'; +import { useState, useEffect } from 'react'; import { useDashboardData } from '@/lib/hooks/useDashboardData'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { DollarSign, Clock, Folder, CheckCircle2, TrendingUp } from 'lucide-react'; @@ -7,14 +8,62 @@ import { FadeIn } from '@/components/ui/fade-in'; import { DashboardStatsSkeleton } from '@/components/ui/loading-skeletons'; export default function DashboardPage() { - const { stats, recentActivity, loading } = useDashboardData(); + const { stats, recentActivity, loading, refetch } = useDashboardData(); + const [isRefreshing, setIsRefreshing] = useState(false); + const [lastUpdated, setLastUpdated] = useState(null); + + const handleRefresh = async () => { + setIsRefreshing(true); + try { + await refetch?.(); + setLastUpdated(new Date()); + } finally { + setIsRefreshing(false); + } + }; + + useEffect(() => { + handleRefresh(); + const interval = setInterval(handleRefresh, 60000); + return () => clearInterval(interval); + }, []); if (loading) { return (
-
-

Dashboard

-

Welcome back! Here's your overview.

+
+
+

Dashboard

+

Welcome back! Here's your overview.

+
+
+ + {lastUpdated && ( +

+ Last updated: {lastUpdated.toLocaleTimeString()} +

+ )} +
{/* Simplified Loading for Recent Activity */} @@ -36,9 +85,39 @@ export default function DashboardPage() { return (
-
-

Dashboard

-

Welcome back! Here's your overview.

+
+
+

Dashboard

+

Welcome back! Here's your overview.

+
+
+ + {lastUpdated && ( +

+ Last updated: {lastUpdated.toLocaleTimeString()} +

+ )} +
{/* Stats Grid */}