import SortTh from './SortTh'; function fmt(val) { return `$${Number(val || 0).toFixed(2)}`; } function inferItemType(item) { const match = String(item?.description || '').match(/\bR(\d{2})\b/i); if (match) { return Number(match[1]) <= 0 ? { label: 'New', badgeClass: 'badge-initial' } : { label: 'Revision', badgeClass: 'badge-client_revision' }; } if (item?.task_id) return { label: 'Task', badgeClass: 'badge-in_progress' }; return { label: 'Other', badgeClass: 'badge-initial' }; } export default function SubcontractorInvoiceDetailView({ error, headerActions, leftCardTitle, leftCardBody, rightCardTitle, rightCardBody, sortKey, sortDir, onSort, items, notes, total, }) { return (
{error ?
{error}
: null}
{leftCardTitle}
{leftCardBody}
{rightCardTitle}
{headerActions ?
{headerActions}
: null}
{rightCardBody}
Line Items
{items.length === 0 ? (
No line items.
) : (
TypeDescriptionQtyUnit PriceTotal {items.map((item) => { const itemType = inferItemType(item); return ( ); })}
{itemType.label} {item.description} {item.quantity} {fmt(item.unit_price)} {fmt(Number(item.unit_price || 0) * Number(item.quantity || 1))}
)}
Total
{fmt(total)}
{notes ? (
Notes

{notes}

) : null}
); }