diff --git a/src/app/(mobile)/m/dashboard-view.tsx b/src/app/(mobile)/m/dashboard-view.tsx index 3730aef..b895153 100644 --- a/src/app/(mobile)/m/dashboard-view.tsx +++ b/src/app/(mobile)/m/dashboard-view.tsx @@ -3,7 +3,8 @@ import { useState, useEffect, useCallback, useRef } from "react"; import { useRouter } from "next/navigation"; import { toast } from "sonner"; -import { RefreshCw, X } from "lucide-react"; +import { RefreshCw, X, Moon, Sun } from "lucide-react"; +import { useTheme } from "next-themes"; import getPocketBase from "@/lib/pocketbase"; import type { BossDashboardData, @@ -56,6 +57,19 @@ export default function BossDashboardView() { realtimeStatusRef.current = realtimeStatus; }, [realtimeStatus]); + // Light/dark toggle — next-themes mounted check avoids SSR/hydration + // mismatch (next-themes returns "light" before mount regardless of the + // persisted value). + const { theme: colorMode, setTheme: setColorMode } = useTheme(); + const [mounted, setMounted] = useState(false); + useEffect(() => { + // eslint-disable-next-line react-hooks/set-state-in-effect + setMounted(true); + }, []); + const toggleColorMode = useCallback(() => { + setColorMode(colorMode === "dark" ? "light" : "dark"); + }, [colorMode, setColorMode]); + const fetchData = useCallback(async () => { // Pre-check auth — if PB has no valid token, redirect via the router so // we preserve the in-memory state of the dashboard (search, tabs, sheet) @@ -225,7 +239,7 @@ export default function BossDashboardView() {

- Good {greeting()}, {firstName}. + Good {greeting()}, {firstName}.

- +
+ + +
{/* Time tab bar */} @@ -269,7 +297,7 @@ export default function BossDashboardView() { onClick={() => selectWindow(w)} className={`flex-1 rounded-lg px-3 py-2 text-sm font-medium capitalize transition-colors ${ activeWindow === w - ? "bg-cyan-500/15 text-cyan-300" + ? "bg-red-500/15 text-red-500" : "text-muted-foreground hover:text-foreground" }`} > @@ -315,13 +343,13 @@ export default function BossDashboardView() { className="w-full rounded-xl border border-border/60 bg-card p-3 text-left transition-colors hover:bg-card/70 active:bg-card/80 disabled:opacity-50 disabled:cursor-not-allowed" >
-
+
{(rep.name[0] ?? "?").toUpperCase()}
{rep.name}
- +
@@ -388,7 +416,7 @@ export default function BossDashboardView() { className="flex items-center justify-between gap-3 rounded-xl border border-border/60 bg-card p-3" >
-
+
{(drv.name[0] ?? "?").toUpperCase()}
@@ -465,7 +493,7 @@ export default function BossDashboardView() { }} className={`flex-1 rounded-md px-3 py-1.5 text-sm font-medium capitalize transition-colors ${ sheetKind === k - ? "bg-cyan-500/15 text-cyan-300" + ? "bg-red-500/15 text-red-500" : "text-muted-foreground hover:text-foreground" }`} > @@ -569,7 +597,7 @@ function OrderTotal({
{label}
-
+
{value.toLocaleString()}
@@ -587,10 +615,10 @@ function MiniMetric({ }) { return (
-
+
{value.toLocaleString()}
-
+
{label}