Implement client-side validation for container and bulk cargo fields in booking form

This commit is contained in:
Marshal
2026-07-09 07:49:53 +00:00
parent 61ec67cc2e
commit c6198a4c62
2 changed files with 160 additions and 25 deletions

View File

@@ -482,10 +482,25 @@ export const contractsService = {
postContract<Freight.IContract>(C.OPS_CLEARANCE_FINALIZE(id)),
// ── Booking under contract (GL ET — Path B) ──
createBookingUnderContract: (
// The API returns { booking, warnings } (CreateBookingUnderContractResult) —
// unwrap to the booking itself so callers can use its id directly.
createBookingUnderContract: async (
id: string,
payload: Freight.CreateBookingUnderContractDto,
) => postContract<{ id: string; reference: string }>(C.BOOKINGS(id), payload),
): Promise<{ id: string; reference: string; warnings?: string[] }> => {
const result = await postContract<{
booking?: { id: string; reference: string };
id?: string;
reference?: string;
warnings?: string[];
}>(C.BOOKINGS(id), payload);
const booking = result.booking ?? result;
return {
id: booking.id ?? "",
reference: booking.reference ?? "",
warnings: result.warnings,
};
},
/**
* Pre-create validation + authoritative price preview: the same