import type { AllocationWithDetails, AllocationStatus } from "@capakraken/shared"; import { ALLOCATION_STATUS_BADGE as STATUS_BADGE } from "~/lib/status-styles.js"; import { ConfirmDialog } from "~/components/ui/ConfirmDialog.js"; import { BatchActionBar } from "~/components/ui/BatchActionBar.js"; import { BatchDateShiftModal } from "./BatchDateShiftModal.js"; const ALL_ALLOC_STATUSES = [ { value: "PROPOSED", label: "Proposed" }, { value: "CONFIRMED", label: "Confirmed" }, { value: "ACTIVE", label: "Active" }, { value: "COMPLETED", label: "Completed" }, { value: "CANCELLED", label: "Cancelled" }, ] as const; type ConfirmDeleteState = { single?: AllocationWithDetails; ids?: string[]; } | null; type ConfirmBatchStatusState = { ids: string[]; status: string; } | null; type AllocationBatchDialogsProps = { selectionCount: number; selectedMutationIds: string[]; onClearSelection: () => void; // Batch status picker batchStatusPickerOpen: boolean; onOpenBatchStatusPicker: () => void; onCloseBatchStatusPicker: () => void; batchStatusPending: boolean; onBatchStatusConfirm: (ids: string[], status: AllocationStatus) => void; // Delete confirmDelete: ConfirmDeleteState; onSetConfirmDelete: (state: ConfirmDeleteState) => void; onSingleDelete: (alloc: AllocationWithDetails) => void; onBatchDelete: (ids: string[]) => void; batchDeletePending: boolean; // Date shift showDateShiftModal: boolean; onOpenDateShiftModal: () => void; onCloseDateShiftModal: () => void; onDateShiftConfirm: (daysDelta: number) => void; dateShiftPending: boolean; }; export function AllocationBatchDialogs({ selectionCount, selectedMutationIds, onClearSelection, batchStatusPickerOpen, onOpenBatchStatusPicker, onCloseBatchStatusPicker, batchStatusPending, onBatchStatusConfirm, confirmDelete, onSetConfirmDelete, onSingleDelete, onBatchDelete, batchDeletePending, showDateShiftModal, onOpenDateShiftModal, onCloseDateShiftModal, onDateShiftConfirm, dateShiftPending, }: AllocationBatchDialogsProps) { return ( <> {/* Batch Status Picker */} {batchStatusPickerOpen && (
e.stopPropagation()} >

Set status for {selectionCount} allocations

{ALL_ALLOC_STATUSES.map((s) => ( ))}
)} {/* Confirm single delete */} {confirmDelete?.single && ( { onSingleDelete(confirmDelete.single!); onSetConfirmDelete(null); }} onCancel={() => onSetConfirmDelete(null)} /> )} {/* Confirm batch delete */} {confirmDelete?.ids && ( { onBatchDelete(confirmDelete.ids!); onSetConfirmDelete(null); }} onCancel={() => onSetConfirmDelete(null)} /> )} {/* Batch Action Bar */} onSetConfirmDelete({ ids: selectedMutationIds }), disabled: batchDeletePending, }, ]} /> {/* Batch date shift modal */} {showDateShiftModal && ( )} ); }