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:
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"packages": [
|
||||
{
|
||||
"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"
|
||||
]
|
||||
}
|
||||
],
|
||||
"banner": null
|
||||
}
|
||||
+27
-35
@@ -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;
|
||||
|
||||
@@ -94,6 +94,23 @@ export interface PricingPackage {
|
||||
name: string;
|
||||
price: number; // whole euros
|
||||
features: string[];
|
||||
// From the CMS offering; all optional
|
||||
priceNote?: string;
|
||||
description?: string;
|
||||
ctaLabel?: string;
|
||||
featured?: boolean;
|
||||
}
|
||||
|
||||
// The one optional banner under the price cards (an offering with
|
||||
// layout=banner in the CMS). It is not a bookable package: it is not in the
|
||||
// form's choices and not in the package count. The price is free text.
|
||||
export interface PricingBanner {
|
||||
title: string;
|
||||
description: string;
|
||||
priceText: string;
|
||||
priceNote?: string;
|
||||
features: string[];
|
||||
ctaLabel?: string;
|
||||
}
|
||||
|
||||
// The kinds of shoot Andrea offers. The ids are stable: they go into URLs
|
||||
|
||||
Reference in New Issue
Block a user