diff --git a/apps/web/app/dashboard/layout.tsx b/apps/web/app/dashboard/layout.tsx new file mode 100644 index 0000000..b9b56b1 --- /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, isLoading } = useAuth(); + const router = useRouter(); + + useEffect(() => { + if (!isLoading && !user) { + router.replace('/login'); + } + }, [isLoading, user, router]); + + if (isLoading || !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 ( + + ); +}