import { useState } from "react"; import type { ContractSummary, ContractPhase } from "../../lib/api"; import { WorkflowContractCard } from "./WorkflowContractCard"; interface PhaseColumnProps { phase: ContractPhase; contracts: ContractSummary[]; onContractClick: (contractId: string) => void; onDrop: (contractId: string, phase: ContractPhase) => void; onContextMenu?: (e: React.MouseEvent, contract: ContractSummary) => void; } const phaseConfig: Record< ContractPhase, { label: string; color: string; bgColor: string; borderColor: string } > = { research: { label: "Research", color: "text-purple-400", bgColor: "bg-purple-400/10", borderColor: "border-purple-400/30", }, specify: { label: "Specify", color: "text-blue-400", bgColor: "bg-blue-400/10", borderColor: "border-blue-400/30", }, plan: { label: "Plan", color: "text-cyan-400", bgColor: "bg-cyan-400/10", borderColor: "border-cyan-400/30", }, execute: { label: "Execute", color: "text-yellow-400", bgColor: "bg-yellow-400/10", borderColor: "border-yellow-400/30", }, review: { label: "Review", color: "text-green-400", bgColor: "bg-green-400/10", borderColor: "border-green-400/30", }, }; export function PhaseColumn({ phase, contracts, onContractClick, onDrop, onContextMenu, }: PhaseColumnProps) { const [isDragOver, setIsDragOver] = useState(false); const config = phaseConfig[phase]; const handleDragOver = (e: React.DragEvent) => { e.preventDefault(); setIsDragOver(true); }; const handleDragLeave = () => { setIsDragOver(false); }; const handleDrop = (e: React.DragEvent) => { e.preventDefault(); setIsDragOver(false); const contractId = e.dataTransfer.getData("contractId"); if (contractId) { onDrop(contractId, phase); } }; return (
{/* Column header */}
{config.label} ({contracts.length})
{/* Cards container */}
{contracts.length === 0 ? (
No contracts
) : ( contracts.map((contract) => ( onContractClick(contract.id)} onDragStart={(e) => { e.dataTransfer.setData("contractId", contract.id); e.dataTransfer.effectAllowed = "move"; }} onContextMenu={onContextMenu ? (e) => onContextMenu(e, contract) : undefined} /> )) )}
); }