Checkout: reservation countdown, 'keep it 10 more minutes', and a message when a hold runs out

Basket changes that free or take places reload the page data, so places
removed from the basket show up in the shop again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VaXE9U7AmW3dfD2w6cbLfk
This commit is contained in:
agent 2026-10-24 09:32:56 +00:00
parent 28773f2599
commit 021d06d3e4
6 changed files with 187 additions and 28 deletions

View file

@ -275,8 +275,9 @@ function createBasket(app) {
/**
* Renew the hold on every slot line in a basket. Used at checkout start
* (30 min) and after a failed payment (10 min, so the customer can retry).
* A live hold is simply extended (its seats are already counted). A lapsed
* (30 min), after a failed payment (10 min, so the customer can retry) and
* when the customer asks for more time (`renew_holds`, 10 min). A live hold
* is extended, never shortened (its seats are already counted). A lapsed
* one that hasn't been swept yet is rescued only if its seats are still
* free and nothing has blocked the time since — otherwise it's left for
* the sweep, and checkout tells the customer the slot expired.
@ -285,9 +286,12 @@ function extendBasketHolds(app, basketId, durationMs) {
const now = Date.now();
const until = isoIn(durationMs);
for (const line of findAll(app, 'basket_lines', "basket = {:basket} && lineType = 'slot'", { basket: basketId })) {
if (toMs(line.getString('heldUntil')) > now) {
line.set('heldUntil', until);
app.save(line);
const heldUntil = toMs(line.getString('heldUntil'));
if (heldUntil > now) {
if (heldUntil < now + durationMs) {
line.set('heldUntil', until);
app.save(line);
}
continue;
}
try {
@ -379,6 +383,13 @@ function basketAction(app, body) {
break;
}
case 'renew_holds': {
// "Keep my reservation" at checkout. Holds that already lapsed were
// swept above; the customer is told and picks the time again.
extendBasketHolds(app, basket.id, SLOT_HOLD_MS);
break;
}
case 'remove_line': {
const line = lines.find((l) => l.id === String(body.lineId || ''));
if (!line) throw new NotFoundError('Line not found in your basket');