diff --git a/src/dashboard/DashboardGrids.tsx b/src/dashboard/DashboardGrids.tsx index cbff4d9..1af6e1f 100644 --- a/src/dashboard/DashboardGrids.tsx +++ b/src/dashboard/DashboardGrids.tsx @@ -241,14 +241,10 @@ export function DashboardGrids() { - {filteredAttention.length} invoices require approval. Show invoices ready to approve. + {filteredAttention.length} invoices require approval. ) : null} diff --git a/src/mocks/index.test.ts b/src/mocks/index.test.ts index 506a8f0..0729bd8 100644 --- a/src/mocks/index.test.ts +++ b/src/mocks/index.test.ts @@ -84,6 +84,26 @@ describe("mocks module", () => { expect(pending.every((invoice) => invoice.actionLabel === "Approve invoice")).toBe(true); const nonPending = invoices.filter((invoice) => invoice.status !== "pending_approval"); expect(nonPending.every((invoice) => invoice.actionLabel !== "Approve invoice")).toBe(true); + expect( + invoices + .filter((invoice) => invoice.status === "approved") + .every((invoice) => invoice.actionLabel === "Approved"), + ).toBe(true); + expect( + invoices + .filter((invoice) => invoice.status === "paid") + .every((invoice) => invoice.actionLabel === "Paid"), + ).toBe(true); + expect( + invoices + .filter((invoice) => invoice.status === "scheduled") + .every((invoice) => invoice.actionLabel === "Scheduled"), + ).toBe(true); + expect( + invoices + .filter((invoice) => invoice.status === "rejected") + .every((invoice) => invoice.actionLabel === "Rejected"), + ).toBe(true); }); it("seeds at least two invoices per dashboard tab", () => { diff --git a/src/mocks/invoices.ts b/src/mocks/invoices.ts index a565190..3ff6ff0 100644 --- a/src/mocks/invoices.ts +++ b/src/mocks/invoices.ts @@ -1,4 +1,3 @@ -import { INVOICE_ACTION_OPTIONS } from "@/dashboard/column-catalog"; import { syncMockApprovalsForInvoice } from "@/mocks/approvals"; import { areMocksEnabled } from "@/mocks/env"; @@ -104,16 +103,16 @@ type MockInvoiceCore = Omit< | "rowCount" >; -/** Non-pending rows never show the pending-only "Approve invoice" action. */ -const NON_PENDING_ACTION_OPTIONS = INVOICE_ACTION_OPTIONS.filter( - (option) => option !== "Approve invoice", -); +const ACTION_LABEL_BY_STATUS: Record = { + pending_approval: "Approve invoice", + approved: "Approved", + scheduled: "Scheduled", + paid: "Paid", + rejected: "Rejected", +}; -function actionLabelForStatus(status: MockInvoiceStatus, index: number): string { - if (status === "pending_approval") { - return "Approve invoice"; - } - return NON_PENDING_ACTION_OPTIONS[index % NON_PENDING_ACTION_OPTIONS.length]; +function actionLabelForStatus(status: MockInvoiceStatus): string { + return ACTION_LABEL_BY_STATUS[status]; } function derivedActivityFields(invoice: Pick) { @@ -160,7 +159,7 @@ function invoiceDateBeforeDue(dueDate: string, index: number): string { function withRefreshedCatalogFields(invoice: MockInvoice, index: number): MockInvoice { return { ...invoice, - actionLabel: actionLabelForStatus(invoice.status, index), + actionLabel: actionLabelForStatus(invoice.status), ...derivedActivityFields(invoice), description: invoice.memo, paymentAccount: paymentAccountFor(invoice.paymentMethod), @@ -175,7 +174,7 @@ function enrichInvoice(core: MockInvoiceCore, index: number): MockInvoice { hasBolt: index % 3 === 0, hasBell: index % 2 === 0, hasEye: true, - actionLabel: actionLabelForStatus(core.status, index), + actionLabel: actionLabelForStatus(core.status), lastUpdate: "", lastUpdateMessage: "", lastUpdateActorName: "",