From 99abf5dff005c9e1f2c15298074f26f8ea353b42 Mon Sep 17 00:00:00 2001 From: Sluijsens Date: Sat, 1 Aug 2026 22:20:31 +0200 Subject: [PATCH] Hernoem packages endpoint naar /api/v1/offerings De frontend haalt de pakketten-data nu op via /api/v1/offerings i.p.v. /api/v1/packages. --- .../functional-design/packages-api-handoff.md | 6 +++--- src/features/landing/__tests__/PackagesSection.test.tsx | 4 ++-- src/features/landing/data/content.ts | 2 +- src/features/landing/hooks/usePackagesQuery.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/aidlc-docs/features/react-frontend/construction/react-frontend-app/functional-design/packages-api-handoff.md b/aidlc-docs/features/react-frontend/construction/react-frontend-app/functional-design/packages-api-handoff.md index 31d559b..6c0b736 100644 --- a/aidlc-docs/features/react-frontend/construction/react-frontend-app/functional-design/packages-api-handoff.md +++ b/aidlc-docs/features/react-frontend/construction/react-frontend-app/functional-design/packages-api-handoff.md @@ -1,4 +1,4 @@ -# Hand-off: Packages API (`GET /api/v1/packages`) +# Hand-off: Packages API (`GET /api/v1/offerings`) **Audience**: whoever implements the CMS/backend that will serve package content. **Status**: frontend is already wired up and waiting on this endpoint to exist. @@ -19,10 +19,10 @@ it yet. ### Endpoint ``` -GET /api/v1/packages +GET /api/v1/offerings ``` -- **Same domain as the site, relative path.** The frontend calls `fetch('/api/v1/packages')` +- **Same domain as the site, relative path.** The frontend calls `fetch('/api/v1/offerings')` with no protocol/host — it relies on the API being reachable under the *same* origin the React app is served from, both on `test.slpsoftware.nl` and on production (`slpsoftware.nl`). Today, both Pis only serve the static React build (see diff --git a/src/features/landing/__tests__/PackagesSection.test.tsx b/src/features/landing/__tests__/PackagesSection.test.tsx index 6c68c35..2d146dd 100644 --- a/src/features/landing/__tests__/PackagesSection.test.tsx +++ b/src/features/landing/__tests__/PackagesSection.test.tsx @@ -27,7 +27,7 @@ describe('PackagesSection', () => { vi.unstubAllGlobals(); }); - it('fetches packages from /api/v1/packages and renders one PackageCard per package', async () => { + it('fetches packages from /api/v1/offerings and renders one PackageCard per package', async () => { mockFetchOnce(new Response(JSON.stringify(packages), { status: 200 })); renderWithQueryClient(); @@ -36,7 +36,7 @@ describe('PackagesSection', () => { expect(screen.getByTestId('packages-grid').children.length).toBe(packages.length); }); - expect(fetch).toHaveBeenCalledWith('/api/v1/packages'); + expect(fetch).toHaveBeenCalledWith('/api/v1/offerings'); for (const pkg of packages) { expect(screen.getByTestId(`package-card-${pkg.id}`)).toBeInTheDocument(); expect(screen.getByText(pkg.title)).toBeInTheDocument(); diff --git a/src/features/landing/data/content.ts b/src/features/landing/data/content.ts index 3c9f399..75442b4 100644 --- a/src/features/landing/data/content.ts +++ b/src/features/landing/data/content.ts @@ -7,7 +7,7 @@ * * This module is the source of truth for content that isn't (yet) API-backed * (requirements FR-1/FR-6). `packages` is the exception: it now also doubles as - * the reference/seed data for the `/api/v1/packages` contract consumed via + * the reference/seed data for the `/api/v1/offerings` contract consumed via * src/features/landing/hooks/usePackagesQuery.ts (requirements FR-5) — see * aidlc-docs/features/react-frontend/construction/react-frontend-app/functional-design/packages-api-handoff.md. */ diff --git a/src/features/landing/hooks/usePackagesQuery.ts b/src/features/landing/hooks/usePackagesQuery.ts index 6215648..1d32f7f 100644 --- a/src/features/landing/hooks/usePackagesQuery.ts +++ b/src/features/landing/hooks/usePackagesQuery.ts @@ -5,10 +5,10 @@ import type { PackageCardData } from '../data/content'; // (test.slpsoftware.nl / slpsoftware.nl) — see aidlc-docs/features/react-frontend/ // construction/react-frontend-app/functional-design/packages-api-handoff.md // for the API contract this endpoint must implement. -const PACKAGES_ENDPOINT = '/api/v1/packages'; +const OFFERINGS_ENDPOINT = '/api/v1/offerings'; async function fetchPackages(): Promise { - const response = await fetch(PACKAGES_ENDPOINT); + const response = await fetch(OFFERINGS_ENDPOINT); if (!response.ok) { throw new Error(`Failed to fetch packages: ${response.status} ${response.statusText}`); } -- 2.39.5