mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 19:58:11 +00:00
changes
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
import type { Freight } from "@edr/types";
|
||||
|
||||
export interface ShipmentListRow {
|
||||
id: string;
|
||||
reference: string;
|
||||
contractId: string;
|
||||
contractReference: string;
|
||||
scheduledDate?: string | null;
|
||||
summary: string;
|
||||
status: Freight.BookingRequestStatus;
|
||||
createdBookingId?: string | null;
|
||||
}
|
||||
|
||||
export type ShipmentRowAction =
|
||||
| {
|
||||
kind: "navigate";
|
||||
label: string;
|
||||
to: (row: ShipmentListRow) => string;
|
||||
variant: "filled" | "light" | "default";
|
||||
}
|
||||
| {
|
||||
kind: "reject";
|
||||
label: string;
|
||||
variant: "light";
|
||||
};
|
||||
|
||||
/** Primary staff action for a shipment request list row. */
|
||||
export function getShipmentStaffRowAction(
|
||||
row: Pick<
|
||||
ShipmentListRow,
|
||||
"status" | "contractId" | "id" | "createdBookingId"
|
||||
>,
|
||||
): ShipmentRowAction {
|
||||
if (row.status === "PENDING") {
|
||||
return {
|
||||
kind: "navigate",
|
||||
label: "Accept",
|
||||
to: (r) =>
|
||||
`/dashboard/contracts/${r.contractId}/create-booking?requestId=${r.id}`,
|
||||
variant: "filled",
|
||||
};
|
||||
}
|
||||
if (row.status === "ACCEPTED" && row.createdBookingId) {
|
||||
return {
|
||||
kind: "navigate",
|
||||
label: "View clearance",
|
||||
to: (r) => `/dashboard/clearance/${r.createdBookingId}`,
|
||||
variant: "light",
|
||||
};
|
||||
}
|
||||
return {
|
||||
kind: "navigate",
|
||||
label: "Review",
|
||||
to: (r) => `/dashboard/shipment-requests/${r.id}`,
|
||||
variant: "default",
|
||||
};
|
||||
}
|
||||
|
||||
export function getShipmentRejectAction(
|
||||
row: Pick<ShipmentListRow, "status">,
|
||||
): ShipmentRowAction | null {
|
||||
if (row.status !== "PENDING") return null;
|
||||
return { kind: "reject", label: "Reject", variant: "light" };
|
||||
}
|
||||
Reference in New Issue
Block a user