From a279ec29efb863fefd1ca82e5b490f2e8784cf3c Mon Sep 17 00:00:00 2001
From: soryu <soryu@soryu.co>
Date: Sun, 25 Jan 2026 00:01:25 +0000
Subject: Move files tab and file pages to be accessible via contracts (#27)

* feat: remove Files from top-level navigation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: update file links to use contract-scoped routes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add contract context to FileDetail component

- Add contractId, contractName, and onContractClick props to FileDetailProps
- Update breadcrumb navigation to show contract name with path separator
  when viewing file within a contract context
- Fall back to "Back to list" when no contract context is provided
- This enables the FileDetail component to be used within the
  /contracts/:contractId/files/:fileId route

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* 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 <noreply@anthropic.com>

* Task completion checkpoint

* Task completion checkpoint

* Task completion checkpoint

* Task completion checkpoint

* Task completion checkpoint

* Task completion checkpoint

* Task completion checkpoint

* Task completion checkpoint

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
---
 frontend/src/components/FileDetail.tsx | 97 ++++++++++++++++++++++++++++++++++
 1 file changed, 97 insertions(+)
 create mode 100644 frontend/src/components/FileDetail.tsx

(limited to 'frontend/src/components/FileDetail.tsx')

diff --git a/frontend/src/components/FileDetail.tsx b/frontend/src/components/FileDetail.tsx
new file mode 100644
index 0000000..31228ef
--- /dev/null
+++ b/frontend/src/components/FileDetail.tsx
@@ -0,0 +1,97 @@
+import React, { useEffect, useState } from 'react'
+import { useParams, Link } from 'react-router-dom'
+
+interface File {
+  id: string
+  name: string
+  description?: string
+  body?: string
+  contract_id?: string
+  version: number
+  created_at: string
+}
+
+export function FileDetail() {
+  const { contractId, fileId } = useParams<{ contractId: string; fileId: string }>()
+  const [file, setFile] = useState<File | null>(null)
+  const [loading, setLoading] = useState(true)
+  const [error, setError] = useState<string | null>(null)
+
+  useEffect(() => {
+    async function fetchFile() {
+      if (!fileId) return
+
+      try {
+        setLoading(true)
+        const response = await fetch(`/api/v1/files/${fileId}`)
+        if (!response.ok) {
+          throw new Error(`Failed to fetch file: ${response.statusText}`)
+        }
+        const data = await response.json()
+        setFile(data)
+      } catch (err) {
+        setError(err instanceof Error ? err.message : 'Unknown error')
+      } finally {
+        setLoading(false)
+      }
+    }
+
+    fetchFile()
+  }, [fileId])
+
+  if (loading) {
+    return (
+      <div className="file-detail-container">
+        <div className="loading">Loading file...</div>
+      </div>
+    )
+  }
+
+  if (error) {
+    return (
+      <div className="file-detail-container">
+        <div className="error">Error: {error}</div>
+        <Link to={`/contracts/${contractId}`} className="back-link">
+          Back to Contract
+        </Link>
+      </div>
+    )
+  }
+
+  if (!file) {
+    return (
+      <div className="file-detail-container">
+        <div className="not-found">File not found</div>
+        <Link to={`/contracts/${contractId}`} className="back-link">
+          Back to Contract
+        </Link>
+      </div>
+    )
+  }
+
+  return (
+    <div className="file-detail-container">
+      <div className="file-detail-header">
+        <Link to={`/contracts/${contractId}`} className="back-link">
+          Back to Contract
+        </Link>
+        <h1 className="file-title">{file.name}</h1>
+        {file.description && (
+          <p className="file-description">{file.description}</p>
+        )}
+        <div className="file-meta">
+          <span>Version: {file.version}</span>
+          <span>Created: {new Date(file.created_at).toLocaleString()}</span>
+        </div>
+      </div>
+
+      <div className="file-detail-body">
+        {file.body ? (
+          <pre className="file-content">{file.body}</pre>
+        ) : (
+          <p className="no-content">No content</p>
+        )}
+      </div>
+    </div>
+  )
+}
-- 
cgit v1.2.3

