import { useState } from "react"; import type { ContractSummary, ContractStatus } from "../../lib/api"; import { PhaseBadge } from "./PhaseBadge"; import { PhaseProgressBarCompact } from "./PhaseProgressBar"; import { ContractContextMenu } from "./ContractContextMenu"; interface ContractListProps { contracts: ContractSummary[]; loading: boolean; onSelect: (id: string) => void; onCreate: () => void; selectedId?: string; onMarkComplete?: (contract: ContractSummary) => void; onMarkActive?: (contract: ContractSummary) => void; onArchive?: (contract: ContractSummary) => void; onDelete?: (contract: ContractSummary) => void; onGoToSupervisor?: (contract: ContractSummary) => void; } const statusColors: Record = { active: "text-green-400", completed: "text-blue-400", archived: "text-[#555]", }; export function ContractList({ contracts, loading, onSelect, onCreate, selectedId, onMarkComplete, onMarkActive, onArchive, onDelete, onGoToSupervisor, }: ContractListProps) { const [filter, setFilter] = useState("all"); const [contextMenuPosition, setContextMenuPosition] = useState<{ x: number; y: number } | null>(null); const [contextMenuContract, setContextMenuContract] = useState(null); const handleContextMenu = (e: React.MouseEvent, contract: ContractSummary) => { e.preventDefault(); setContextMenuPosition({ x: e.clientX, y: e.clientY }); setContextMenuContract(contract); }; const closeContextMenu = () => { setContextMenuPosition(null); setContextMenuContract(null); }; const filteredContracts = filter === "all" ? contracts : contracts.filter((c) => c.status === filter); if (loading) { return (
Loading...
); } return (
{/* Header */}

Contracts

{/* Filter tabs */}
{(["all", "active", "completed", "archived"] as const).map((status) => ( ))}
{/* Contract list */}
{filteredContracts.length === 0 ? (

{filter === "all" ? "No contracts yet" : `No ${filter} contracts`}

) : (
{filteredContracts.map((contract) => ( ))}
)}
{/* Context Menu */} {contextMenuPosition && contextMenuContract && ( onMarkComplete?.(contextMenuContract)} onMarkActive={() => onMarkActive?.(contextMenuContract)} onArchive={() => onArchive?.(contextMenuContract)} onDelete={() => onDelete?.(contextMenuContract)} onGoToSupervisor={() => onGoToSupervisor?.(contextMenuContract)} /> )}
); } export function ContractCard({ contract, onClick, }: { contract: ContractSummary; onClick: () => void; }) { return ( ); }