import { auth } from "@/lib/auth";
import { User } from "@prisma/client";
import { redirect } from "next/navigation";

interface DashboardLayoutProps {
  admin: React.ReactNode;
  guest: React.ReactNode;
}

export default async function DashboardLayout({
  admin,
  guest,
}: DashboardLayoutProps) {
  const session = await auth();
  if (!session?.user) {
    redirect("/sign-in");
  }

  const user = session.user as User;

  return user.role === "ADMIN" ? admin : guest;
}
