This commit is contained in:
natib21
2026-07-03 20:43:26 +00:00
parent f5e68f5a61
commit 4ddf03e357
4 changed files with 53 additions and 27 deletions

View File

@@ -1086,35 +1086,25 @@ const LastMilePage = () => {
header: "Invoice",
meta: { headerClassName, cellClassName },
cell: ({ row }) => {
const hasDistance = row.original.exactKm != null && row.original.exactKm > 0;
const isPaid = (row.original as any).paid;
if (!hasDistance) {
// Only show an invoice once it's actually been generated — NOT merely
// because distance was entered.
const invoice = row.original.invoice;
if (!invoice) {
return <Text c="dimmed"></Text>;
}
if (isPaid) {
return (
<Group gap="xs" wrap="nowrap">
<UnstyledButton
onClick={() => openInvoice(row.original)}
c="blue"
fw={500}
style={{ textDecoration: "underline", cursor: "pointer" }}
>
#345
</UnstyledButton>
<Badge color="green" variant="light" size="sm">Paid</Badge>
</Group>
);
}
const isPaid = (row.original as any).paid || invoice.status === "Paid";
return (
<UnstyledButton
onClick={() => openInvoice(row.original)}
c="blue"
fw={500}
style={{ textDecoration: "underline", cursor: "pointer" }}
>
#345
</UnstyledButton>
<Group gap="xs" wrap="nowrap">
<UnstyledButton
onClick={() => openInvoice(row.original)}
c="blue"
fw={500}
style={{ textDecoration: "underline", cursor: "pointer" }}
>
{invoice.number}
</UnstyledButton>
{isPaid && <Badge color="green" variant="light" size="sm">Paid</Badge>}
</Group>
);
},
},

View File

@@ -64,6 +64,8 @@ export interface LastMileRecord {
distanceKm?: number | null;
vehicle?: LastMileVehicle | null;
}>;
/** Present only when an invoice has actually been generated (not on distance). */
invoice?: { number: string; status: string } | null;
createdAt: string;
updatedAt: string;
}