import React, { useEffect, useState } from 'react' import { Link } from 'react-router-dom' interface ContractSummary { id: string name: string description?: string contract_type: string phase: string status: string localOnly?: boolean autoMergeLocal?: boolean file_count: number task_count: number repository_count: number created_at: string } export function ContractList() { const [contracts, setContracts] = useState([]) const [loading, setLoading] = useState(true) const [error, setError] = useState(null) useEffect(() => { async function fetchContracts() { try { setLoading(true) const response = await fetch('/api/v1/contracts') if (!response.ok) { throw new Error(`Failed to fetch contracts: ${response.statusText}`) } const data = await response.json() setContracts(data.contracts || []) } catch (err) { setError(err instanceof Error ? err.message : 'Unknown error') } finally { setLoading(false) } } fetchContracts() }, []) if (loading) { return (
Loading contracts...
) } if (error) { return (
Error: {error}
) } return (

Contracts

{contracts.length === 0 ? (

No contracts found

) : (
    {contracts.map((contract) => (
  • {contract.name}

    {contract.description &&

    {contract.description}

    }
    Phase: {contract.phase} Status: {contract.status} Files: {contract.file_count} Tasks: {contract.task_count}
  • ))}
)}
) }