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 f7364af47..fc725c368 100644 --- a/apps/edr-freight-web/portal/src/pages/bookings/BookingDetailPage.tsx +++ b/apps/edr-freight-web/portal/src/pages/bookings/BookingDetailPage.tsx @@ -59,10 +59,11 @@ import { cn } from "@/lib/utils"; import useAuth from "@/hooks/useAuth"; const PROGRESS_STAGES = [ - { label: "Request", icon: FileText, statuses: ["DRAFT"] }, - { label: "Approval", icon: ClipboardCheck, statuses: ["CONFIRMED"] }, - { label: "In Transit", icon: Train, statuses: ["IN_TRANSIT"] }, - { label: "Complete", icon: PackageCheck, statuses: ["DELIVERED"] }, + { label: "Request", icon: FileText, statuses: ["DRAFT", "CHANGES_REQUESTED"] }, + { label: "Submitted", icon: ClipboardCheck, statuses: ["SUBMITTED", "PENDING_APPROVAL"] }, + { label: "Approved", icon: ShieldCheck, statuses: ["APPROVED_PENDING_SIGNATURE", "APPROVED", "CONTRACT_READY", "SIGNED_CUSTOMER", "FULLY_EXECUTED"] }, + { label: "In Transit", icon: Train, statuses: ["PNR_GENERATED", "PAYMENT_VERIFICATION_IN_PROGRESS", "PAID", "IN_TRANSIT", "PENDING_CONSOLIDATION", "CONSOLIDATED"] }, + { label: "Complete", icon: PackageCheck, statuses: ["COMPLETED", "DELIVERED"] }, ]; const STATUS_MAP: Record< @@ -75,23 +76,107 @@ const STATUS_MAP: Record< color: "text-muted-foreground", stage: 0, }, - CONFIRMED: { - title: "Booking Confirmed", - description: "Booking has been confirmed and approved.", + CHANGES_REQUESTED: { + title: "Changes Requested", + description: "Staff has requested changes. Please review and resubmit.", + color: "text-amber-600", + stage: 0, + }, + SUBMITTED: { + title: "Submitted", + description: "Your booking has been submitted for review.", color: "text-primary", stage: 1, }, + PENDING_APPROVAL: { + title: "Pending Approval", + description: "Booking is in the approval process.", + color: "text-primary", + stage: 1, + }, + APPROVED_PENDING_SIGNATURE: { + title: "Awaiting Signature", + description: "Approved — pending contract signature.", + color: "text-primary", + stage: 2, + }, + APPROVED: { + title: "Approved", + description: "Booking has been fully approved.", + color: "text-primary", + stage: 2, + }, + CONTRACT_READY: { + title: "Contract Ready", + description: "Contract is available for review and signature.", + color: "text-primary", + stage: 2, + }, + SIGNED_CUSTOMER: { + title: "Customer Signed", + description: "Customer has signed. Awaiting staff signature.", + color: "text-primary", + stage: 2, + }, + FULLY_EXECUTED: { + title: "Fully Executed", + description: "Contract has been fully signed and executed.", + color: "text-primary", + stage: 2, + }, + PNR_GENERATED: { + title: "PNR Generated", + description: "Payment reference number generated.", + color: "text-primary", + stage: 3, + }, + PAYMENT_VERIFICATION_IN_PROGRESS: { + title: "Payment Verification", + description: "Payment is being verified.", + color: "text-primary", + stage: 3, + }, + PAID: { + title: "Paid", + description: "Payment has been confirmed.", + color: "text-primary", + stage: 3, + }, IN_TRANSIT: { title: "Cargo Moving", description: "Shipment is currently moving through the rail network.", color: "text-primary", - stage: 2, + stage: 3, + }, + PENDING_CONSOLIDATION: { + title: "Pending Consolidation", + description: "Awaiting consolidation partner.", + color: "text-primary", + stage: 3, + }, + CONSOLIDATED: { + title: "Consolidated", + description: "Cargo has been consolidated with partner shipment.", + color: "text-primary", + stage: 3, + }, + COMPLETED: { + title: "Service Complete", + description: "Cargo delivered and service successfully terminated.", + color: "text-primary", + stage: 4, }, DELIVERED: { title: "Service Complete", description: "Cargo delivered and service successfully terminated.", color: "text-primary", - stage: 3, + stage: 4, + }, + REJECTED: { + title: "Rejected", + description: "This booking request has been rejected.", + color: "text-destructive", + stage: -1, }, CANCELLED: { title: "Cancelled", @@ -178,7 +263,7 @@ export default function BookingDetailPage() { ); } - if (booking.status === "DRAFT") { + if (booking.status === "DRAFT" || booking.status === "CHANGES_REQUESTED") { return ( ); @@ -309,10 +394,12 @@ function DraftBookingView({

{booking.reference}

- +

- Complete the steps below to submit your booking request. + {booking.status === "CHANGES_REQUESTED" + ? "Staff has requested changes. Please review, update, and resubmit." + : "Complete the steps below to submit your booking request."}

@@ -334,6 +421,16 @@ function DraftBookingView({ + {booking.status === "CHANGES_REQUESTED" && booking.latestChangeRequestNote && ( +
+ +
+

Changes Requested by Staff

+

{booking.latestChangeRequestNote}

+
+
+ )} + {pricingQuery.isError && (
@@ -747,8 +844,9 @@ function ReadonlyBookingView({ booking }: { booking: Freight.IBooking }) { - {(booking.status === "CONFIRMED" || - booking.status === "IN_TRANSIT") && ( + {(booking.status === "CONTRACT_READY" || + booking.status === "SIGNED_CUSTOMER" || + booking.status === "FULLY_EXECUTED") && (
@@ -1173,9 +1271,24 @@ function InfoItem({ function StatusBadge({ status }: { status: string }) { const statusColors: Record = { DRAFT: "bg-muted text-muted-foreground border-border", + CHANGES_REQUESTED: "bg-amber-50 text-amber-700 border-amber-200", + SUBMITTED: "bg-primary/10 text-primary border-primary/20", + PENDING_APPROVAL: "bg-primary/10 text-primary border-primary/20", + APPROVED_PENDING_SIGNATURE: "bg-primary/10 text-primary border-primary/20", + APPROVED: "bg-primary/10 text-primary border-primary/20", + CONTRACT_READY: "bg-primary/10 text-primary border-primary/20", + SIGNED_CUSTOMER: "bg-primary/10 text-primary border-primary/20", + FULLY_EXECUTED: "bg-primary/10 text-primary border-primary/20", + PNR_GENERATED: "bg-primary/10 text-primary border-primary/20", + PAYMENT_VERIFICATION_IN_PROGRESS: "bg-primary/10 text-primary border-primary/20", + PAID: "bg-primary/10 text-primary border-primary/20", CONFIRMED: "bg-primary/10 text-primary border-primary/20", IN_TRANSIT: "bg-primary/10 text-primary border-primary/20", + PENDING_CONSOLIDATION: "bg-primary/10 text-primary border-primary/20", + CONSOLIDATED: "bg-primary/10 text-primary border-primary/20", + COMPLETED: "bg-muted text-foreground border-border", DELIVERED: "bg-muted text-foreground border-border", + REJECTED: "bg-destructive/10 text-destructive border-destructive/20", CANCELLED: "bg-destructive/10 text-destructive border-destructive/20", }; diff --git a/packages/types/src/freight/index.ts b/packages/types/src/freight/index.ts index ee46f4d76..7e20712d3 100644 --- a/packages/types/src/freight/index.ts +++ b/packages/types/src/freight/index.ts @@ -34,10 +34,24 @@ export enum FreightType { export enum BookingStatus { Draft = "DRAFT", - Confirmed = "CONFIRMED", + Submitted = "SUBMITTED", + ChangesRequested = "CHANGES_REQUESTED", + PendingApproval = "PENDING_APPROVAL", + ApprovedPendingSignature = "APPROVED_PENDING_SIGNATURE", + Approved = "APPROVED", + ContractReady = "CONTRACT_READY", + SignedCustomer = "SIGNED_CUSTOMER", + FullyExecuted = "FULLY_EXECUTED", + PnrGenerated = "PNR_GENERATED", + PaymentVerificationInProgress = "PAYMENT_VERIFICATION_IN_PROGRESS", + Paid = "PAID", InTransit = "IN_TRANSIT", + Completed = "COMPLETED", Delivered = "DELIVERED", + Rejected = "REJECTED", Cancelled = "CANCELLED", + PendingConsolidation = "PENDING_CONSOLIDATION", + Consolidated = "CONSOLIDATED", } export enum ConsignmentStatus { @@ -227,6 +241,9 @@ export interface IBooking extends BaseEntity { resource: string; signedUrl?: string | null; }>; + + latestChangeRequestNote?: string | null; + contractSummary?: string | null; } export interface IInvoice extends BaseEntity {