import { customers, type Customer } from "@/pages/customers/customers.mock"; import { bookings, type Booking } from "@/pages/bookings/bookings.mock"; import { consignments, type Consignment, } from "@/pages/consignments/consignments.mock"; import { shipments, type Shipment, } from "@/pages/tracking/shipments.mock"; import { invoices, type Invoice } from "@/pages/billing/invoices.mock"; /** * Mock "logged-in customer". When auth integrates, replace this with the value * pulled from `@edr/iamui-common` / the JWT context. */ const CURRENT_CUSTOMER_ID = 1; export function getCurrentCustomer(): Customer { return ( customers.find((c) => c.id === CURRENT_CUSTOMER_ID) ?? (customers[0] as Customer) ); } export function getMyBookings(): Booking[] { const me = getCurrentCustomer(); return bookings.filter((b) => b.customerId === me.id); } export function getMyConsignments(): Consignment[] { const me = getCurrentCustomer(); const myBookingIds = new Set(getMyBookings().map((b) => b.id)); return consignments.filter((c) => myBookingIds.has(c.bookingId)); } export function getMyShipments(): Shipment[] { const myBookingIds = new Set(getMyBookings().map((b) => b.id)); return shipments.filter((s) => myBookingIds.has(s.bookingId)); } export function getMyInvoices(): Invoice[] { const me = getCurrentCustomer(); return invoices.filter((inv) => inv.customerId === me.id); }