34 lines
888 B
TypeScript
34 lines
888 B
TypeScript
import { Sidebar } from '@/components/layout/Sidebar'
|
|
import { Header } from '@/components/layout/Header'
|
|
import { auth } from '@/lib/auth'
|
|
import { headers } from 'next/headers'
|
|
import { redirect } from 'next/navigation'
|
|
|
|
export default async function DashboardLayout({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode
|
|
}) {
|
|
const session = await auth.api.getSession({ headers: await headers() })
|
|
|
|
if (!session?.user) {
|
|
redirect('/login')
|
|
}
|
|
|
|
// Superadmin Redirect
|
|
const superAdminEmail = process.env.SUPERADMIN_EMAIL || 'superadmin@innungsapp.de'
|
|
if (session.user.email === superAdminEmail) {
|
|
redirect('/superadmin')
|
|
}
|
|
|
|
return (
|
|
<div className="flex h-screen bg-gray-50">
|
|
<Sidebar />
|
|
<div className="flex-1 flex flex-col min-w-0">
|
|
<Header />
|
|
<main className="flex-1 overflow-y-auto p-6">{children}</main>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|