import { requireRole } from '@/lib/auth-redirect'
import { ObserverNav } from '@/components/layouts/observer-nav'
import { EditionProvider } from '@/components/observer/observer-edition-context'

export default async function ObserverLayout({
  children,
}: {
  children: React.ReactNode
}) {
  const session = await requireRole('OBSERVER')

  return (
    <div className="min-h-screen bg-background">
      <EditionProvider>
        <ObserverNav
          user={{
            name: session.user.name,
            email: session.user.email,
          }}
        />
        <main className="container-app py-6">{children}</main>
      </EditionProvider>
    </div>
  )
}
