diff --git a/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/schema.ts b/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/schema.ts index 3a59e5715..ef36292e5 100644 --- a/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/schema.ts +++ b/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/schema.ts @@ -282,10 +282,10 @@ export function getRouteDirection( return "DOMESTIC"; } if (origin.country === "Ethiopia" && dest.country === "Djibouti") { - return "IMPORT"; + return "EXPORT"; } if (origin.country === "Djibouti" && dest.country === "Ethiopia") { - return "EXPORT"; + return "IMPORT"; } return null; 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 e8d0310c4..e9d4a387e 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 @@ -1,8 +1,8 @@ +import type { Freight } from "@edr/types"; +import { Divider, Skeleton, Stack, Switch } from "@mantine/core"; +import { Flame, MapPin, Snowflake } from "lucide-react"; import { useEffect, useMemo } from "react"; import { Controller, type UseFormReturn } from "react-hook-form"; -import { Flame, MapPin, Snowflake } from "lucide-react"; -import { Divider, Skeleton, Stack, Switch } from "@mantine/core"; -import type { Freight } from "@edr/types"; import { BookingFormInputValues, type BookingFormValues, @@ -56,25 +56,24 @@ export function Step4Route({ return true; }); }, [yardOptions, destinationYard]); - console.log({ yardOptions, originYard, destinationYard }); const destData = useMemo(() => { return yardOptions.filter((o) => o.value !== originYard); }, [yardOptions, originYard]); - const direction = getRouteDirection( - referenceData?.yard.find((y) => y.id === originYard), - referenceData?.yard.find((y) => y.name === destinationYard), - ); + const origin = referenceData?.yard.find((y) => y.id === originYard); + const dest = referenceData?.yard.find((y) => y.id === destinationYard); + const direction = getRouteDirection(origin, dest); + console.log({ yardOptions, originYard, destinationYard, direction, origin, dest }); const directionStyle: Record = { - export: "bg-sky-50 text-sky-800 border-sky-200", - import: "bg-amber-50 text-amber-800 border-amber-200", - domestic: "bg-gray-100 text-gray-600 border-gray-200", + EXPORT: "bg-sky-50 text-sky-800 border-sky-200", + IMPORT: "bg-amber-50 text-amber-800 border-amber-200", + DOMESTIC: "bg-gray-100 text-gray-600 border-gray-200", }; const directionLabel: Record = { - export: "Export workflow (inside country to outside country)", - import: "Import workflow (outside country to inside country)", - domestic: "Domestic corridor", + EXPORT: "Export workflow (inside country to outside country)", + IMPORT: "Import workflow (outside country to inside country)", + DOMESTIC: "Domestic corridor", }; useEffect(() => {