Reads the shoot packages and an optional banner from the CMS at build time

The build asks GET /api/v1/offerings and bakes the packages into the pages,
with a committed snapshot as fallback so a CMS outage never breaks the build
or shows an empty price. The form choices and ?pakket= use the same list. An
offering with layout=banner becomes an optional band under the price cards.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-12 08:13:01 +01:00
co-authored by Claude Sonnet 5.5
parent 7737104a77
commit 5bfbde1881
16 changed files with 626 additions and 40 deletions
+27 -35
View File
@@ -1,38 +1,30 @@
import type { PricingPackage } from './types';
import type { PricingBanner, PricingPackage } from './types';
import snapshot from './offerings.snapshot.json';
// The shoot packages until the CMS API exists (live site, October 2026), in
// display order. Andrea uses the small business scheme (KOR): no VAT.
const packages: PricingPackage[] = [
{
id: 'zwangerschap',
name: 'Zwangerschap',
price: 175,
features: [
'1 uur fotografie',
"Minstens 30 zorgvuldig nabewerkte foto's",
'Persoonlijke online fotogalerij',
],
},
{
id: 'newborn',
name: 'Newborn',
price: 185,
features: [
'1-2 uur fotografie',
"Minstens 40 zorgvuldig nabewerkte foto's",
'Persoonlijke online fotogalerij',
],
},
{
id: 'gezin',
name: 'Gezin',
price: 175,
features: [
'1 uur fotografie',
"Minstens 30 zorgvuldig nabewerkte foto's",
'Persoonlijke online fotogalerij',
],
},
];
interface Offerings {
packages: PricingPackage[];
banner: PricingBanner | null;
}
// The shoot packages and the optional banner. config/fetchOfferings.ts writes
// offerings.generated.json before every build with what the CMS says; without
// it (tests, a build without CMS address, a CMS that is down) the committed
// snapshot is used. Andrea uses the small business scheme (KOR): no VAT.
// Tests always use the snapshot, so they do not depend on a build.
const generated =
import.meta.env.MODE === 'test'
? {}
: import.meta.glob<Offerings>('./offerings.generated.json', {
eager: true,
import: 'default',
});
const offerings: Offerings =
generated['./offerings.generated.json'] ?? (snapshot as Offerings);
// In display order
const packages: PricingPackage[] = offerings.packages;
export const banner: PricingBanner | null = offerings.banner;
export default packages;