diff --git a/.env.example b/.env.example index 1c7ea11..a9473a1 100644 --- a/.env.example +++ b/.env.example @@ -1,48 +1,50 @@ -# Secrets read by docker-compose.yml via ${VAR:-} substitution. -# Copy to .env at the project root and fill in. - -# Stripe. The secret key and webhook secret go to PocketBase only (the shop -# API in pocketbase/pb_hooks); the public app gets just the publishable key. -STRIPE_SECRET_KEY=sk_test_... -PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_... -STRIPE_WEBHOOK_SECRET=whsec_... -STRIPE_CURRENCY=eur - -# Shared by PocketBase and the public app so the public app can record -# booking-email status on orders (its only write). Generate a long random -# value, e.g.: openssl rand -hex 32 -INTERNAL_API_SECRET= - -# Booking emails via Brevo's SMTP relay (Brevo → SMTP & API → SMTP). -# Leave SMTP_HOST empty in development: emails are then written to the -# app logs instead of being sent. -# Brevo: smtp-relay.brevo.com -SMTP_HOST= -# 587 (STARTTLS); use 2525 if your network blocks 587, or 465 for implicit TLS -SMTP_PORT=587 -# The SMTP login Brevo shows (xxxx@smtp-brevo.com), NOT your account email -SMTP_USER= -# The SMTP key generated in Brevo (not your account password) -SMTP_PASS= -# Must be a sender on a domain authenticated in Brevo -EMAIL_FROM=bookings@example.com -EMAIL_FROM_NAME=Eva Shafik -# Timezone used for booking times in emails (IANA name) -SITE_TIMEZONE=Europe/Oslo - -# Public URLs the browser uses: ://admin.. -# They must match the address bar exactly (SvelteKit's form CSRF check). -# Local default: http + :8080. Behind a reverse proxy / TLS on 443: -# URL_SCHEME=https -# URL_PORT=:443 -# (:443 is the https default, so URLs come out without a port. An empty -# value works too; a MISSING URL_PORT means :8080.) -DOMAIN=localhost -URL_SCHEME=http -URL_PORT=:8080 - -# Caddy scheme for the reverse proxy on port 8080. -# http (default) — plain HTTP; matches the ORIGIN vars in docker-compose.yml -# https — HTTPS on :8080 (self-signed unless you add a cert issuer; -# also update ORIGIN/PUBLIC_* URLs to https://...) -CADDY_SCHEME=http +# Secrets read by docker-compose.yml via ${VAR:-} substitution. +# Copy to .env at the project root and fill in. + +# Stripe. The secret key and webhook secret go to PocketBase only (the shop +# API in pocketbase/pb_hooks); the public app gets just the publishable key. +STRIPE_SECRET_KEY=sk_test_... +PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_... +STRIPE_WEBHOOK_SECRET=whsec_... +# Shop currency (ISO 4217, e.g. eur, nok): what Stripe charges in and what +# every price on the site, in the admin and in booking emails is shown in. +# Item prices are entered in this currency. +STRIPE_CURRENCY=eur + +# Shared by PocketBase and the public app so the public app can record +# booking-email status on orders (its only write). Generate a long random +# value, e.g.: openssl rand -hex 32 +INTERNAL_API_SECRET= + +# Booking emails via Brevo's SMTP relay (Brevo → SMTP & API → SMTP). +# Leave SMTP_HOST empty in development: emails are then written to the +# app logs instead of being sent. +# Brevo: smtp-relay.brevo.com +SMTP_HOST= +# 587 (STARTTLS); use 2525 if your network blocks 587, or 465 for implicit TLS +SMTP_PORT=587 +# The SMTP login Brevo shows (xxxx@smtp-brevo.com), NOT your account email +SMTP_USER= +# The SMTP key generated in Brevo (not your account password) +SMTP_PASS= +# Must be a sender on a domain authenticated in Brevo +EMAIL_FROM=bookings@example.com +EMAIL_FROM_NAME=Eva Shafik +# Timezone used for booking times in emails (IANA name) +SITE_TIMEZONE=Europe/Oslo + +# Public URLs the browser uses: ://admin.. +# They must match the address bar exactly (SvelteKit's form CSRF check). +# Local default: http + :8080. Behind a reverse proxy / TLS on 443, e.g.: +# URL_SCHEME=https +# URL_PORT= +# (empty URL_PORT = no port in the URL; leave the line out to get :8080) +DOMAIN=localhost +URL_SCHEME=http +URL_PORT=:8080 + +# Caddy scheme for the reverse proxy on port 8080. +# http (default) — plain HTTP; matches the ORIGIN vars in docker-compose.yml +# https — HTTPS on :8080 (self-signed unless you add a cert issuer; +# also update ORIGIN/PUBLIC_* URLs to https://...) +CADDY_SCHEME=http diff --git a/AGENTS.md b/AGENTS.md index e2168fd..e14c23f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -3,7 +3,7 @@ ## Stack - **SvelteKit 2** (SSR, Svelte 5 runes mode) — all `.svelte` files use `$state`, `$derived`, `$props()` etc. -- **PocketBase** — server pinned to **0.23.12** (`docker-compose.yml`), REST API via the `pocketbase` SDK (v0.26). Auth, DB, and image storage. Bump the server version deliberately (changelog, backup, test migrations). +- **PocketBase** — server pinned to **0.40.6** (`docker-compose.yml`, image `elestio/pocketbase`, digest-pinned; runs as non-root uid 100 on port 8090), REST API via the `pocketbase` SDK (v0.28). Auth, DB, and image storage. Bump the server version deliberately (changelog, backup, test migrations). - **Tailwind CSS v4** + **DaisyUI 5** — utility-first CSS with DaisyUI components for admin; custom theme for the public site. - **Docker Compose** — four services: `app-admin`, `app-public`, `pocketbase`, and `caddy` (reverse proxy). @@ -14,7 +14,7 @@ packages/shared/src/ # Shared code (types, calendar utils, blocks, pb, app-admin/ # SvelteKit admin app (serves admin.) ├── src/ │ ├── lib/ -│ │ ├── admin/ # Admin UI components (BlockList, Modal, editors, confirm/unsaved helpers) +│ │ ├── admin/ # Admin UI components (BlockList, Modal, editors, confirm/unsaved helpers, slots/ bulk modals) │ │ ├── blocks/ # Re-exports from $shared/blocks (block renderers live in shared) │ │ ├── pb.ts # Re-exports from $shared/pb + app-specific uploadMedia │ │ ├── types.ts # Re-exports from $shared @@ -22,20 +22,23 @@ app-admin/ # SvelteKit admin app (serves admin.) │ │ ├── scrollReveal.ts # Re-exports from $shared │ │ ├── stripe-client.ts # Re-exports from $shared │ │ ├── basket.svelte.ts # Re-exports from $shared -│ │ └── server/ # Re-exports from $shared/server + admin helpers (actions.ts, pages.ts) +│ │ └── server/ # Re-exports from $shared/server + admin helpers (actions.ts, pages.ts, slots.ts) │ ├── routes/ │ │ ├── +layout.svelte # Root layout (admin shell: grouped sidebar; bare on /login and /preview) +│ │ ├── +page.svelte # Dashboard (income + chart, hours, utilisation, customers, codes owed, what sells, needs attention); figures from $lib/server/dashboard.ts. Login lands here │ │ ├── login/ # Admin login │ │ ├── pages/ # Page CRUD + block editor │ │ ├── calendar/ # Event CRUD (menu label: Events) │ │ ├── items/ # Service/product CRUD (menu label: Services & products) -│ │ ├── slots/ # Bookable time slot CRUD +│ │ ├── passes/ # Vouchers & codes: search, void/extend, issue (menu label: Vouchers & codes) +│ │ ├── slots/ # Time windows + group sessions: month calendar (?month=YYYY-MM), CRUD, bulk generate/copy/clear │ │ ├── orders/ # Order list + booking-email status/resend +│ │ ├── customers/ # Customer personal data (GDPR): search, export, correct, erase, retention settings │ │ ├── emails/ # Block-based booking email editor (live preview, test send) -│ │ ├── globals/ # Header/footer/colors editor (menu label: Site design) +│ │ ├── globals/ # Header/footer/colors/style editor (menu label: Site design) │ │ ├── backup/ # Export/import UI (calls api/export, api/import) │ │ ├── preview/ # Draft preview via sessionStorage (same-origin) -│ │ └── api/ # upload, export, import endpoints +│ │ └── api/ # upload, export, import, slots (Shop block times in /preview) endpoints │ ├── hooks.server.ts # Auth guard — all routes except /login │ └── app.css # Tailwind + DaisyUI + custom theme ├── static/ # Static assets @@ -59,7 +62,7 @@ app-public/ # SvelteKit public app (serves *.) │ │ ├── +layout.svelte # Root layout (always renders Header/Footer) │ │ ├── +page.svelte # Home page (slug=home) │ │ ├── [slug]/ # Dynamic CMS pages -│ │ ├── api/ # basket, checkout, webhooks endpoints +│ │ ├── api/ # basket, checkout, webhooks, slots (Shop block times) endpoints │ │ └── checkout/return/ # Stripe return URL │ ├── hooks.server.ts # Creates PB client in locals (no auth guard) │ └── app.css # Tailwind + DaisyUI + custom theme @@ -79,7 +82,7 @@ Caddyfile # Subdomain-based routing Caddy routes by `Host` header — no path stripping: - `admin.{$DOMAIN}:8080` → `app-admin:3001` (admin app) -- `db.{$DOMAIN}:8080` → `pocketbase:80` (redirects `/` to `/_/`) +- `db.{$DOMAIN}:8080` → `pocketbase:8090` (redirects `/` to `/_/`) - `www.{$DOMAIN}:8080`, `*.{$DOMAIN}:8080` → `app-public:3000` (public app) For local dev, `DOMAIN` defaults to `localhost`, so Caddy serves `admin.localhost:8080`, `db.localhost:8080`, `www.localhost:8080`. Caddy's `.localhost` handling works without DNS or hosts-file changes. @@ -97,12 +100,14 @@ All components use Svelte 5 runes syntax — **never** `export let`, `$:`, or `o ### Block System Pages are composed of `ContentBlock[]`. Each block has `{ id, type, data }`. Block types are defined in `packages/shared/src/types.ts` (re-exported via `$lib/types` in each app): -`text | image_text | timeline | hero | button | spacer | testimonials | upcoming_calendar | shop | checkout` +`text | image_text | timeline | hero | button | spacer | testimonials | upcoming_calendar | shop | checkout | cards | faq | html` - **Renderers (shared)**: `packages/shared/src/blocks/Block.svelte` — one renderer per type, imported by both apps via `$shared/blocks/...`. The admin preview iframe uses the same shared renderers. - **Admin editors**: `app-admin/src/lib/admin/editors/BlockEditor.svelte` — switches editor UI by type - **Defaults**: `app-admin/src/lib/admin/blockDefaults.ts` — `createBlock(type)` generates a new block with sensible defaults - **Block list**: `app-admin/src/lib/admin/BlockList.svelte` — draggable reorder, select, delete +- **Settings on every block** (keys starting with `_`, edited below each block's own fields): `_background`, `_foreground` (colours) and `_anchor` (id for `#anchor` links), applied by `BackgroundWrapper.svelte`. +- **Text is edited visually**: `RichTextEditor.svelte` (Tiptap) only produces `p, h2, h3, strong, em, s, a, ul, ol, li, blockquote, br, hr` — no inline styles or layout HTML. That list is `EDITOR_TAGS` in `packages/shared/src/richText.ts`; keep it and the editor's extensions in step. A layout people keep needing becomes a block (as Cards and FAQ did), never HTML in a text block; one-offs and embeds go in an `html` block. Old text blocks holding other HTML are turned into `html` blocks (or centred text) by `upgradeLegacyBlocks()` on backup import and by migration `1793300000_text_blocks_visual_editor.js`. To add a new block type: add to `BlockType` union in `packages/shared/src/types.ts`, create renderer in `packages/shared/src/blocks/`, add editor case in `app-admin/src/lib/admin/editors/BlockEditor.svelte`, add default in `app-admin/src/lib/admin/blockDefaults.ts`, add import in `packages/shared/src/blocks/BlockRenderer.svelte`. @@ -118,34 +123,47 @@ To add an email block type: add to `EmailBlockType` in `packages/shared/src/type ### Shared Code - `packages/shared/src/types.ts` — all type definitions - `packages/shared/src/calendar.ts` — calendar utilities (used by admin calendar editor and public upcoming calendar block) +- `packages/shared/src/items.ts` — service durations (`parseDurations`, `formatDuration`, `lowestPrice`); which length costs what is charged by the shop hooks +- `packages/shared/src/slots.ts` — pure slot planning (generate/copy-week maths on date keys + wall-clock times in `SITE_TIMEZONE`, DST-safe); the `/slots` actions use it via `$lib/slots`, PocketBase I/O is in `app-admin/src/lib/server/slots.ts` - Each app's `svelte.config.js` declares `kit.alias.$shared → '../packages/shared/src'` - Each app's `src/lib/types.ts` and `src/lib/calendar.ts` re-export from `$shared` so existing `$lib/types` and `$lib/calendar` imports work ### PocketBase Integration - Client created in `hooks.server.ts` (`event.locals.pb`) — injected per-request with auth cookie - `$lib/pb.ts` exports `createPocketBase()`, `getFileUrl()`, `uploadMedia()` -- Collections: `pages` (slug, title, blocks[], published), `globals` (key, data), `media` (file, alt), `email_templates` (key, subject, blocks[], recipients, enabled) +- Collections: `pages` (slug, title, blocks[], published), `globals` (key, data), `media` (file, alt), `email_templates` (key, subject, blocks[], recipients, enabled); commerce: `items`, `slots`, `baskets`, `basket_lines`, `orders`, `order_lines`, `passes` (bundle/voucher codes) - Server load functions use `locals.pb.collection('pages').getFirstListItem()` - **Always build filters with `pb.filter('slug = {:slug}', { slug })`** — never interpolate values into filter strings (quotes break them). -- **Schema changes**: add a migration to `pocketbase/pb_migrations/` (runs once, on the next PocketBase start) **and** mirror it in `pb_schema.json` (fresh installs import that after the migrations have already run). Migrations must skip missing collections and must not throw for data problems — a failing migration stops PocketBase from starting. +- **Schema changes**: add a migration to `pocketbase/pb_migrations/` (runs once, on the next PocketBase start) **and** mirror it in `pb_schema.json` (fresh installs import that after the migrations have already run). Field settings go at the field's top level (`"maxSize": 2000000`), never under `options`: PocketBase has ignored `options` since 0.23. Migrations must skip missing collections and must not throw for data problems — a failing migration stops PocketBase from starting. - **API rules**: CMS collections require `@request.auth.id != ''`, so `users` must never allow public sign-up (its createRule is superuser-only). Commerce writes (orders, order_lines, baskets, basket_lines) are superuser-only; they happen in the PocketBase shop hooks (`pocketbase/pb_hooks/shop/lib.js`), which bypass rules. +- **Slot availability** (window start times, group-session places, blocking by overlapping bookings incl. get-ready time) is computed only by `availability()`/`windowStartTimes()`/`checkBooking()` in the shop hooks — the public listing, basket holds and the admin `/slots` page all go through it (`GET /api/shop/slots?item=&minutes=&from=&to=`, `?detail=1` for the admin). Slots are `window`s (services bookable at any of their lengths) or group `session`s; bookings carry their own `start`/`minutes` on basket/order lines. Never store booking state on a slot or re-implement the rule elsewhere; see the README's *Slot availability*. +- **Customer personal data (GDPR)** lives in `orders.customerDetails`/`email`, `passes.email`/`recipientName`/`message` and (during checkout) `baskets` / `basket_lines.giftTo`/`giftMessage`. Admin access, correction, erasure (= anonymise the order, never delete it — the accounts need it) and the retention cron are in `pocketbase/pb_hooks/privacy/`; the admin `/customers` page only calls `/api/privacy/*`. A new place that stores customer details (e.g. a Google Calendar sync) must be covered by export, erase and retention too, and listed in the privacy draft (`app-admin/src/lib/admin/privacyTemplate.ts`). Don't load third-party resources on public pages (fonts are bundled; Stripe.js loads only at Pay) — each one sends visitors' IPs elsewhere and may need consent. See the README's *Personal data (GDPR)*. +- **Bundles and codes** (`passes`): what a code has left is counted from order lines and live holds by `passCredits()` in the shop hooks — never store a counter. A line a code covers has `pass` and costs 0; a basket with nothing to pay is confirmed without Stripe. Bundle parts are JSON, not relations: the `onRecordDelete` hook on `items` (`deleteBlocker`) keeps parts that bundles or codes still need from being deleted, and a bundle with an inactive part isn't sold. PocketBase reads empty numbers back as 0 and treats 0 as blank for required fields: use a flag (like `items.trackStock`) instead of an empty number, and keep fields that can be 0 not required. See the README's *Bundles and codes*. - **Shop / payments**: all basket, slot-hold, Stripe and order logic lives in the PocketBase hooks (JSVM: synchronous, each handler `require()`s the lib; see the header comment). The public app must stay unprivileged — no superuser login, no Stripe secret key; its routes only proxy to `/api/shop/*` and manage the `basket_id` cookie (`app-public/src/lib/server/shop.ts`). Booking emails are rendered and sent by the public app from data the webhook hook returns (`OrderEmailData`, `sendOrderEmailsFromData`); keep `orderEmailData()` in the hook and `loadOrderEmailData()` in `packages/shared/src/server/email` returning the same shape. Local testing uses `stripe-mock` (`STRIPE_API_BASE`, local compose only). ### Styling -- **Public site**: Custom theme via `@theme` in `app.css` — colors: `warm`, `charcoal`, `sage`, `sage-dark`, `terracotta`. Fonts: `DM Sans` (body), `Playfair Display` (headings). +- **Public site**: Custom theme via `@theme` in `app.css` — colors: `warm`, `charcoal`, `sage`, `sage-dark`, `terracotta`. Fonts: `font-sans` (body), `font-serif` (headings), chosen in Site design → Style (default DM Sans / Playfair Display). + - **Site design → Style** (`style` global: fonts, corners, text size, shadows, page width) becomes `--site-*` variables (`siteStyleVars` in `$shared/theme`) that the `@theme` tokens in both `app.css` files scale. So in public-site markup use the tokens — `rounded-xl`/`rounded-2xl`/`rounded-card`/`rounded-panel`, `shadow-sm`…`shadow-xl`, `max-w-3xl`/`6xl`/`7xl` — never `rounded-[2rem]` or an arbitrary `shadow-[…]`, which ignore the settings. Buttons, chips and icon buttons are `rounded-button` (a pill when Round, square when Sharp); only dots, avatars and badges stay `rounded-full`. + - Keep scrolling smooth: no `backdrop-blur` on public pages (it is redrawn on every scrolled frame; use a nearly solid background), and keep animations short. The `.reveal` / `.animate-fade-in` animations are switched off for people who ask for reduced motion and, by `scrollReveal.ts`, on devices that stutter (`plain-motion` on ``, rules in both `app.css` files). + - Fonts are bundled `@fontsource-variable/*` packages, imported in each app's `src/lib/fonts.ts` and listed in `SITE_FONTS`; a new one goes in all three places. - **Admin area**: DaisyUI **5** (no `form-control` / `label-text` / `*-bordered` — those are v4). Colours come from Site design via `$shared/theme`, rendered as a ` diff --git a/packages/shared/src/blocks/CheckoutBlock.svelte b/packages/shared/src/blocks/CheckoutBlock.svelte index bd12b04..8e52dab 100644 --- a/packages/shared/src/blocks/CheckoutBlock.svelte +++ b/packages/shared/src/blocks/CheckoutBlock.svelte @@ -1,14 +1,23 @@ + +
+
+ {#if data.heading}

{data.heading}

{/if} + {#each data.items || [] as item, i (i)} +
+ + {item.question} + + + {@html item.answer || ''} +
+ {/each} +
+
diff --git a/packages/shared/src/blocks/HeroBlock.svelte b/packages/shared/src/blocks/HeroBlock.svelte index 68af2f6..dd1bdba 100644 --- a/packages/shared/src/blocks/HeroBlock.svelte +++ b/packages/shared/src/blocks/HeroBlock.svelte @@ -1,4 +1,7 @@ + + +
+
+ {@html data.html || ''} +
+
diff --git a/packages/shared/src/blocks/ImageTextBlock.svelte b/packages/shared/src/blocks/ImageTextBlock.svelte index bfd20b4..9b3d048 100644 --- a/packages/shared/src/blocks/ImageTextBlock.svelte +++ b/packages/shared/src/blocks/ImageTextBlock.svelte @@ -8,7 +8,7 @@
-
+
{#if data.url} {data.alt {:else} diff --git a/packages/shared/src/blocks/ShopBlock.svelte b/packages/shared/src/blocks/ShopBlock.svelte index e9b21c1..916f3c5 100644 --- a/packages/shared/src/blocks/ShopBlock.svelte +++ b/packages/shared/src/blocks/ShopBlock.svelte @@ -1,12 +1,14 @@
{#if data.title} -

{data.title}

+

{data.title}

+ {/if} + + {#if showSortMenu} +
+ +
{/if} {#if !visibleItems.length} @@ -141,13 +317,14 @@
{#each visibleItems as item (item.id)} {@const ui = cardStates[item.id]} - {@const itemSlotsByDay = slotsByDay.get(item.id)} {@const isService = item.type === 'item_with_time'} - {@const soldOut = !isService && item.stock === 0} + {@const duration = isService ? selectedDuration(item, ui) : null} + {@const bookable = !isService || !!duration} + {@const soldOut = item.type === 'item' && item.stock === 0} {@const itemInBasket = !isService && basket.lines.some((l) => l.item === item.id)}
{#if item.imageUrl} @@ -172,19 +349,45 @@ {#if item.description}

{item.description}

{/if} + {#if item.type === 'bundle'} + +
    + {#each item.bundleParts as part (`${part.item}|${part.minutes}`)} +
  • {part.count}× {itemNames.get(part.item) ?? 'Item'}{part.minutes ? ` (${formatDuration(part.minutes)})` : ''}
  • + {/each} +
+

+ You get a code to book the sessions whenever suits you{item.validMonths ? ` — valid ${item.validMonths} months` : ''}. It can be given as a gift. +

+ {/if} -
- {priceFormatter.format(item.price)} - {#if isService && item.duration != null} - {item.duration} min - {:else if !isService && item.stock != null && item.stock > 0 && item.stock <= 5} - - Only {item.stock} left - - {:else if soldOut} - - Sold out - +
+ {#if isService && item.durations.length > 1} + +
+ from {formatPrice(lowestPrice(item.durations) ?? item.price, currency)} + {formatDuration(item.durations[0].minutes)} – {formatDuration(item.durations[item.durations.length - 1].minutes)} +
+ {:else} + {@const listPrice = item.type === 'bundle' ? bundleListPrice(item.bundleParts, items) : null} +
+ {formatPrice(duration?.price ?? lowestPrice(item.durations) ?? item.price, currency)} + {#if listPrice != null && listPrice > item.price} + + Bought separately: {formatPrice(listPrice, currency)} + {/if} + {#if duration} + {formatDuration(duration.minutes)} + {:else if !isService && item.stock != null && item.stock > 0 && item.stock <= 5} + + Only {item.stock} left + + {:else if soldOut} + + Sold out + + {/if} +
{/if}
@@ -209,20 +412,21 @@ {#if isService} {:else} {#if itemInBasket} ✓ In basket @@ -240,9 +444,88 @@
- {#if isService && ui?.pickerOpen && itemSlotsByDay} + {#if isService && ui?.pickerOpen && duration} + {@const byDay = entriesByDay(item, ui, duration.minutes)} + {@const availableKeys = [...byDay.keys()].sort()} + {@const months = pickerMonths(ui.monthOffset)} + {@const shown = shownRange(ui.monthOffset)} + {@const anyShown = availableKeys.some((key) => key >= shown.from && key <= shown.to)}
-

Select a date

+ {#if item.durations.length > 1} + +
+ + +
+ {/if} +
+ +

+ {#if ui.loading}{/if} + Select a date · {formatDuration(duration.minutes)} +

+ +
+ + {#if ui.loadError} + + {:else if !ui.loading && !anyShown} + +
+ {#if ui.next} + The next available date for {formatDuration(duration.minutes)} is {longDate(zonedDateKey(ui.next, timezone))}. + + {:else} + No times are available for {formatDuration(duration.minutes)} in these months{item.durations.length > 1 ? ' — try another length' : ''}. + {/if} +
+ {/if} +
{#each months as month (month.label)}
@@ -252,14 +535,14 @@ {letter} {/each} {#each month.days as day (day.dateKey)} - {@const selectable = day.inMonth && itemSlotsByDay.has(day.dateKey)} + {@const selectable = day.inMonth && byDay.has(day.dateKey)} {@const selected = selectable && ui.selectedDayKey === day.dateKey}
- {#if ui.selectedDayKey} - {@const daySlots = itemSlotsByDay.get(ui.selectedDayKey) ?? []} -

Available times

+ {#if ui.selectedDayKey && byDay.has(ui.selectedDayKey)} +

+ Available times · {longDate(ui.selectedDayKey)} +

- {#each daySlots as slot (slot.id)} - {@const slotInBasket = basket.lines.some((l) => l.slot === slot.id)} - + {#each byDay.get(ui.selectedDayKey) ?? [] as entry (`${entry.slot}|${entry.start}`)} + {@const isGroup = (entry.time?.capacity ?? entry.line?.slotCapacity ?? 1) > 1} + {@const free = entry.time?.free ?? 0} + {@const pending = ui.pendingKey === `${entry.slot}|${entry.start}`} + {@const label = `${formatTime(entry.start)}–${formatTime(entry.end)}`} + {#if isGroup && entry.line} + +
+ {label} · {placesLeft(free)} + + + + {#if pending}{:else}{entry.line.quantity}{/if} + {entry.line.quantity === 1 ? 'place' : 'places'} in your basket + + + +
+ {:else} + + {/if} {/each}
- {:else} -

- Days with availability are highlighted{item.duration != null ? ` · ${item.duration} min per session` : ''}. -

+ {:else if anyShown} +

Days with availability are highlighted.

{/if} {#if ui.justAdded}

- Added ✓ — view basket + Added ✓ — view basket

{/if}
diff --git a/packages/shared/src/blocks/TestimonialsBlock.svelte b/packages/shared/src/blocks/TestimonialsBlock.svelte index b421c95..e8eedbe 100644 --- a/packages/shared/src/blocks/TestimonialsBlock.svelte +++ b/packages/shared/src/blocks/TestimonialsBlock.svelte @@ -52,7 +52,7 @@