Merge pull request #441 from Tria-plc/freight/feature/first_mile_invoice

fix
This commit is contained in:
yaschalew10
2026-07-04 03:59:09 +03:00
committed by GitHub
2 changed files with 32 additions and 4 deletions

View File

@@ -64,6 +64,19 @@ const STATUS_META: Record<FirstMileApiStatus, { label: string; color: string }>
RECEIVED_TO_PORT: { label: "Received to Port", color: "green" },
};
// Invoice payment state → badge color, keyed by upper-cased status.
const INVOICE_STATUS_META: Record<string, { label: string; color: string }> = {
PAID: { label: "Paid", color: "green" },
PARTIALLY_PAID: { label: "Partially Paid", color: "teal" },
PENDING: { label: "Pending", color: "yellow" },
UNPAID: { label: "Unpaid", color: "yellow" },
OPEN: { label: "Open", color: "yellow" },
ISSUED: { label: "Issued", color: "blue" },
OVERDUE: { label: "Overdue", color: "red" },
CANCELLED: { label: "Cancelled", color: "gray" },
VOID: { label: "Void", color: "gray" },
};
const NEXT_STATUS: Partial<Record<FirstMileApiStatus, FirstMileApiStatus>> = {
PAYMENT_PENDING: "READY_TO_TRANSIT",
READY_TO_TRANSIT: "IN_TRANSIT",
@@ -757,7 +770,8 @@ const FirstMilePage = () => {
if (!invoice) {
return <Text c="dimmed"></Text>;
}
const isPaid = (row.original as any).paid || invoice.status === "Paid";
const status = String((row.original as any).paid ? "PAID" : invoice.status || "").toUpperCase();
const badge = INVOICE_STATUS_META[status] ?? { color: "gray", label: status || "—" };
return (
<Group gap="xs" wrap="nowrap">
<UnstyledButton
@@ -772,7 +786,7 @@ const FirstMilePage = () => {
>
{invoice.number}
</UnstyledButton>
{isPaid && <Badge color="green" variant="light" size="sm">Paid</Badge>}
{status && <Badge color={badge.color} variant="filled" size="sm">{badge.label}</Badge>}
</Group>
);
},

View File

@@ -71,6 +71,19 @@ const STATUS_META: Record<LastMileApiStatus, { label: string; color: string }> =
DELIVERED: { label: "Delivered", color: "green" },
};
// Invoice payment state → badge color, keyed by upper-cased status.
const INVOICE_STATUS_META: Record<string, { label: string; color: string }> = {
PAID: { label: "Paid", color: "green" },
PARTIALLY_PAID: { label: "Partially Paid", color: "teal" },
PENDING: { label: "Pending", color: "yellow" },
UNPAID: { label: "Unpaid", color: "yellow" },
OPEN: { label: "Open", color: "yellow" },
ISSUED: { label: "Issued", color: "blue" },
OVERDUE: { label: "Overdue", color: "red" },
CANCELLED: { label: "Cancelled", color: "gray" },
VOID: { label: "Void", color: "gray" },
};
const NEXT_STATUS: Partial<Record<LastMileApiStatus, LastMileApiStatus>> = {
PAYMENT_PENDING: "READY_TO_TRANSIT",
READY_TO_TRANSIT: "IN_TRANSIT",
@@ -1128,7 +1141,8 @@ const LastMilePage = () => {
if (!invoice) {
return <Text c="dimmed"></Text>;
}
const isPaid = (row.original as any).paid || invoice.status === "Paid";
const status = String((row.original as any).paid ? "PAID" : invoice.status || "").toUpperCase();
const badge = INVOICE_STATUS_META[status] ?? { color: "gray", label: status || "—" };
return (
<Group gap="xs" wrap="nowrap">
<UnstyledButton
@@ -1143,7 +1157,7 @@ const LastMilePage = () => {
>
{invoice.number}
</UnstyledButton>
{isPaid && <Badge color="green" variant="light" size="sm">Paid</Badge>}
{status && <Badge color={badge.color} variant="filled" size="sm">{badge.label}</Badge>}
</Group>
);
},