import { prisma } from "@/lib/prisma";
import { NextResponse } from "next/server";

const serializeBigInt = (data: any) =>
  JSON.parse(
    JSON.stringify(data, (_, value) =>
      typeof value === "bigint" ? value.toString() : value
    )
  );

export async function GET() {
  try {
    const data = await prisma.cms_footer_badge.findMany({
      where: { status: true },
      orderBy: { sort_order: "asc" },
    });

    return NextResponse.json({
      success: true,
      data: serializeBigInt(data),
    });
  } catch (error: any) {
    console.error("Fetch footer badges error:", error);
    return NextResponse.json(
      { success: false, message: error.message || "Failed to fetch footer badges" },
      { status: 500 }
    );
  }
}