From dd35ca8e1e2576bffedb7fedd6fe277ffbae2698 Mon Sep 17 00:00:00 2001 From: chemicalcommando Date: Mon, 22 Jun 2026 14:29:25 +0100 Subject: [PATCH 1/2] updated dashboard --- apps/web/app/dashboard/layout.tsx | 26 ++++++++++++ apps/web/app/dashboard/page.tsx | 8 ++++ apps/web/components/Sidebar.tsx | 70 +++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 apps/web/app/dashboard/layout.tsx create mode 100644 apps/web/app/dashboard/page.tsx create mode 100644 apps/web/components/Sidebar.tsx diff --git a/apps/web/app/dashboard/layout.tsx b/apps/web/app/dashboard/layout.tsx new file mode 100644 index 0000000..40ce64b --- /dev/null +++ b/apps/web/app/dashboard/layout.tsx @@ -0,0 +1,26 @@ +'use client'; + +import { useRouter } from 'next/navigation'; +import { useEffect, type ReactNode } from 'react'; +import { Sidebar } from '../../components/Sidebar'; +import { useAuth } from '../../lib/auth-context'; + +export default function DashboardLayout({ children }: { children: ReactNode }) { + const { user } = useAuth(); + const router = useRouter(); + + useEffect(() => { + if (!user) { + router.replace('/login'); + } + }, [user, router]); + + if (!user) return null; + + return ( +
+ +
{children}
+
+ ); +} diff --git a/apps/web/app/dashboard/page.tsx b/apps/web/app/dashboard/page.tsx new file mode 100644 index 0000000..1c27fe6 --- /dev/null +++ b/apps/web/app/dashboard/page.tsx @@ -0,0 +1,8 @@ +export default function DashboardPage() { + return ( +
+

Dashboard

+

Welcome back. More stats coming soon.

+
+ ); +} diff --git a/apps/web/components/Sidebar.tsx b/apps/web/components/Sidebar.tsx new file mode 100644 index 0000000..213ae0c --- /dev/null +++ b/apps/web/components/Sidebar.tsx @@ -0,0 +1,70 @@ +'use client'; + +import Link from 'next/link'; +import { usePathname } from 'next/navigation'; +import { useAuth } from '../lib/auth-context'; + +const NAV_LINKS = [ + { href: '/dashboard', label: 'Dashboard' }, + { href: '/dashboard/restaurants', label: 'Restaurants' }, + { href: '/dashboard/menu', label: 'Menu' }, + { href: '/dashboard/orders', label: 'Orders' }, + { href: '/dashboard/settings', label: 'Settings' }, +] as const; + +export function Sidebar() { + const pathname = usePathname(); + const { user, logout } = useAuth(); + + return ( + + ); +} From ecd02eb2ba7ce997567f2b0f05fe633bac9b265f Mon Sep 17 00:00:00 2001 From: chemicalcommando Date: Mon, 22 Jun 2026 15:02:37 +0100 Subject: [PATCH 2/2] Update layout.tsx --- apps/web/app/dashboard/layout.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/web/app/dashboard/layout.tsx b/apps/web/app/dashboard/layout.tsx index 40ce64b..b9b56b1 100644 --- a/apps/web/app/dashboard/layout.tsx +++ b/apps/web/app/dashboard/layout.tsx @@ -6,16 +6,16 @@ import { Sidebar } from '../../components/Sidebar'; import { useAuth } from '../../lib/auth-context'; export default function DashboardLayout({ children }: { children: ReactNode }) { - const { user } = useAuth(); + const { user, isLoading } = useAuth(); const router = useRouter(); useEffect(() => { - if (!user) { + if (!isLoading && !user) { router.replace('/login'); } - }, [user, router]); + }, [isLoading, user, router]); - if (!user) return null; + if (isLoading || !user) return null; return (