Files
SlpSoftware/aidlc-docs/features/redesign-modern-timetravel/construction/packages-block/functional-design/business-logic-model.md
T
SluijsensandClaude Sonnet 5.5 9661b64635 Pakketblok: elk aantal pakketten, filterchips, swipe-rij op mobiel en optionele banner
Pure logica (splitsen, chips, filter, labels), useSwipeRow en usePackageFilter,
ContactPreselect voor het formulier, kaarten in stijl B en tests.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-10 10:34:09 +01:00

2.2 KiB

Business Logic Model — packages-block (U3)

Data flow

sequenceDiagram
    box rgba(99,179,237,0.4) Browser
      participant V as Visitor
      participant PS as PackagesSection
      participant HK as usePackageFilter
    end
    box rgba(154,230,180,0.4) CMS API
      participant A as offerings
    end
    PS->>A: GET offerings
    A-->>PS: package array
    PS->>HK: split and derive chips
    HK-->>PS: cards, chips, banner
    V->>PS: choose a chip
    PS->>HK: set active chip
    HK-->>PS: filtered cards
    V->>PS: click Kies button
    PS->>PS: set preselect and scroll to contact

Text alternative: the section loads the offerings, the filter hook splits cards and banner and derives chips, a chip choice filters the cards, and a Kies button sets the contact preselect and scrolls.

Pure functions (unit-testable, src/shared/packages/)

  • splitPackages(packages, bannerSlugs) -> { cards, banners }
  • deriveChips(cards, threshold) -> Chip[] | null (null = no chips)
  • filterCards(cards, activeId) -> PackageCardData[]
  • resultLabel(count, hasBanner) -> string ("1 pakket ...", "3 pakketten ...")
  • initialIndex(visible) -> number (index of the featured card, else 0)
  • activeIndexFromScroll(scrollLeft, itemWidths|itemOffsets, viewportWidth) -> number (nearest snap position)

Hooks

  • usePackageFilter(packages, settings): state activeId; returns { cards, banners, chips, activeId, setActive, visible, label }; resets activeId to all when the chosen category disappears.
  • useSwipeRow(itemCount, initialIndex): returns { ref, activeIndex, scrollToIndex }; on mount and when itemCount/filter key changes scrolls to initialIndex (instant); listens to scroll (throttled by requestAnimationFrame) to update activeIndex; uses scrollTo({behavior}) with smooth unless reduced motion.
  • useContactPreselect (context from U3, consumed by U4): { subject, key, select(subject) }.

Error handling

  • API error: error state with retry (refetch); loading: skeletons; empty list: info text.
  • Unknown/absent category: package only under "Alles".
  • bannerSlugs containing an unknown slug: fallback banner from settings.
  • No ResizeObserver/IntersectionObserver required (scroll event + offsets); jsdom-safe.