import type { ReactNode } from "react"; import { safeWorklistLink, worklistText } from "./worklistApi"; import type { WorklistCell, WorklistColumn, WorklistPage } from "./worklistApi"; export function worklistFigure(value: unknown, money = false): string { return typeof value === "number" && Number.isFinite(value) ? value.toLocaleString(undefined, money ? { minimumFractionDigits: 2, maximumFractionDigits: 2 } : { maximumFractionDigits: 20 }) : worklistText(value); } function Cell({ column, value }: { column: WorklistColumn; value: WorklistCell }) { if (value == null || value === "") return null; if (column.type === "link") { const href = safeWorklistLink(value); return href ? Open {worklistText(column.label)} : <>Link unavailable.; } return <>{column.type === "money" || column.type === "number" ? worklistFigure(value, column.type === "money") : worklistText(value)}; } export default function WorklistTable({ page, details, loading, problem, onShowMore, onRetry }: { page: WorklistPage | null; details?: ReactNode; loading: boolean; problem: string; onShowMore: () => void; onRetry: () => void; }) { return
{details || page?.validation.length ?
Details
{details} {page?.validation.length ?
    {page.validation.map((check, index) =>
  • {worklistText(check.check)} Worklist: {worklistFigure(check.a)} ยท Odoo: {worklistFigure(check.b)} {check.ok ? "Ties to Odoo" : "Does not tie to Odoo"}
  • )}
: null}
: null} {page ? <> {page.rows.length ? <>

{page.rows.length.toLocaleString()} of {page.total.toLocaleString()} rows

{page.columns.map((column) => )}{page.rows.map((row, rowIndex) => {page.columns.map((column, index) => )})}
{worklistText(column.label)}
:

Nothing found.

} : null} {loading ?
: null} {problem ?

{worklistText(problem)}{" "}

: null} {page && page.rows.length < page.total ? : null}
; }