- Introduced a new toggle in the quotes and archive pages to allow users to include older quotes beyond the default 90-day cutoff. - Updated the search parameters in the quotes and archive APIs to handle the new `includeOlder` flag, enabling full history searches. - Enhanced the user interface to reflect the current search scope, providing clear feedback on whether the search is limited to recent quotes or includes the full archive. - Adjusted the quotes search service to support the new functionality, ensuring efficient retrieval of older quotes when requested. - Added relevant tests to verify the correct behavior of the new search feature and its integration with existing functionality.
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
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 });
|
|
}
|
|
}
|