mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-01 21:43:27 +00:00
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { customers, type Customer } from "@/pages/customers/customers.mock";
|
|
import { bookings, type Booking } from "@/pages/bookings/bookings.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 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);
|
|
}
|