Files
SluijsensandClaude Opus 5.5 30dab1af42 Adds the Prijzen section to the homepage
Shows the three live packages as cards with their price and what is
included. Each card links to the contact section with ?pakket=<id>, so
the contact form can preselect it. Invalid packages from the CMS are
skipped and the pakket value is only accepted when it names a package.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 01:07:36 +02:00

3.4 KiB
Raw Permalink Blame History

Business Logic Model — Unit 3: Prijzen

Booking flow (across units 3 and 5)

sequenceDiagram
    box rgba(246,224,94,0.4) Visitor
      participant V as Visitor
    end
    box rgba(99,179,237,0.4) Homepage
      participant Card as PriceCard
      participant Route as RouteIndex
      participant Form as ContactForm
    end
    V->>Card: Clicks Boek Newborn
    Card->>Route: Navigate to the homepage with pakket newborn and hash contact
    Route->>Route: packageFromSearch checks the value against the shown packages
    Route->>Form: Preselected package id newborn
    Route-->>V: Scrolls to the contact section
    Form->>Form: Selects newborn, replacing any earlier choice
    Form->>Route: Remove pakket from the URL with history replace

Text alternative: a click on a price card navigates to the homepage with the package in the URL; the route validates it and hands it to the contact form, scrolls to the contact section, and after the form has selected the package the parameter is removed from the URL.

Pure functions (web/src/lib/)

Function Input → output Rules
formatPrice(euros: number): string 185 → '€ 185' BR-PRICE-01
visiblePackages(packages: PricingPackage[]): PricingPackage[] raw list → shown list BR-PRICE-02
bookLabel(name: string): { visible: string; hidden?: string } 'Newborn' → { visible: 'Boek Newborn' }; a 15+ character name → { visible: 'Boek je shoot', hidden: ': <name>' } BR-BOOK-02
packageFromSearch(value: unknown, packages: PricingPackage[]): string | undefined 'Newborn ' → 'newborn'; 'onbekend' → undefined BR-PARAM-01

The route's validateSearch only keeps pakket when it is a string (anything else becomes undefined); packageFromSearch does the matching against the shown packages.

Testable properties (PBT-01)

Function Category Property
formatPrice Round-trip For any positive integer n, removing everything but digits from formatPrice(n) gives back n
formatPrice Invariant Output starts with € followed by a non-breaking space and contains no regular space
visiblePackages Invariant Every result meets all invariants; ids are unique
visiblePackages Invariant The result is a subsequence of the input (order kept, nothing invented)
visiblePackages Idempotency visiblePackages(visiblePackages(x)) equals visiblePackages(x)
visiblePackages Oracle A list of only valid, unique packages comes back unchanged
bookLabel Invariant The visible text plus the hidden text always contains the name; the visible text is Boek <name> exactly when the name has ≤ 14 characters, otherwise Boek je shoot
packageFromSearch Invariant The result is undefined or the id of one of the given packages
packageFromSearch Oracle For every package, its id in any letter case and with surrounding spaces returns that id
packageFromSearch Invariant Non-string input always gives undefined
packageFromSearch Idempotency Feeding the result back in gives the same result

Generators (PBT-07) are added to src/test/arbitraries.ts: a valid pricingPackage (slug ids, Dutch-like names, 1–5 features, prices 1–5000), a list with unique ids, and an anyPackage mix that includes invalid ones (empty name, price 0 / negative / fractional / NaN, bad id, duplicates).