diff options
| author | soryu <soryu@soryu.co> | 2026-01-25 02:55:45 +0000 |
|---|---|---|
| committer | soryu <soryu@soryu.co> | 2026-01-25 03:53:14 +0000 |
| commit | 9dc282e4777abf41178c44f14f8be3de1c725b10 (patch) | |
| tree | 2a18dcd3bfaf0bc3a2c0734209d810e28bfcf2dc /makima/frontend/src/lib/api.ts | |
| parent | 34bc1296a53d264216c12cbaa74ca9d68dfe8f22 (diff) | |
| download | soryu-9dc282e4777abf41178c44f14f8be3de1c725b10.tar.gz soryu-9dc282e4777abf41178c44f14f8be3de1c725b10.zip | |
feat: Update create contract modal to use dynamic templatesmakima/dynamic-contract-templates
- Add ContractTypeTemplate interface and listContractTypes API function
to frontend api.ts
- Add GET /api/v1/contract-types backend endpoint that returns built-in
contract types (simple, specification) with their phases and defaults
- Update create contract modal to fetch contract types dynamically when
opened, with loading state and fallback to hardcoded types on error
- Dynamically render contract type selection buttons from fetched types
- Update phase dropdown to use phases from selected contract type
- Replace static getValidPhases/getDefaultPhase calls with dynamic data
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat (limited to 'makima/frontend/src/lib/api.ts')
| -rw-r--r-- | makima/frontend/src/lib/api.ts | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/makima/frontend/src/lib/api.ts b/makima/frontend/src/lib/api.ts index 1ae4103..64ce591 100644 --- a/makima/frontend/src/lib/api.ts +++ b/makima/frontend/src/lib/api.ts @@ -1507,6 +1507,43 @@ export function getDefaultPhase(contractType: ContractType): ContractPhase { return "research"; } +// ============================================================================= +// Contract Type Templates +// ============================================================================= + +/** Contract type template returned by the API */ +export interface ContractTypeTemplate { + /** Template identifier (e.g., "simple", "specification") */ + id: string; + /** Display name */ + name: string; + /** Description of the contract type workflow */ + description: string; + /** Ordered list of phases for this contract type */ + phases: ContractPhase[]; + /** Default starting phase */ + defaultPhase: ContractPhase; + /** Whether this is a built-in type (always available) */ + isBuiltin: boolean; +} + +/** Response from list contract types endpoint */ +export interface ListContractTypesResponse { + types: ContractTypeTemplate[]; +} + +/** + * List available contract types/templates. + * Returns built-in types (simple, specification) and any custom types. + */ +export async function listContractTypes(): Promise<ListContractTypesResponse> { + const res = await authFetch(`${API_BASE}/api/v1/contract-types`); + if (!res.ok) { + throw new Error(`Failed to list contract types: ${res.statusText}`); + } + return res.json(); +} + export interface ContractRepository { id: string; contractId: string; |
