diff --git a/apps/edr-freight-web/portal/src/pages/bookings/NewBookingPage.tsx b/apps/edr-freight-web/portal/src/pages/bookings/NewBookingPage.tsx index 2cf59dd40..a1cbc6376 100644 --- a/apps/edr-freight-web/portal/src/pages/bookings/NewBookingPage.tsx +++ b/apps/edr-freight-web/portal/src/pages/bookings/NewBookingPage.tsx @@ -33,7 +33,7 @@ export default function NewBookingPage() { const queryClient = useQueryClient(); const [step, setStep] = useState(1); const { customer } = useAuth(); - const { data: referenceData } = useQuery( + const { data: referenceData, isLoading: refDataLoading } = useQuery( api.bookings.referenceData.queryOptions(), ); @@ -181,13 +181,14 @@ export default function NewBookingPage() { {step === 1 && } {step === 2 && } {step === 3 && ( - + )} {step === 4 && ( )} {step === 5 && ( 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 89c2a648a..2713197a0 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,27 +1,28 @@ +import { useEffect, useMemo } from "react"; import { Controller, type UseFormReturn } from "react-hook-form"; import { Flame, MapPin, Snowflake } from "lucide-react"; -import { Field, SelectItem, Separator, Switch } from "@edr/ui-common"; +import { Field, SelectItem, Separator, Skeleton, Switch } from "@edr/ui-common"; import type { Freight } from "@edr/types"; import { type BookingFormValues, getRouteDirection, } from "./schema"; import { - AlertBox, SelectField, StepHeader, StepLabel, } from "./shared"; -import { useEffect, useMemo } from "react"; type BookingForm = UseFormReturn; export function Step4Route({ form, referenceData, + isLoading, }: { form: BookingForm; referenceData?: Freight.BookingReferenceData; + isLoading?: boolean; }) { const originYard = form.watch("originYard"); const destinationYard = form.watch("destinationYard"); @@ -70,52 +71,50 @@ export function Step4Route({ description="Select the origin and destination yards." /> -
- Route -
- ( - - - - )} - /> - ( - - - - )} - /> -
- {!referenceData && ( - - Loading reference data... - - )} - {direction && ( + {isLoading ? ( + + ) : ( +
+ Route +
+ ( + + + + )} + /> + ( + + + + )} + /> +
+ {direction && (
@@ -123,7 +122,8 @@ export function Step4Route({ {directionLabel[direction]}
)} -
+
+ )} {direction && direction != "domestic" && ( +
+
+ + +
+
+ + +
+
+ + + ); +} + function YardSelectOptions({ options, excludeValue, diff --git a/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/step5-cargo-details.tsx b/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/step5-cargo-details.tsx index 58af0897b..0105f54c3 100644 --- a/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/step5-cargo-details.tsx +++ b/apps/edr-freight-web/portal/src/pages/bookings/new-booking-form/step5-cargo-details.tsx @@ -1,7 +1,7 @@ import { useMemo } from "react"; import { Controller, useFieldArray, type UseFormReturn } from "react-hook-form"; import { MapPin, Package, Plus, Trash2, Weight } from "lucide-react"; -import { Button, Field, FieldError, FieldLabel, Input } from "@edr/ui-common"; +import { Button, Field, FieldError, FieldLabel, Input, Skeleton } from "@edr/ui-common"; import type { Freight } from "@edr/types"; import { calcWagons, @@ -23,10 +23,12 @@ export function Step5CargoDetails({ form, direction, referenceData, + isLoading, }: { form: BookingForm; direction: RouteDirection; referenceData?: Freight.BookingReferenceData; + isLoading?: boolean; }) { const cargoType = form.watch("cargoType"); const freightType = form.watch("freightType"); @@ -69,6 +71,26 @@ export function Step5CargoDetails({ return null; } + if (isLoading) { + return ( +
+ +
+ +
+ + +
+ + +
+
+ ); + } + return (