Shop: duration slider on services, times fetched per service and length

Service cards step through their lengths with a slider and the price
follows. The time picker loads bookable times for the chosen length and
the months on screen from GET /api/slots (a proxy to the shop hook in each
app), and reloads when the basket's bookings change. Checkout, emails and
the basket show each booking's own length.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hy2vMnHJYP7QGsiH21zHxW
This commit is contained in:
agent 2026-10-25 20:12:46 +00:00
parent 23df2ceced
commit eac99b2abe
18 changed files with 479 additions and 210 deletions

View file

@ -6,6 +6,7 @@
import { DEFAULT_NOTES_HINT, DEFAULT_PRIVACY_NOTICE, type BasketLine, type CheckoutBlockData } from '$shared/types';
import { getBasketContext } from '$shared/basket.svelte';
import { DEFAULT_CURRENCY, DEFAULT_TIMEZONE, formatInstant, formatPrice } from '$shared/calendar';
import { formatDuration } from '$shared/items';
import { loadStripe } from '$shared/stripe-client';
import type { Stripe, StripeElements, StripePaymentElement } from '@stripe/stripe-js';
@ -90,7 +91,7 @@
}
function describeLine(line: BasketLine) {
return [line.itemName ?? 'A time slot', line.slotStart ? formatSlotTime(line.slotStart) : ''].filter(Boolean).join(', ');
return [line.itemName ?? 'A time slot', line.start ? formatSlotTime(line.start) : ''].filter(Boolean).join(', ');
}
// At zero, reload the basket: the server drops the lapsed line. Retry every
@ -345,10 +346,14 @@
<div class="min-w-0 flex-1">
<p class="truncate font-medium">{line.itemName ?? 'Item'}</p>
{#if line.lineType === 'slot' && line.slotStart}
<p class="text-sm text-fg-body/70">{formatSlotTime(line.slotStart)}</p>
{#if line.lineType === 'slot' && line.start}
<p class="text-sm text-fg-body/70">{formatSlotTime(line.start)}{line.minutes ? ` · ${formatDuration(line.minutes)}` : ''}</p>
{/if}
{#if line.itemPrice == null}
<p class="text-sm text-terracotta">No longer offered at this length — please remove it and pick again.</p>
{:else}
<p class="text-sm text-fg-body/70">{formatPrice(line.itemPrice, currency)}</p>
{/if}
<p class="text-sm text-fg-body/70">{formatPrice(line.itemPrice ?? 0, currency)}</p>
</div>
<!-- Products, and places in a group session (capacity > 1); the server checks what's left. -->