import { redirect } from 'next/navigation'
import { getAdminFromCookie } from '@/lib/admin-auth'
import AdminShell from '@/components/pitch-admin/AdminShell'

export const dynamic = 'force-dynamic'

export default async function AuthedAdminLayout({ children }: { children: React.ReactNode }) {
  const admin = await getAdminFromCookie()
  if (!admin) {
    redirect('/pitch-admin/login')
  }

  return (
    <AdminShell admin={{ id: admin.id, email: admin.email, name: admin.name }}>
      {children}
    </AdminShell>
  )
}
