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

@ -1,14 +1,14 @@
<script lang="ts">
import { page } from '$app/state';
import type { BasketLine, ShopBlockData, ItemRecord, SlotRecord } from '$shared/types';
import type { BasketLine, BookableTime, ShopBlockData, ItemRecord } from '$shared/types';
import { getBasketContext } from '$shared/basket.svelte';
import { DEFAULT_CURRENCY, DEFAULT_TIMEZONE, addMonths, createCalendarMonth, formatInstant, formatPrice, startOfMonth, zonedDateKey } from '$shared/calendar';
import { formatDateKey } from '$shared/slots';
import { DEFAULT_CURRENCY, DEFAULT_TIMEZONE, addMonths, createCalendarMonth, formatInstant, formatPrice, startOfMonth, zonedDateKey, zonedInputToIso } from '$shared/calendar';
import { formatDuration, lowestPrice } from '$shared/items';
import { addDaysToKey, formatDateKey } from '$shared/slots';
let { data = {}, items = [], slots = [] } = $props<{
let { data = {}, items = [] } = $props<{
data: ShopBlockData;
items?: ItemRecord[];
slots?: SlotRecord[];
}>();
const basket = getBasketContext();
@ -16,20 +16,33 @@
// Per-card interaction state. Instances are created per component instance
// (never shared at module level); keyed by item id so each card is independent.
class CardState {
/** Index into the service's durations (the slider). */
durationIndex = $state(0);
pickerOpen = $state(false);
selectedDayKey = $state<string | null>(null);
adding = $state(false);
errorMsg = $state<string | null>(null);
justAdded = $state(false);
pendingSlotId = $state<string | null>(null);
/** `slot|start` of the time being added or changed. */
pendingKey = $state<string | null>(null);
/** Months from the current one to the first month shown in the picker. */
monthOffset = $state(0);
// Bookable times for the selected duration in the months shown (GET /api/slots).
times = $state<BookableTime[]>([]);
next = $state<string | null>(null);
loading = $state(false);
loadError = $state<string | null>(null);
/** What `times` was loaded for; a reload starts when this differs. */
loadedKey = $state('');
requestId = 0;
}
let cardStates = $state<Record<string, CardState>>({});
/** The picker shows this many months side by side; the arrows move one month. */
const MONTHS_SHOWN = 2;
/** How far ahead the picker goes (the shop hook lists up to a year). */
const MAX_MONTH_OFFSET = 12;
const weekdayLetters = ['M', 'T', 'W', 'T', 'F', 'S', 'S'];
const timezone = $derived<string>(page.data.timezone ?? DEFAULT_TIMEZONE);
const currency = $derived<string>(page.data.currency ?? DEFAULT_CURRENCY);
@ -48,42 +61,16 @@
return result;
});
// The listing leaves out full slots — including ones whose last places are
// in this visitor's own basket. Add those back (no places left) so the
// visitor still sees their times and can change or drop their places.
let shownSlots = $derived.by<SlotRecord[]>(() => {
const listed = new Set(slots.map((s: SlotRecord) => s.id));
const own = basket.lines
.filter((l) => l.lineType === 'slot' && l.slot && !listed.has(l.slot) && l.slotStart && Date.parse(l.slotStart) > Date.now())
.map((l) => ({ id: l.slot!, item: l.item, start: l.slotStart!, end: l.slotEnd ?? l.slotStart!, capacity: l.slotCapacity ?? 1, free: 0 }));
return own.length ? [...slots, ...own] : slots;
});
// item id -> day key ('YYYY-MM-DD', in the studio's timezone) -> slots on that day, sorted by start time
let slotsByDay = $derived.by<Map<string, Map<string, SlotRecord[]>>>(() => {
const map = new Map<string, Map<string, SlotRecord[]>>();
for (const slot of shownSlots) {
const key = zonedDateKey(slot.start, timezone);
if (!key) continue;
let itemMap = map.get(slot.item);
if (!itemMap) {
itemMap = new Map();
map.set(slot.item, itemMap);
}
const list = itemMap.get(key);
if (list) list.push(slot);
else itemMap.set(key, [slot]);
}
for (const itemMap of map.values()) {
for (const list of itemMap.values()) {
list.sort((a, b) => new Date(a.start).getTime() - new Date(b.start).getTime());
}
}
return map;
});
let isList = $derived(data.layout === 'list');
/** Changes whenever the basket's bookings do, so open pickers reload (a booking blocks other times). */
let basketBookingsKey = $derived(
basket.lines
.filter((l) => l.lineType === 'slot')
.map((l) => `${l.id}:${l.quantity}`)
.join(',')
);
/** `2027-01-15` → months from the current month (browser's calendar) to January 2027. */
function monthOffsetOf(key: string) {
const today = new Date();
@ -96,6 +83,19 @@
return Array.from({ length: MONTHS_SHOWN }, (_, i) => createCalendarMonth(addMonths(first, i), new Date(), 1));
}
/** First and last date key of the months shown at `offset`. */
function shownRange(offset: number) {
const months = pickerMonths(offset);
return {
from: months[0].days.find((d) => d.inMonth)!.dateKey,
to: months[months.length - 1].days.findLast((d) => d.inMonth)!.dateKey
};
}
function selectedDuration(item: ItemRecord, state: CardState | undefined) {
return item.durations[Math.min(state?.durationIndex ?? 0, item.durations.length - 1)] ?? null;
}
// Lazily create card state for whatever items are rendered.
$effect(() => {
for (const item of visibleItems) {
@ -103,6 +103,78 @@
}
});
// Load the bookable times for every open picker: again when the duration,
// the months shown or the basket's bookings change.
$effect(() => {
for (const item of visibleItems) {
const state = cardStates[item.id];
const duration = selectedDuration(item, state);
if (!state?.pickerOpen || !duration) continue;
const range = shownRange(state.monthOffset);
const key = [item.id, duration.minutes, range.from, range.to, timezone, basketBookingsKey].join('|');
if (key !== state.loadedKey) void loadTimes(state, item.id, duration.minutes, range, key);
}
});
async function loadTimes(state: CardState, itemId: string, minutes: number, range: { from: string; to: string }, key: string) {
const requestId = ++state.requestId;
state.loadedKey = key;
state.loading = true;
state.loadError = null;
const params = new URLSearchParams({
item: itemId,
minutes: String(minutes),
from: zonedInputToIso(`${range.from}T00:00`, timezone),
to: zonedInputToIso(`${addDaysToKey(range.to, 1)}T00:00`, timezone)
});
try {
const res = await fetch(`/api/slots?${params}`);
const body = await res.json().catch(() => ({}));
if (requestId !== state.requestId) return; // a newer request is under way
if (!res.ok) throw new Error(body?.message || 'Could not load the available times.');
state.times = body.times ?? [];
state.next = body.next ?? null;
} catch (e) {
if (requestId !== state.requestId) return;
state.times = [];
state.next = null;
state.loadError = errorMessage(e, 'Could not load the available times.');
state.loadedKey = ''; // try again on the next change
} finally {
if (requestId === state.requestId) state.loading = false;
}
}
type DayEntry = { time: BookableTime | null; line: BasketLine | null; start: string; end: string; slot: string };
/**
* Day key → what to show that day: the bookable times, plus this
* visitor's own bookings of this service and length (a time they hold
* is no longer listed as bookable, but they should still see it).
*/
function entriesByDay(item: ItemRecord, state: CardState, minutes: number) {
const own = basket.lines.filter(
(l) => l.lineType === 'slot' && l.item === item.id && l.minutes === minutes && l.start && Date.parse(l.start) > Date.now()
);
const entries: DayEntry[] = state.times.map((time) => ({
time,
line: own.find((l) => l.slot === time.slot && l.start && Date.parse(l.start) === Date.parse(time.start)) ?? null,
start: time.start,
end: time.end,
slot: time.slot
}));
for (const line of own) {
if (entries.some((e) => e.line === line)) continue;
entries.push({ time: null, line, start: line.start!, end: line.end ?? line.start!, slot: line.slot ?? '' });
}
const byDay = new Map<string, DayEntry[]>();
for (const entry of entries.sort((a, b) => Date.parse(a.start) - Date.parse(b.start))) {
const key = zonedDateKey(entry.start, timezone);
if (key) byDay.set(key, [...(byDay.get(key) ?? []), entry]);
}
return byDay;
}
function togglePicker(itemId: string) {
const state = cardStates[itemId];
if (!state) return;
@ -113,11 +185,21 @@
state.monthOffset = 0;
}
/** Show the month of the first available day and select it. */
function showFirstAvailable(itemId: string, key: string) {
function selectDuration(itemId: string, index: number) {
const state = cardStates[itemId];
if (!state) return;
state.monthOffset = Math.max(0, monthOffsetOf(key));
if (!state || state.durationIndex === index) return;
state.durationIndex = index;
state.selectedDayKey = null;
state.justAdded = false;
state.errorMsg = null;
}
/** Show the month of `iso`'s day and select that day. */
function showDay(itemId: string, iso: string) {
const state = cardStates[itemId];
const key = zonedDateKey(iso, timezone);
if (!state || !key) return;
state.monthOffset = Math.min(MAX_MONTH_OFFSET, Math.max(0, monthOffsetOf(key)));
state.selectedDayKey = key;
}
@ -139,31 +221,32 @@
}
}
async function addSlot(itemId: string, slotId: string) {
const state = cardStates[itemId];
async function addTime(item: ItemRecord, minutes: number, time: BookableTime) {
const state = cardStates[item.id];
if (!state || state.adding) return;
state.adding = true;
state.pendingSlotId = slotId;
state.pendingKey = `${time.slot}|${time.start}`;
state.errorMsg = null;
try {
// The store reloads the listing afterwards: a booking can block other
// times (one practitioner) or fill a group session.
await basket.addSlotLine(slotId);
// The picker reloads afterwards (basketBookingsKey changes): this
// booking takes its time, plus get-ready time, out of the day.
await basket.addSlotLine(time.slot, time.kind === 'window' ? { itemId: item.id, minutes, start: time.start } : null);
state.justAdded = true;
} catch (e) {
state.errorMsg = errorMessage(e, 'Could not book this time slot.');
state.errorMsg = errorMessage(e, 'Could not book this time.');
} finally {
state.adding = false;
state.pendingSlotId = null;
state.pendingKey = null;
}
}
/** One place more or fewer in a group session already in the basket (0 removes it). */
async function changeSeats(itemId: string, line: BasketLine, delta: number) {
async function changeSeats(itemId: string, entry: DayEntry, delta: number) {
const state = cardStates[itemId];
if (!state || state.adding) return;
const line = entry.line;
if (!state || !line || state.adding) return;
state.adding = true;
state.pendingSlotId = line.slot;
state.pendingKey = `${entry.slot}|${entry.start}`;
state.errorMsg = null;
try {
const seats = line.quantity + delta;
@ -173,7 +256,7 @@
state.errorMsg = errorMessage(e, 'Could not change the number of places.');
} finally {
state.adding = false;
state.pendingSlotId = null;
state.pendingKey = null;
}
}
@ -184,6 +267,8 @@
function placesLeft(free: number) {
return free > 0 ? `${free} ${free === 1 ? 'place' : 'places'} left` : 'no places left';
}
const longDate = (key: string) => formatDateKey(key, { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' });
</script>
<section class="mx-auto max-w-6xl px-6 py-16">
@ -202,13 +287,14 @@
<div class={isList ? 'flex flex-col gap-8' : 'grid gap-8 sm:grid-cols-2 lg:grid-cols-3'}>
{#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 duration = isService ? selectedDuration(item, ui) : null}
{@const bookable = !isService || !!duration}
{@const soldOut = !isService && item.stock === 0}
{@const itemInBasket = !isService && basket.lines.some((l) => l.item === item.id)}
<article
class={isList
? 'rounded-2xl border border-charcoal/10 bg-white p-5 shadow-sm sm:flex sm:gap-6'
? 'rounded-2xl border border-charcoal/10 bg-white p-5 shadow-sm sm:flex sm:flex-wrap sm:gap-6'
: 'flex flex-col overflow-hidden rounded-2xl border border-charcoal/10 bg-white shadow-sm'}
>
{#if item.imageUrl}
@ -234,18 +320,48 @@
<p class="mt-1 line-clamp-3 text-sm text-charcoal/70">{item.description}</p>
{/if}
<div class="mt-auto flex flex-wrap items-center gap-x-3 gap-y-1 pt-3">
<span class="text-lg font-semibold text-sage-dark">{formatPrice(item.price, currency)}</span>
{#if isService && item.duration != null}
<span class="text-xs text-charcoal/60">{item.duration} min</span>
{:else if !isService && item.stock != null && item.stock > 0 && item.stock <= 5}
<span class="rounded-full bg-terracotta/15 px-2.5 py-0.5 text-xs font-medium text-terracotta">
Only {item.stock} left
</span>
{:else if soldOut}
<span class="rounded-full bg-terracotta/15 px-2.5 py-0.5 text-xs font-medium text-terracotta">
Sold out
</span>
<div class="mt-auto pt-3">
{#if isService && item.durations.length > 1 && ui}
<!-- Several lengths: a slider steps through them and the price follows. -->
<label class="block">
<span class="flex items-baseline justify-between gap-3">
<span class="text-sm font-medium text-charcoal">{formatDuration(duration!.minutes)}</span>
<span class="text-lg font-semibold text-sage-dark">{formatPrice(duration!.price, currency)}</span>
</span>
<input
type="range"
class="mt-2 w-full cursor-pointer accent-sage"
min="0"
max={item.durations.length - 1}
step="1"
value={ui.durationIndex}
aria-label="Length of {item.name}"
aria-valuetext="{formatDuration(duration!.minutes)}, {formatPrice(duration!.price, currency)}"
oninput={(e) => selectDuration(item.id, Number(e.currentTarget.value))}
/>
</label>
<div class="mt-1 flex justify-between text-xs text-charcoal/50" aria-hidden="true">
{#each item.durations as option, i (option.minutes)}
<button type="button" tabindex="-1" class="hover:text-charcoal {i === ui.durationIndex ? 'font-semibold text-charcoal' : ''}" onclick={() => selectDuration(item.id, i)}>
{formatDuration(option.minutes)}
</button>
{/each}
</div>
{:else}
<div class="flex flex-wrap items-center gap-x-3 gap-y-1">
<span class="text-lg font-semibold text-sage-dark">{formatPrice(duration?.price ?? lowestPrice(item.durations) ?? item.price, currency)}</span>
{#if duration}
<span class="text-xs text-charcoal/60">{formatDuration(duration.minutes)}</span>
{:else if !isService && item.stock != null && item.stock > 0 && item.stock <= 5}
<span class="rounded-full bg-terracotta/15 px-2.5 py-0.5 text-xs font-medium text-terracotta">
Only {item.stock} left
</span>
{:else if soldOut}
<span class="rounded-full bg-terracotta/15 px-2.5 py-0.5 text-xs font-medium text-terracotta">
Sold out
</span>
{/if}
</div>
{/if}
</div>
@ -272,13 +388,14 @@
type="button"
class="inline-flex items-center justify-center gap-2 rounded-full px-6 py-2.5 text-sm font-medium transition {ui?.pickerOpen
? 'border border-charcoal/15 text-charcoal hover:bg-charcoal/5'
: itemSlotsByDay?.size
: bookable
? 'bg-sage text-primary-content hover:bg-sage-dark'
: 'cursor-not-allowed bg-charcoal/10 text-charcoal/50'}"
disabled={!itemSlotsByDay?.size && !ui?.pickerOpen}
disabled={!bookable && !ui?.pickerOpen}
aria-expanded={!!ui?.pickerOpen}
onclick={() => togglePicker(item.id)}
>
{itemSlotsByDay?.size ? (ui?.pickerOpen ? 'Close' : 'Book') : 'No availability'}
{bookable ? (ui?.pickerOpen ? 'Close' : 'Book') : 'No availability'}
</button>
{:else}
<button
@ -301,13 +418,12 @@
</div>
</div>
{#if isService && ui?.pickerOpen && itemSlotsByDay}
{@const availableKeys = [...itemSlotsByDay.keys()].sort()}
{#if isService && ui?.pickerOpen && duration}
{@const byDay = entriesByDay(item, ui, duration.minutes)}
{@const availableKeys = [...byDay.keys()].sort()}
{@const months = pickerMonths(ui.monthOffset)}
{@const shownFrom = months[0].days.find((d) => d.inMonth)!.dateKey}
{@const shownTo = months[months.length - 1].days.findLast((d) => d.inMonth)!.dateKey}
{@const anyShown = availableKeys.some((key) => key >= shownFrom && key <= shownTo)}
{@const lastOffset = monthOffsetOf(availableKeys[availableKeys.length - 1]) - (MONTHS_SHOWN - 1)}
{@const shown = shownRange(ui.monthOffset)}
{@const anyShown = availableKeys.some((key) => key >= shown.from && key <= shown.to)}
<div class={isList ? 'mt-5 border-t border-charcoal/10 pt-5 sm:basis-full' : 'border-t border-charcoal/10 bg-warm p-4'}>
<div class="mb-3 flex items-center justify-between gap-2">
<button
@ -319,33 +435,39 @@
>
‹
</button>
<p class="text-sm font-medium text-charcoal/70">Select a date</p>
<p class="flex items-center gap-2 text-sm font-medium text-charcoal/70">
{#if ui.loading}<span class="loading loading-spinner loading-xs" aria-label="Loading times"></span>{/if}
Select a date · {formatDuration(duration.minutes)}
</p>
<button
type="button"
class="flex h-8 w-8 items-center justify-center rounded-full border border-charcoal/15 text-lg leading-none text-charcoal transition hover:bg-charcoal/5 disabled:cursor-default disabled:opacity-30"
aria-label="Next month"
disabled={ui.monthOffset >= lastOffset}
disabled={ui.monthOffset >= MAX_MONTH_OFFSET}
onclick={() => ui.monthOffset++}
>
›
</button>
</div>
{#if !anyShown && availableKeys.length}
{#if ui.loadError}
<p class="mb-4 rounded-xl border border-terracotta/30 bg-terracotta/10 px-4 py-3 text-sm text-charcoal" role="alert">{ui.loadError}</p>
{:else if !ui.loading && !anyShown}
<!-- Nothing in the months on screen: say when the next date is, so
nobody books January thinking it is this month. -->
<div class="mb-4 flex flex-wrap items-center justify-between gap-2 rounded-xl border border-sage/30 bg-sage/10 px-4 py-3 text-sm text-charcoal">
<span>
{availableKeys[0] > shownTo ? 'The first available date is' : 'The next available date is'}
<strong>{formatDateKey(availableKeys.find((key) => key > shownTo) ?? availableKeys[0], { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' })}</strong>.
</span>
<button
type="button"
class="rounded-full bg-sage px-4 py-1.5 font-medium text-primary-content transition hover:bg-sage-dark"
onclick={() => showFirstAvailable(item.id, availableKeys.find((key) => key > shownTo) ?? availableKeys[0])}
>
Go to {availableKeys[0] > shownTo ? 'first' : 'next'} available date →
</button>
{#if ui.next}
<span>The next available date for {formatDuration(duration.minutes)} is <strong>{longDate(zonedDateKey(ui.next, timezone))}</strong>.</span>
<button
type="button"
class="rounded-full bg-sage px-4 py-1.5 font-medium text-primary-content transition hover:bg-sage-dark"
onclick={() => showDay(item.id, ui.next!)}
>
Go to next available date →
</button>
{:else}
<span>No times are available for {formatDuration(duration.minutes)} in these months{item.durations.length > 1 ? ' — try another length' : ''}.</span>
{/if}
</div>
{/if}
@ -358,7 +480,7 @@
<span class="py-1 text-xs text-charcoal/40">{letter}</span>
{/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}
<button
type="button"
@ -382,40 +504,40 @@
{/each}
</div>
{#if ui.selectedDayKey}
{@const daySlots = itemSlotsByDay.get(ui.selectedDayKey) ?? []}
{#if ui.selectedDayKey && byDay.has(ui.selectedDayKey)}
<p class="mt-4 mb-2 text-sm font-medium text-charcoal/70">
Available times · {formatDateKey(ui.selectedDayKey, { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' })}
Available times · {longDate(ui.selectedDayKey)}
</p>
<div class="flex flex-wrap gap-2">
{#each daySlots as slot (slot.id)}
{@const line = basket.lines.find((l) => l.slot === slot.id)}
{@const isGroup = slot.capacity > 1}
{@const label = `${formatTime(slot.start)}${item.duration != null ? ` · ${item.duration} min` : ''}`}
{#if isGroup && line}
{#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}
<!-- Places in a group session already in the basket: − / + -->
<div class="inline-flex items-center gap-2 rounded-full bg-sage/15 py-1 pr-1 pl-3.5 text-sm text-sage-dark">
<span>{label} · {placesLeft(slot.free)}</span>
<span>{label} · {placesLeft(free)}</span>
<span class="inline-flex items-center gap-1 rounded-full bg-white px-1 py-0.5">
<button
type="button"
class="flex h-6 w-6 items-center justify-center rounded-full leading-none text-charcoal transition hover:bg-charcoal/10 disabled:opacity-40"
aria-label="One place fewer"
disabled={ui.adding}
onclick={() => changeSeats(item.id, line, -1)}
onclick={() => changeSeats(item.id, entry, -1)}
>
−
</button>
<span class="min-w-5 text-center font-semibold text-charcoal tabular-nums" aria-live="polite">
{#if ui.pendingSlotId === slot.id}<span class="loading loading-spinner loading-xs"></span>{:else}{line.quantity}{/if}
<span class="sr-only">{line.quantity === 1 ? 'place' : 'places'} in your basket</span>
{#if pending}<span class="loading loading-spinner loading-xs"></span>{:else}{entry.line.quantity}{/if}
<span class="sr-only">{entry.line.quantity === 1 ? 'place' : 'places'} in your basket</span>
</span>
<button
type="button"
class="flex h-6 w-6 items-center justify-center rounded-full leading-none text-charcoal transition hover:bg-charcoal/10 disabled:opacity-40"
aria-label="One place more"
disabled={ui.adding || slot.free <= 0}
onclick={() => changeSeats(item.id, line, 1)}
disabled={ui.adding || free <= 0}
onclick={() => changeSeats(item.id, entry, 1)}
>
+
</button>
@ -424,27 +546,25 @@
{:else}
<button
type="button"
disabled={!!line || ui.adding}
onclick={() => addSlot(item.id, slot.id)}
class="inline-flex items-center gap-1.5 rounded-full border px-3.5 py-1.5 text-sm transition {line
disabled={!!entry.line || !entry.time || ui.adding}
onclick={() => entry.time && addTime(item, duration.minutes, entry.time)}
class="inline-flex items-center gap-1.5 rounded-full border px-3.5 py-1.5 text-sm transition {entry.line
? 'cursor-not-allowed border-transparent bg-sage/15 text-sage-dark'
: 'border-charcoal/15 bg-white text-charcoal hover:border-sage hover:bg-sage/10'} disabled:opacity-60 {ui.adding &&
!line
!entry.line
? 'cursor-wait'
: ''}"
>
{#if ui.pendingSlotId === slot.id}
{#if pending}
<span class="loading loading-spinner loading-xs"></span>
{/if}
{label}{isGroup ? ` · ${placesLeft(slot.free)}` : ''}{line ? ' · In basket' : ''}
{label}{isGroup ? ` · ${placesLeft(free)}` : ''}{entry.line ? ' · In basket' : ''}
</button>
{/if}
{/each}
</div>
{:else if anyShown}
<p class="mt-4 text-sm text-charcoal/60">
Days with availability are highlighted{item.duration != null ? ` · ${item.duration} min per session` : ''}.
</p>
<p class="mt-4 text-sm text-charcoal/60">Days with availability are highlighted.</p>
{/if}
{#if ui.justAdded}