import type { AllocationWithDetails, ColumnDef } from "@capakraken/shared"; import { ALLOCATION_STATUS_BADGE as STATUS_BADGE } from "~/lib/status-styles.js"; const STATUS_LEFT_BORDER: Record = { ACTIVE: "border-l-green-500", PROPOSED: "border-l-amber-500", CONFIRMED: "border-l-blue-500", COMPLETED: "border-l-gray-400", CANCELLED: "border-l-red-500", }; type AllocationRowProps = { alloc: AllocationWithDetails; visibleColumns: ColumnDef[]; isGrouped?: boolean; rowIndex?: number; isSelected: boolean; onToggleSelection: () => void; onEdit: () => void; onRequestDelete: () => void; deleteDisabled: boolean; formatPeriod: (alloc: AllocationWithDetails) => string; }; export function AllocationRow({ alloc, visibleColumns, isGrouped = false, rowIndex = 0, isSelected, onToggleSelection, onEdit, onRequestDelete, deleteDisabled, formatPeriod, }: AllocationRowProps) { const leftBorder = STATUS_LEFT_BORDER[alloc.status] ?? "border-l-gray-300"; return ( {visibleColumns.map((col) => { switch (col.key) { case "resource": return ( {isGrouped ? ( ) : ( (alloc.resource?.displayName ?? "—") )} ); case "project": return ( {alloc.project ? ( <> {alloc.project.shortCode}{" "} {alloc.project.name} ) : ( "—" )} ); case "role": return ( {alloc.role} ); case "dates": return ( {formatPeriod(alloc)} ); case "hoursPerDay": return ( {alloc.hoursPerDay}h ); case "cost": return ( {(alloc.dailyCostCents / 100).toFixed(0)} € ); case "status": return ( {alloc.status} ); default: return ( — ); } })}
); }