Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | import { Checkbox } from "@/ahuora-design-system/ui/checkbox";
import type {
BulkEquipmentSetupResult,
CapitalCostLineRead,
CostCurveRead,
} from "@/api/apiStore.gen";
import type { UnitCostRow } from "../../model/capitalLineTypes";
import { currentCostCurveLabel } from "./bulkSetupHelpers";
import { DriverInputsSummary } from "./DriverInputsSummary";
export function BulkCustomSelectionTable({
rows,
curves,
selectedCurve,
capitalLines,
previewResultsByMapping,
customSelection,
canEdit,
busy,
onSelectionChange,
}: {
rows: UnitCostRow[];
curves: CostCurveRead[];
selectedCurve?: CostCurveRead;
capitalLines: CapitalCostLineRead[];
previewResultsByMapping: Map<number, BulkEquipmentSetupResult>;
customSelection: Record<number, boolean>;
canEdit: boolean;
busy: boolean;
onSelectionChange: (customSelection: Record<number, boolean>) => void;
}) {
return (
<div className="grid gap-2 rounded-md bg-background p-2 text-xs">
{rows.length === 0 ? (
<div className="text-muted-foreground">
No enabled units in this category can receive a cost curve yet.
</div>
) : (
<div className="grid gap-2">
<div className="grid grid-cols-[minmax(8rem,1fr)_minmax(10rem,1fr)_minmax(14rem,1.2fr)] gap-3 px-1 text-[11px] font-medium text-muted-foreground">
<span>Unit operation</span>
<span>Current cost curve</span>
<span>Driver inputs</span>
</div>
{rows.map((row) => {
const unitName = row.unit.componentName || `Unit ${row.unit.id}`;
const mappingId = row.costableItem?.equipment_mapping?.id;
const previewResult =
typeof mappingId === "number"
? previewResultsByMapping.get(mappingId)
: undefined;
return (
<label
key={row.unit.id}
className="grid min-w-0 grid-cols-[minmax(8rem,1fr)_minmax(10rem,1fr)_minmax(14rem,1.2fr)] items-start gap-3 rounded-sm px-1 py-1"
>
<span className="flex min-w-0 items-center gap-2">
<Checkbox
checked={Boolean(customSelection[row.unit.id])}
disabled={!canEdit || busy}
aria-label={`Select ${unitName} for bulk setup apply`}
onCheckedChange={(checked) => {
onSelectionChange({
...customSelection,
[row.unit.id]: checked === true,
});
}}
/>
<span className="min-w-0 truncate font-medium">
{unitName}
</span>
</span>
<span className="min-w-0 truncate text-muted-foreground">
{currentCostCurveLabel(row, curves)}
</span>
<span className="min-w-0 text-muted-foreground">
<DriverInputsSummary
row={row}
selectedCurve={selectedCurve}
capitalLines={capitalLines}
previewResult={previewResult}
/>
</span>
</label>
);
})}
</div>
)}
</div>
);
}
|