import { AdminSidebar } from '@/components/admin-sidebar'
import { AdminContentArea } from '@/components/admin-content-area'
import { auth } from '@/auth'
import { redirect } from 'next/navigation'

export default async function AdminLayout({
  children,
}: {
  children: React.ReactNode
}) {
  const session = await auth()

  if ((session?.user as any)?.role !== 'ADMIN') {
    redirect('/')
  }

  return (
    <div className="flex h-full bg-gray-50 dark:bg-zinc-950">
      <AdminSidebar />
      <AdminContentArea>{children}</AdminContentArea>
    </div>
  )
}
