import { redirect } from 'next/navigation'
import { getServerSession } from '@/lib/auth'
import ManageSubNav from '@/components/ManageSubNav'

export default async function ManageLayout({ children }: { children: React.ReactNode }) {
  const session = await getServerSession()
  if (!session.userId) redirect('/login')
  if (session.role !== 'admin') redirect('/')

  return (
    <div>
      <ManageSubNav />
      {children}
    </div>
  )
}
