From e152e7e9860f8cfc3bd2b2cc18b86dcada0527ae Mon Sep 17 00:00:00 2001 From: ghost2023 Date: Sat, 6 Jun 2026 11:44:15 +0300 Subject: [PATCH] fix: the request approaval pricing ui --- .../src/pages/bookings/BookingDetailPage.tsx | 58 ++++--------------- packages/types/src/freight/index.ts | 15 +++++ 2 files changed, 26 insertions(+), 47 deletions(-) diff --git a/apps/edr-freight-web/portal/src/pages/bookings/BookingDetailPage.tsx b/apps/edr-freight-web/portal/src/pages/bookings/BookingDetailPage.tsx index d4fcfae13..2dcecfaac 100644 --- a/apps/edr-freight-web/portal/src/pages/bookings/BookingDetailPage.tsx +++ b/apps/edr-freight-web/portal/src/pages/bookings/BookingDetailPage.tsx @@ -299,12 +299,7 @@ function DraftBookingView({ [booking.files], ); - const pricingQuery = useQuery( - api.bookings.generatePrice.queryOptions({ - input: { id: booking.id }, - enabled: !!booking.id, - }), - ); + const pricing = booking.pricingBreakdown; const uploadMutation = useMutation({ mutationFn: (files: Record) => @@ -499,7 +494,7 @@ function DraftBookingView({ @@ -512,28 +507,7 @@ function DraftBookingView({ - {pricingQuery.isLoading ? ( -
- -

- Calculating price… -

-
- ) : pricingQuery.isError ? ( -
-

- Could not calculate price. -

- -
- ) : pricingQuery.data ? ( + {pricing ? (
@@ -546,7 +520,7 @@ function DraftBookingView({ - {pricingQuery.data.lineItems.map((item, i) => ( + {pricing.lineItems.map((item, i) => (
{item.description} @@ -561,29 +535,19 @@ function DraftBookingView({ Total Estimated Cost - {pricingQuery.data.totalAmount.toLocaleString()}{" "} - {pricingQuery.data.currency} + {pricing.totalAmount.toLocaleString()}{" "} + {pricing.currency}
- - {pricingQuery.data.warnings.length > 0 && ( -
- {pricingQuery.data.warnings.map((w, i) => ( -

- - {w} -

- ))} -
- )}
- ) : null} + ) : ( +

+ Pricing will be calculated after submission. +

+ )}
diff --git a/packages/types/src/freight/index.ts b/packages/types/src/freight/index.ts index 7e20712d3..372c25d57 100644 --- a/packages/types/src/freight/index.ts +++ b/packages/types/src/freight/index.ts @@ -244,6 +244,21 @@ export interface IBooking extends BaseEntity { latestChangeRequestNote?: string | null; contractSummary?: string | null; + pricingBreakdown?: PricingBreakdown | null; +} + +export interface PricingBreakdownLineItem { + code: string; + amount: number; + currency: string; + description: string; +} + +export interface PricingBreakdown { + currency: string; + lineItems: PricingBreakdownLineItem[]; + generatedAt: string; + totalAmount: number; } export interface IInvoice extends BaseEntity {