import { NextResponse } from "next/server"; import { listCustomersForRepairForm, listSuppliersForRepairForm, } from "@/lib/server/repairs-service"; export const runtime = "nodejs"; export const dynamic = "force-dynamic"; /** * GET /api/v1/repairs/form-data * * Returns the lookup data needed by the "New Repair" + "Edit * Repair" forms: a small page of customers + suppliers. Orders * are NOT included here — they're served by the dedicated * `/api/v1/orders/lookup` endpoint so the order picker can search * server-side (the customers list is bounded and safe to ship * whole; the orders list is not, especially on a phone over a * dodgy cellular connection). */ export async function GET() { try { const [customers, suppliers] = await Promise.all([ listCustomersForRepairForm(), listSuppliersForRepairForm(), ]); return NextResponse.json({ customers, suppliers }); } catch (err: unknown) { const message = err instanceof Error ? err.message : "Failed to load form data"; return NextResponse.json({ error: message }, { status: 500 }); } }