import { headers } from "next/headers";
import { redirect } from "next/navigation";
import AdminApp from "./admin-app";
import { getUserFromCookieHeader } from "../lib/user-auth";

export const dynamic = "force-dynamic";

export default async function Page() {
  const requestHeaders = await headers();
  const user = await getUserFromCookieHeader(requestHeaders.get("cookie"));
  if (!user) redirect("/login");
  return <AdminApp currentUser={user} />;
}
