From a62242a3898acad6e3972f11afad5ee2810d4b04 Mon Sep 17 00:00:00 2001 From: soryu Date: Sat, 24 Jan 2026 19:06:58 +0000 Subject: feat: update routes to nest files under contracts - Add react-router-dom for client-side routing - Create ContractList component to list all contracts - Create ContractDetail component with tabs (overview, files, tasks, repos) - Create FileDetail component to view individual files - Configure routes: - /contracts - list all contracts - /contracts/:id - view contract details with Files tab - /contracts/:contractId/files/:fileId - view file in contract context - Remove standalone file routes (/files, /files/:id) Files are now only accessible through their parent contract. Co-Authored-By: Claude Opus 4.5 --- frontend/src/components/ContractDetail.tsx | 232 +++++++++++++++++++++++++++++ 1 file changed, 232 insertions(+) create mode 100644 frontend/src/components/ContractDetail.tsx (limited to 'frontend/src/components/ContractDetail.tsx') diff --git a/frontend/src/components/ContractDetail.tsx b/frontend/src/components/ContractDetail.tsx new file mode 100644 index 0000000..72527ce --- /dev/null +++ b/frontend/src/components/ContractDetail.tsx @@ -0,0 +1,232 @@ +import React, { useEffect, useState } from 'react' +import { useParams, Link } from 'react-router-dom' + +interface FileSummary { + id: string + name: string + description?: string + contract_phase?: string +} + +interface TaskSummary { + id: string + name: string + status: string +} + +interface ContractRepository { + id: string + name: string + source_type: string + is_primary: boolean +} + +interface Contract { + id: string + name: string + description?: string + contract_type: string + phase: string + status: string + version: number + created_at: string +} + +interface ContractWithRelations { + contract: Contract + repositories: ContractRepository[] + files: FileSummary[] + tasks: TaskSummary[] +} + +type Tab = 'overview' | 'files' | 'tasks' | 'repositories' + +export function ContractDetail() { + const { id } = useParams<{ id: string }>() + const [data, setData] = useState(null) + const [loading, setLoading] = useState(true) + const [error, setError] = useState(null) + const [activeTab, setActiveTab] = useState('overview') + + useEffect(() => { + async function fetchContract() { + if (!id) return + + try { + setLoading(true) + const response = await fetch(`/api/v1/contracts/${id}`) + if (!response.ok) { + throw new Error(`Failed to fetch contract: ${response.statusText}`) + } + const contractData = await response.json() + setData(contractData) + } catch (err) { + setError(err instanceof Error ? err.message : 'Unknown error') + } finally { + setLoading(false) + } + } + + fetchContract() + }, [id]) + + if (loading) { + return ( +
+
Loading contract...
+
+ ) + } + + if (error) { + return ( +
+
Error: {error}
+ + Back to Contracts + +
+ ) + } + + if (!data) { + return ( +
+
Contract not found
+ + Back to Contracts + +
+ ) + } + + const { contract, repositories, files, tasks } = data + + return ( +
+
+ + Back to Contracts + +

{contract.name}

+ {contract.description && ( +

{contract.description}

+ )} +
+ Phase: {contract.phase} + Status: {contract.status} + Version: {contract.version} +
+
+ +
+ + + + +
+ +
+ {activeTab === 'overview' && ( +
+

Contract Overview

+
+
Type
+
{contract.contract_type}
+
Phase
+
{contract.phase}
+
Status
+
{contract.status}
+
Created
+
{new Date(contract.created_at).toLocaleString()}
+
+
+ )} + + {activeTab === 'files' && ( +
+

Files

+ {files.length === 0 ? ( +

No files in this contract

+ ) : ( +
    + {files.map((file) => ( +
  • + +

    {file.name}

    + {file.description &&

    {file.description}

    } + {file.contract_phase && ( + Phase: {file.contract_phase} + )} + +
  • + ))} +
+ )} +
+ )} + + {activeTab === 'tasks' && ( +
+

Tasks

+ {tasks.length === 0 ? ( +

No tasks in this contract

+ ) : ( +
    + {tasks.map((task) => ( +
  • +

    {task.name}

    + + {task.status} + +
  • + ))} +
+ )} +
+ )} + + {activeTab === 'repositories' && ( +
+

Repositories

+ {repositories.length === 0 ? ( +

No repositories linked to this contract

+ ) : ( +
    + {repositories.map((repo) => ( +
  • +

    + {repo.name} + {repo.is_primary && Primary} +

    + {repo.source_type} +
  • + ))} +
+ )} +
+ )} +
+
+ ) +} -- cgit v1.2.3