diff --git a/src/dashboard/components/DashboardLayout.tsx b/src/dashboard/components/DashboardLayout.tsx index 929a869..dc34280 100644 --- a/src/dashboard/components/DashboardLayout.tsx +++ b/src/dashboard/components/DashboardLayout.tsx @@ -65,13 +65,18 @@ export function DashboardLayout() { const { currentUser } = useAuth(); const handleSignOut = async () => { - await signOut(auth); - navigate("/"); + try { + await signOut(auth); + navigate("/"); + } catch (error) { + console.error("Sign out failed:", error); + } }; const initials = currentUser?.displayName ? currentUser.displayName .split(" ") + .filter((n) => n.length > 0) .map((n) => n[0]) .join("") .toUpperCase() diff --git a/src/dashboard/pages/DashboardOverview.tsx b/src/dashboard/pages/DashboardOverview.tsx index 9d540de..8d6f3dd 100644 --- a/src/dashboard/pages/DashboardOverview.tsx +++ b/src/dashboard/pages/DashboardOverview.tsx @@ -57,12 +57,18 @@ export function DashboardOverview() { ); } - const overallProgress = Math.round( - Object.values(project.stages).reduce( - (sum, s) => sum + s.completionPercent, - 0, - ) / Object.keys(project.stages).length, - ); + const stageValues = Object.values(project.stages ?? {}); + const overallProgress = + stageValues.length > 0 + ? Math.round( + stageValues.reduce( + (sum, s) => + sum + + (Number.isFinite(s.completionPercent) ? s.completionPercent : 0), + 0, + ) / stageValues.length, + ) + : 0; const completedStages = Object.values(project.stages).filter( (s) => s.status === "completed",