From 6e4b70be34e85223d3b191e40fb8ba2a5059154d Mon Sep 17 00:00:00 2001 From: ghost2023 Date: Fri, 5 Jun 2026 11:28:43 +0300 Subject: [PATCH 1/3] chore: install date-fns --- apps/edr-freight-web/portal/package.json | 1 + pnpm-lock.yaml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/apps/edr-freight-web/portal/package.json b/apps/edr-freight-web/portal/package.json index 3cd617e0a..b9b33d35d 100644 --- a/apps/edr-freight-web/portal/package.json +++ b/apps/edr-freight-web/portal/package.json @@ -20,6 +20,7 @@ "axios": "^1.7.7", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", + "date-fns": "^3.6.0", "lucide-react": "^1.14.0", "radix-ui": "^1.4.3", "react": "19.2.6", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7270938b5..6a69f3c38 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -292,6 +292,9 @@ importers: clsx: specifier: ^2.1.1 version: 2.1.1 + date-fns: + specifier: ^3.6.0 + version: 3.6.0 lucide-react: specifier: ^1.14.0 version: 1.16.0(react@19.2.6) From f77dd543907f77a7bc1ee19094f505d39973a103 Mon Sep 17 00:00:00 2001 From: ghost2023 Date: Fri, 5 Jun 2026 11:36:13 +0300 Subject: [PATCH 2/3] feat: setup the recent booking endpoint and ui fixes --- .../portal/src/pages/MyPortalPage.tsx | 128 +++---- .../src/pages/bookings/BookingDetailPage.tsx | 311 ++++++++++-------- .../portal/src/pages/bookings/MyBookings.tsx | 54 +-- .../portal/src/services/api.ts | 3 +- .../portal/src/services/bookings.service.ts | 14 +- packages/types/src/freight/index.ts | 24 +- 6 files changed, 303 insertions(+), 231 deletions(-) diff --git a/apps/edr-freight-web/portal/src/pages/MyPortalPage.tsx b/apps/edr-freight-web/portal/src/pages/MyPortalPage.tsx index 6cb111bb7..b6b17e71f 100644 --- a/apps/edr-freight-web/portal/src/pages/MyPortalPage.tsx +++ b/apps/edr-freight-web/portal/src/pages/MyPortalPage.tsx @@ -1,5 +1,7 @@ import { useMemo, useState } from "react"; -import { Link } from "react-router-dom"; +import { Link, useNavigate } from "react-router-dom"; +import { format } from "date-fns"; +import { useQuery } from "@tanstack/react-query"; import { ArrowRight, Building2, @@ -7,6 +9,7 @@ import { Clock, DollarSign, Eye, + LoaderCircle, Mail, MapPin, Package, @@ -20,14 +23,12 @@ import { import { getCurrentCustomer, - getMyBookings, getMyInvoices, getMyShipments, } from "@/lib/currentCustomer"; import { formatCurrency } from "@/pages/billing/invoices.mock"; import type { ShipmentStatus } from "@/pages/tracking/shipments.mock"; import type { InvoiceStatus } from "@/pages/billing/invoices.mock"; -import type { BookingStatus } from "@/pages/bookings/bookings.mock"; import { Button, Card, @@ -36,16 +37,36 @@ import { CardTitle, CardDescription, } from "@edr/ui-common"; +import { api } from "@/services/api"; + +const ACTIVE_STATUSES = [ + "DRAFT", + "SUBMITTED", + "PENDING_APPROVAL", + "IN_TRANSIT", +]; export default function MyPortalPage() { const me = useMemo(() => getCurrentCustomer(), []); - const myBookings = useMemo(() => getMyBookings(), []); const myShipments = useMemo(() => getMyShipments(), []); const myInvoices = useMemo(() => getMyInvoices(), []); - const activeBookings = myBookings.filter( - (b) => b.status === "Confirmed" || b.status === "In Transit", + const navigate = useNavigate(); + + const bookingsQuery = useQuery( + api.bookings.list.queryOptions({ + input: { sortBy: "createdAt", sortOrder: "DESC" }, + }), ); + + const myBookings = useMemo( + () => + (bookingsQuery.data?.items ?? []).filter((b) => + ACTIVE_STATUSES.includes(b.status), + ), + [bookingsQuery.data], + ); + const activeShipments = myShipments.filter((s) => s.status === "In Transit"); const outstandingInvoices = myInvoices.filter( (inv) => inv.status === "Sent" || inv.status === "Overdue", @@ -58,7 +79,7 @@ export default function MyPortalPage() { .filter((inv) => inv.status === "Paid" && inv.currency === "USD") .reduce((sum, inv) => sum + inv.amount, 0); - const recentBookings = [...myBookings].slice(0, 5); + const recentBookings = myBookings.slice(0, 5); const recentInvoices = [...myInvoices].slice(0, 4); return ( @@ -117,7 +138,7 @@ export default function MyPortalPage() {