import { redirect } from "next/navigation";
import { getStaffSession } from "@/lib/staff-session";
import StaffDashboardLayoutClient from "./StaffDashboardLayoutClient";

export default async function StaffDashboardLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  // Server-side authentication - no client-side waterfall
  const user = await getStaffSession();

  if (!user) {
    redirect("/staff/login");
  }

  return (
    <StaffDashboardLayoutClient user={user}>
      {children}
    </StaffDashboardLayoutClient>
  );
}
