import { cookies } from "next/headers";
import { redirect } from "next/navigation";

export default async function DashboardLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  const cookieStore = await cookies();
  const token = cookieStore.get("token");

  // If there is no token, don't even render the children (the dashboard)
  if (!token) {
    redirect("/amazon/login");
  }

  return <>{children}</>;
}