From dd07442b92de0d48ca112c1d9bfe173f2d5f027f Mon Sep 17 00:00:00 2001 From: marshal Date: Sun, 21 Jun 2026 09:38:57 +0300 Subject: [PATCH] feat: switch API base URL to localhost for development and fix shipping line ID handling in booking form - Changed API_BASE_URL from production to localhost in both backoffice and portal configurations. - Updated booking form to use shipping line ID instead of name throughout the flow. - Fixed Step1ContractType to set shipping line ID when loading existing booking. - Updated Step4Route to key shipping line options by ID as required by API. - Enhanced Step8Review to display shipping line name by --- apps/edr-freight-web/backoffice/src/constants/apiConfig.ts | 4 ++-- apps/edr-freight-web/portal/src/constants/apiConfig.ts | 4 ++-- .../pages/bookings/new-booking-form/step1-contract-type.tsx | 2 +- .../src/pages/bookings/new-booking-form/step4-route.tsx | 4 ++-- .../src/pages/bookings/new-booking-form/step8-review.tsx | 5 ++++- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/apps/edr-freight-web/backoffice/src/constants/apiConfig.ts b/apps/edr-freight-web/backoffice/src/constants/apiConfig.ts index 030b051a1..a7c8670cf 100644 --- a/apps/edr-freight-web/backoffice/src/constants/apiConfig.ts +++ b/apps/edr-freight-web/backoffice/src/constants/apiConfig.ts @@ -1,3 +1,3 @@ -export const API_BASE_URL = 'https://edrfreightapi.triaplc.com'; +// export const API_BASE_URL = 'https://edrfreightapi.triaplc.com'; -// export const API_BASE_URL = 'http://localhost:3001'; +export const API_BASE_URL = 'http://localhost:3001'; diff --git a/apps/edr-freight-web/portal/src/constants/apiConfig.ts b/apps/edr-freight-web/portal/src/constants/apiConfig.ts index dce8aad63..fc9f57a58 100644 --- a/apps/edr-freight-web/portal/src/constants/apiConfig.ts +++ b/apps/edr-freight-web/portal/src/constants/apiConfig.ts @@ -1,3 +1,3 @@ -export const API_BASE_URL = 'https://edrfreightapi.triaplc.com'; -// export const API_BASE_URL = 'http://localhost:3001'; +// export const API_BASE_URL = 'https://edrfreightapi.triaplc.com'; +export const API_BASE_URL = 'http://localhost:3001'; diff --git a/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/step1-contract-type.tsx b/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/step1-contract-type.tsx index b4fa15f6b..1df664ff8 100644 --- a/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/step1-contract-type.tsx +++ b/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/step1-contract-type.tsx @@ -128,7 +128,7 @@ export function Step1ContractType({ (sl) => sl.id === booking.shippingLineId, ); if (shippingLine) { - form.setValue("shippingLine", shippingLine.name); + form.setValue("shippingLine", shippingLine.id); } } diff --git a/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/step4-route.tsx b/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/step4-route.tsx index cd05f4e9a..40fc1f061 100644 --- a/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/step4-route.tsx +++ b/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/step4-route.tsx @@ -35,7 +35,7 @@ export function Step4Route({ const shippingLineOptions = useMemo(() => { if (!referenceData?.shipping_line) return []; - // The form keys shipping line by name, so options are keyed by name too. + // The form keys shipping line by ID (required by API as UUID). // Dedupe by name: if the reference data has two lines sharing a name, a // duplicate option would crash Mantine's Select ("Duplicate options..."). const seen = new Set(); @@ -43,7 +43,7 @@ export function Step4Route({ for (const sl of referenceData.shipping_line) { if (!sl.name || seen.has(sl.name)) continue; seen.add(sl.name); - options.push({ value: sl.name, label: sl.name }); + options.push({ value: sl.id, label: sl.name }); } return options; }, [referenceData]); diff --git a/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/step8-review.tsx b/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/step8-review.tsx index c9c8265fe..ef5c840ef 100644 --- a/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/step8-review.tsx +++ b/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/step8-review.tsx @@ -151,6 +151,9 @@ export function Step8Review({ const serviceType = referenceData?.service.find( (s) => s.id === values.serviceTypeId, ); + const shippingLine = referenceData?.shipping_line.find( + (sl) => sl.id === values.shippingLine, + ); const containerSummary = values.cargoType === "container" && values.containers.length > 0 @@ -274,7 +277,7 @@ export function Step8Review({ value={`${originYardName} → ${destinationYardName}`} /> - +