import { NextResponse } from "next/server";
import { requireSuperadmin } from "@/lib/admin-auth";
import { getOrCheckSnippetStatus } from "@/lib/services/snippet-status";

export const dynamic = "force-dynamic";
export const maxDuration = 30;

export async function POST(
  _request: Request,
  { params }: { params: { brandId: string } }
) {
  const denied = await requireSuperadmin();
  if (denied) return denied;

  try {
    const status = await getOrCheckSnippetStatus(params.brandId, true);
    return NextResponse.json(status);
  } catch (err) {
    return NextResponse.json(
      { error: err instanceof Error ? err.message : "Snippet check failed" },
      { status: 500 }
    );
  }
}
