- Login/register pages met AuthForm (useActionState + useFormStatus) - Server Actions voor login, register, logout met Zod validatie - Middleware checkt session cookie zonder iron-session op Edge runtime - AppLayout met auth-check en NavBar met demo badge en actieve links - Dashboard toont productenlijst via ProductList Client Component - Fix: a-in-a hydration error opgelost door div plus useRouter te gebruiken Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
22 lines
679 B
TypeScript
22 lines
679 B
TypeScript
import { redirect } from 'next/navigation'
|
|
import { cookies } from 'next/headers'
|
|
import { getIronSession } from 'iron-session'
|
|
import { SessionData, sessionOptions } from '@/lib/session'
|
|
import { NavBar } from '@/components/shared/nav-bar'
|
|
|
|
export default async function AppLayout({ children }: { children: React.ReactNode }) {
|
|
const session = await getIronSession<SessionData>(await cookies(), sessionOptions)
|
|
|
|
if (!session.userId) {
|
|
redirect('/login')
|
|
}
|
|
|
|
return (
|
|
<div className="min-h-screen bg-background flex flex-col">
|
|
<NavBar isDemo={session.isDemo} />
|
|
<main className="flex-1 flex flex-col">
|
|
{children}
|
|
</main>
|
|
</div>
|
|
)
|
|
}
|