From 258f1eb45a8c154346bf392828c5bbfad49f41af Mon Sep 17 00:00:00 2001 From: Marshal Date: Sun, 28 Jun 2026 18:50:50 +0000 Subject: [PATCH] feat: implement booking action logic for contracts and enhance RecentContractsSection --- .../src/pages/MyPortalPage/MyPortalPage.tsx | 1 + .../components/RecentContractsSection.tsx | 24 +++++---- .../BookingDetailPage/ReadonlyBookingView.tsx | 13 +++-- .../src/pages/contracts/ContractsList.tsx | 29 ++++++---- .../contracts/contract-booking-action.ts | 54 +++++++++++++++++++ packages/types/src/freight/index.ts | 2 + 6 files changed, 100 insertions(+), 23 deletions(-) create mode 100644 apps/edr-freight-web/portal/src/pages/contracts/contract-booking-action.ts diff --git a/apps/edr-freight-web/portal/src/pages/MyPortalPage/MyPortalPage.tsx b/apps/edr-freight-web/portal/src/pages/MyPortalPage/MyPortalPage.tsx index 98ed091f9..cb350916d 100644 --- a/apps/edr-freight-web/portal/src/pages/MyPortalPage/MyPortalPage.tsx +++ b/apps/edr-freight-web/portal/src/pages/MyPortalPage/MyPortalPage.tsx @@ -96,6 +96,7 @@ export default function MyPortalPage() { diff --git a/apps/edr-freight-web/portal/src/pages/MyPortalPage/components/RecentContractsSection.tsx b/apps/edr-freight-web/portal/src/pages/MyPortalPage/components/RecentContractsSection.tsx index 898173942..14ac28b2b 100644 --- a/apps/edr-freight-web/portal/src/pages/MyPortalPage/components/RecentContractsSection.tsx +++ b/apps/edr-freight-web/portal/src/pages/MyPortalPage/components/RecentContractsSection.tsx @@ -1,12 +1,13 @@ import { Box, Button, Group, Skeleton, Stack, Text } from "@mantine/core"; import { memo } from "react"; import { useNavigate } from "react-router-dom"; -import { ArrowRight, FileSignature, Package, Plus } from "lucide-react"; +import { ArrowRight, FileSignature, Package, Plus, RefreshCw } from "lucide-react"; import type { Freight } from "@edr/types"; import { ContractDocButton, ContractStatusBadge, } from "@/pages/contracts/contract-ui"; +import { getContractBookingAction } from "@/pages/contracts/contract-booking-action"; import { Card } from "./Card"; import { EmptyState } from "./EmptyState"; @@ -14,16 +15,15 @@ const INK = "#10202F"; const MUTED = "#6B7C8E"; const BORDER = "#E6ECF2"; -// Statuses where a Path A customer may book directly against the contract. -const BOOKABLE = ["FULLY_EXECUTED", "CONTRACT_ACTIVE"]; - interface RecentContractsSectionProps { contracts: Freight.IContract[]; + bookings: Freight.IBooking[]; isLoading: boolean; } export const RecentContractsSection = memo(function RecentContractsSection({ contracts, + bookings, isLoading, }: RecentContractsSectionProps) { const navigate = useNavigate(); @@ -65,7 +65,7 @@ export const RecentContractsSection = memo(function RecentContractsSection({ const isGeneral = c.contractKind === "GENERAL"; const isContainer = c.freightType === "CONTAINER"; const canSign = c.status === "CONTRACT_READY"; - const canBook = !c.customsClearingEnabled && BOOKABLE.includes(c.status); + const bookingAction = getContractBookingAction(c, bookings); return ( Sign - ) : canBook ? ( + ) : bookingAction.kind !== "none" ? ( ) : (