42 lines
2.1 KiB
TypeScript
42 lines
2.1 KiB
TypeScript
// The Clerical home boards, from one list answer.
|
|||
|
|
import type { ColumnDef } from "../../components/Board";
|
||
|
|
import type { PacketCard } from "../../api/types";
|
||
|
|
import { IN_SHOP_OR_QC } from "../../lib/packets";
|
||
|
|
|
||
|
|
export const byTime = (a: string | null, b: string | null) => (a ?? "").localeCompare(b ?? "");
|
||
|
|
|
||
|
|
/** The boards of the Clerical home, from one list answer. */
|
||
|
|
export function clericalBoards(all: PacketCard[]): { columns: ColumnDef[]; flagged: number; warehouse: number; shop: number; toClose: number } {
|
||
|
|
const drafts = all.filter((p) => p.status === "draft").sort((a, b) => byTime(a.updated_at, b.updated_at));
|
||
|
|
const back = all.filter((p) => p.status === "complete" && p.routed_to === "databook");
|
||
|
|
const flagged = drafts.filter((p) => p.flag);
|
||
|
|
const going = drafts.filter((p) => !p.flag);
|
||
|
|
const toClose = back.filter((p) => !p.vclosed).sort((a, b) => byTime(a.status_at, b.status_at));
|
||
|
|
const toBook = back.filter((p) => p.vclosed).sort((a, b) => byTime(a.vclosed?.at ?? null, b.vclosed?.at ?? null));
|
||
|
|
const filed = all
|
||
|
|
.filter((p) => p.status === "filed")
|
||
|
|
.sort((a, b) => byTime(b.status_at, a.status_at))
|
||
|
|
.slice(0, 25);
|
||
|
|
const columns: ColumnDef[] = [
|
||
|
|
{ key: "cos", title: "Changes to approve", cards: [], empty: "Arrives in phase 3 with the VISUAL feed." },
|
||
|
|
{ key: "flagged", title: "Flagged", cards: flagged, empty: "Nothing flagged." },
|
||
|
|
{ key: "going", title: "Going to the warehouse", cards: going, empty: "Drafts with nothing flagged wait here." },
|
||
|
|
{
|
||
|
|
key: "close",
|
||
|
|
title: "Ready to close",
|
||
|
|
cards: toClose,
|
||
|
|
empty: "Finished packets come back here. Close the job in VISUAL, then mark it closed on the packet.",
|
||
|
|
},
|
||
|
|
{ key: "book", title: "Ready for data book", cards: toBook, empty: "Jobs closed in VISUAL wait here for the data book." },
|
||
|
|
{ key: "filed", title: "Filed", cards: filed, empty: "Nothing filed yet." },
|
||
|
|
];
|
||
|
|
return {
|
||
|
|
columns,
|
||
|
|
flagged: flagged.length,
|
||
|
|
warehouse: all.filter((p) => p.status === "warehouse").length,
|
||
|
|
shop: all.filter((p) => IN_SHOP_OR_QC.includes(p.status)).length,
|
||
|
|
toClose: toClose.length,
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|