Services with several lengths; slots become time windows #6
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "session/change-slots-behavior"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
Today one massage in three lengths means three services, and every bookable time is a slot of one service. The studio asked for:
Bundles, vouchers and codes are a follow-up PR on top of this.
What changes
Schema (migration
1793100000_durations_and_time_windows.js, mirrored inpb_schema.json)items.durations—[{ minutes, price }];items.durationgoes.items.priceis kept as the lowest length price (products: unchanged).slots.kind=window|session,slots.items(multiple),slots.startTimes=grid|edgeswithslots.gridMinutes(the step);slots.itemgoes.basket_lines.start/minutes,order_lines.minutes: a booking records its own time, so availability no longer depends on the slot.minutesfrom its slot, so paid bookings keep blocking their time. Basket holds on old slots are dropped.Availability (all still in
pocketbase/pb_hooks/shop/lib.js)grid= fixed steps, chosen per window (gridMinutes: 10, 15, 20, 30, 45 or 60; default 30);edges= only at the start or end of each free stretch, so the window shrinks from either end and no gaps are left. A booking must fit inside the window; its get-ready time may run past the end.GET /api/shop/slots?item=&minutes=&from=&to=lists times for one service and length, plusnextwhen the range is empty. The Shop block fetches it viaGET /api/slotsin each app instead of shipping every slot in the layout.Admin
Public: service cards show "from" the lowest price; after Book, a slider picks the length (the price follows) above the date picker; the picker loads times for the chosen length and reloads after a booking. Checkout, emails and orders show the booked length.
Tested
main's schema with old-style data: old slots are removed, the paid booking keeps its time (60 min), the stale hold is dropped, and services get one length at their old price. Fresh install (pb_schema.jsonimport) works too.next, and admin detail/auth.stripe-mock): the order line gets the right start, length and price, and the paid time stays blocked.svelte-check: 0 errors in both apps. All warnings are in files this PR doesn't touch.Not tested: real Stripe payment, actual email sending (the email code path is unchanged apart from the end time), Copy-a-week and Clear in the browser (same server code paths as Generate, covered by type-checks only), and mobile layouts.
Deploying
The migration runs on the next PocketBase start and deletes all existing slots. Back up
pb_datafirst. Then set each service's lengths and prices under Services & products, and create windows under Slots.🤖 Generated with Claude Code
https://claude.ai/code/session_01Hy2vMnHJYP7QGsiH21zHxW
A service now has `durations` ([{ minutes, price }]) instead of one duration and price. A slot is either a `window` (a stretch of time with the services that can be booked in it, start times every 30 min or only at the edges of the free time) or a `session` (one service, fixed time, places — the old group slot). Basket and order lines carry their own start and minutes, so availability is computed from bookings alone. The migration keeps paid bookings blocking their time (order lines get minutes from their slot), then deletes the old slots — agreed: start fresh. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hy2vMnHJYP7QGsiH21zHxW