Phase 2: API client, typed hooks, live probe

- Add api:types script (openapi-typescript against live FastAPI)
- Generate src/lib/api/types.ts (2972 lines, 55 paths, 16 schemas)
- lib/api/client.ts: typed apiRequest + ApiError + makeQueryClient
  (staleTime 5s, no refetchOnWindowFocus to preserve editor state)
- lib/providers.tsx: QueryClientProvider client component, useState
  singleton so App Router re-renders don't dump the cache
- lib/api/cases.ts: Case type + casesKeys + useCases hook (pragmatic
  hand-typed Case pending backend response-model annotations)
- layout.tsx: wrap children with <Providers>
- Smoke test: CasesLiveProbe component on home page hitting live FastAPI
  via /api/cases rewrite proxy

Phase 2 deliverable check: useCases() returns typed Case[] from the
production FastAPI through the Next.js proxy. End-to-end wiring proven.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Chaim
2026-04-11 15:49:24 +00:00
parent 64724656af
commit 0ee8e723bd
9 changed files with 3260 additions and 80 deletions

View File

@@ -1,5 +1,6 @@
import type { Metadata } from "next";
import { Heebo } from "next/font/google";
import { Providers } from "@/lib/providers";
import "./globals.css";
const heebo = Heebo({
@@ -21,7 +22,9 @@ export default function RootLayout({
}>) {
return (
<html lang="he" dir="rtl" className={`${heebo.variable} h-full antialiased`}>
<body className="min-h-full flex flex-col">{children}</body>
<body className="min-h-full flex flex-col">
<Providers>{children}</Providers>
</body>
</html>
);
}

View File

@@ -1,4 +1,5 @@
import { AppShell } from "@/components/app-shell";
import { CasesLiveProbe } from "@/components/cases/cases-live-probe";
export default function HomePage() {
return (
@@ -15,11 +16,8 @@ export default function HomePage() {
<hr className="border-0 h-[2px] bg-gradient-to-l from-transparent via-gold to-transparent" />
<div className="rounded-lg bg-surface shadow-sm p-6 border border-rule">
<p className="text-ink">
שלב 1 של תוכנית השדרוג הושלם: scaffold של Next.js 16, פורט של design
tokens ל-Tailwind v4, RTL עברית עם Heebo. הפאזות הבאות יביאו את 10
המסכים ל-parity עם ה-UI הקיים.
</p>
<h2 className="text-navy text-xl mb-3">פאזה 2 חיבור חי ל-API</h2>
<CasesLiveProbe />
</div>
</section>
</AppShell>