import { auth } from "@/lib/auth";

export async function AdminOnlyGate({ children }: { children: React.ReactNode }) {
  const session = await auth();
  const role = (session?.user as { role?: string } | undefined)?.role;

  if (role !== "admin") {
    return (
      <div className="text-center">
        <h1 className="font-heading text-3xl font-semibold text-terracotta">
          Not authorized
        </h1>
        <p className="mt-4 text-charcoal/70">This page is admin-only.</p>
      </div>
    );
  }

  return <>{children}</>;
}
