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

export async function GET(request: Request) {
  const ids = new URL(request.url).searchParams.get("ids")?.split(",").filter(Boolean) ?? [];
  const products = await prisma.product.findMany({ where: { id: { in: ids }, itemKind: "PHYSICAL_BULLION", isPublicProduct: true } });
  return NextResponse.json(products.map((product) => ({
    ...product,
    totalSalePrice: String(product.totalSalePrice),
    customerPrice: String(product.customerPrice),
    manualPrice: String(product.manualPrice)
  })));
}
