import { auth } from "@/lib/auth"
import { redirect } from "next/navigation"
import Sidebar from "./Sidebar"

interface DashboardLayoutProps {
  children: React.ReactNode
  requiredRole: string
}

export default async function DashboardLayout({ children, requiredRole }: DashboardLayoutProps) {
  const session = await auth()

  if (!session || session.user.role !== requiredRole) {
    redirect("/login")
  }

  return (
    <div className="flex min-h-screen bg-gray-50">
      <Sidebar role={requiredRole} />
      <main className="flex-1 p-8">
        {children}
      </main>
    </div>
  )
}
