mirror of
https://github.com/Sea-Haven-Industries/seahaven-ap.git
synced 2026-10-02 03:53:23 +00:00
Merge branch 'feature/columns-slideover' into feature/filter-slideover
This commit is contained in:
commit
b4f378075c
3 changed files with 34 additions and 19 deletions
|
|
@ -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}
|
||||
|
||||
|
|
|
|||
|
|
@ -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", () => {
|
||||
|
|
|
|||
|
|
@ -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: "",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue