import { requireRole, UserRole } from '@admin/auth/middleware'
import { AdminSidebar } from '@admin/components/layouts/admin-sidebar'
import { SidebarProvider } from '@admin/components/ui/sidebar'

export async function AuthGate({ children }: { children: React.ReactNode }) {
  await requireRole([UserRole.ADMIN, UserRole.EDITOR])

  return (
    <SidebarProvider className="min-h-svh">
      <AdminSidebar />
      <div className="relative flex min-w-0 flex-1 flex-col pb-14 [--admin-shell-content-left:var(--sidebar-width)] peer-data-[state=collapsed]:[--admin-shell-content-left:var(--sidebar-width-icon)]">
        {children}
      </div>
    </SidebarProvider>
  )
}
