Description
Replace placeholder functions with real API calls. Wire 'Load Example' to /example and 'Analyze' to /analyze. Render DiagnosticCard on success.
Implementation details
lib/api.ts:
loadExample(domain: string): Promise<ExampleResponse>
analyzeExample(exampleId: string): Promise<AnalyzeResponse>
- Both POST to backend, URL from
NEXT_PUBLIC_API_URL (default: http://localhost:8000)
- On
loadExample success: populate preview card
- On
analyzeExample success: render <DiagnosticCard result={response} />
- On any error: inline error message
- Disable relevant buttons during in-flight requests
- Create
.env.local.example documenting all env vars
Acceptance criteria
TDD
frontend/__tests__/api.test.ts and page.test.tsx:
loadExample posts to /example with correct domain
analyzeExample posts to /analyze with correct example_id
- Both return parsed responses on 200
- Both throw on non-200
- Preview card populates after
loadExample
- DiagnosticCard renders after
analyzeExample
- Buttons disabled during loading
Description
Replace placeholder functions with real API calls. Wire 'Load Example' to
/exampleand 'Analyze' to/analyze. RenderDiagnosticCardon success.Implementation details
lib/api.ts:loadExample(domain: string): Promise<ExampleResponse>analyzeExample(exampleId: string): Promise<AnalyzeResponse>NEXT_PUBLIC_API_URL(default:http://localhost:8000)loadExamplesuccess: populate preview cardanalyzeExamplesuccess: render<DiagnosticCard result={response} />.env.local.exampledocumenting all env varsAcceptance criteria
.env.local.exampledocumentedTDD
frontend/__tests__/api.test.tsandpage.test.tsx:loadExampleposts to/examplewith correct domainanalyzeExampleposts to/analyzewith correct example_idloadExampleanalyzeExample