Merge branch 'feature/columns-slideover' into feature/filter-slideover

This commit is contained in:
Adam Moussa 2026-09-25 17:14:04 -04:00
commit b4f378075c
No known key found for this signature in database
3 changed files with 34 additions and 19 deletions

View file

@ -241,14 +241,10 @@ export function DashboardGrids() {
<Typography
data-testid="attention-banner"
variant="body2"
sx={{
display: "block",
mb: 1.5,
color: "primary.main",
textAlign: "left",
}}
color="text.secondary"
sx={{ display: "block", mb: 1.5, textAlign: "left" }}
>
{filteredAttention.length} invoices require approval. Show invoices ready to approve.
{filteredAttention.length} invoices require approval.
</Typography>
) : null}

View file

@ -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", () => {

View file

@ -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<MockInvoiceStatus, string> = {
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<MockInvoice, "activity" | "comments" | "dueDate">) {
@ -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: "",