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:
parent
23df2ceced
commit
eac99b2abe
18 changed files with 479 additions and 210 deletions
6
app-admin/src/routes/api/slots/+server.ts
Normal file
6
app-admin/src/routes/api/slots/+server.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { bookableTimesResponse } from '$shared/server/shop';
|
||||
import type { RequestHandler } from './$types';
|
||||
|
||||
// Bookable times for the Shop block's picker (one service and duration).
|
||||
// Public data from the shop hook in PocketBase — this only forwards it.
|
||||
export const GET: RequestHandler = ({ locals, url }) => bookableTimesResponse(locals.pb, url);
|
||||
|
|
@ -3,14 +3,15 @@ import { loadShopData } from '$shared/server/shop';
|
|||
import type { PageServerLoad } from './$types';
|
||||
|
||||
// The draft blocks come from sessionStorage (client-side), so load the data
|
||||
// any block might need: shop items/slots and upcoming events. Failures leave
|
||||
// any block might need: shop items and upcoming events (Shop blocks fetch
|
||||
// bookable times themselves). Failures leave
|
||||
// the blocks empty rather than breaking the preview.
|
||||
export const load: PageServerLoad = async ({ locals }) => {
|
||||
const range = getUpcomingCalendarRange();
|
||||
const [shop, events] = await Promise.all([
|
||||
loadShopData(locals.pb).catch((e) => {
|
||||
console.warn('Preview: shop data unavailable:', e instanceof Error ? e.message : e);
|
||||
return { items: [], slots: [] };
|
||||
return { items: [] };
|
||||
}),
|
||||
locals.pb
|
||||
.collection('events')
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
</svelte:head>
|
||||
|
||||
{#if blocks.length}
|
||||
<BlockRenderer {blocks} items={data.items} slots={data.slots} calendarEvents={data.calendarEvents} />
|
||||
<BlockRenderer {blocks} items={data.items} calendarEvents={data.calendarEvents} />
|
||||
{:else}
|
||||
<section class="mx-auto max-w-3xl px-6 py-20 text-center">
|
||||
<h1 class="text-4xl">No preview content</h1>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue