diff --git a/src/app/dashboard/layout.tsx b/src/app/dashboard/layout.tsx new file mode 100644 index 0000000..497583f --- /dev/null +++ b/src/app/dashboard/layout.tsx @@ -0,0 +1,28 @@ +import { redirect } from 'next/navigation' +import { createClient } from '@/lib/supabase/server' +import Navbar from '@/components/Navbar' + +export default async function DashboardLayout({ + children, +}: { + children: React.ReactNode +}) { + const supabase = await createClient() + + const { + data: { user }, + } = await supabase.auth.getUser() + + if (!user) { + redirect('/login') + } + + return ( +
+ +
+ {children} +
+
+ ) +} diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx new file mode 100644 index 0000000..7b5bec8 --- /dev/null +++ b/src/components/Navbar.tsx @@ -0,0 +1,32 @@ +import Link from 'next/link' +import LogoutButton from './LogoutButton' + +interface NavbarProps { + userEmail: string +} + +export default function Navbar({ userEmail }: NavbarProps) { + return ( + + ) +}