46 lines
1.6 KiB
TypeScript
46 lines
1.6 KiB
TypeScript
import { auth } from '@/lib/auth'
|
|
import { headers } from 'next/headers'
|
|
import { redirect } from 'next/navigation'
|
|
import Link from 'next/link'
|
|
|
|
export default async function SuperAdminLayout({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode
|
|
}) {
|
|
const session = await auth.api.getSession({ headers: await headers() })
|
|
|
|
if (!session?.user) {
|
|
redirect('/login')
|
|
}
|
|
|
|
const superAdminEmail = process.env.SUPERADMIN_EMAIL || 'superadmin@innungsapp.de'
|
|
if (session.user.email !== superAdminEmail) {
|
|
redirect('/dashboard') // Normal admins go back to dashboard
|
|
}
|
|
|
|
return (
|
|
<div className="min-h-screen bg-gray-50 flex flex-col">
|
|
{/* Super Admin Header */}
|
|
<header className="bg-gray-900 text-white border-t-2 border-brand-500 border-b border-gray-800">
|
|
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
|
<div className="flex justify-between h-12 items-center">
|
|
<span
|
|
className="font-bold text-base tracking-tight"
|
|
style={{ fontFamily: "'Syne', system-ui, sans-serif" }}
|
|
>
|
|
Super Admin
|
|
</span>
|
|
<span className="text-xs text-gray-400">{session.user.email}</span>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
{/* Main Content */}
|
|
<main className="flex-1 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8 w-full">
|
|
{children}
|
|
</main>
|
|
</div>
|
|
)
|
|
}
|