Session gaps: per-session waitlist, door session picker, all-sessions choice
- Waitlist per session: entries for pick-sessions tickets name a session; offers use that session's free places, never run past its start, and claim links tick it. Held offers count towards session capacity. - At the door: the Select items pop-up has the session picker, with today's session preselected for new attendees. - On pick-sessions events every ticket shows the session list straight away. "All sessions" tickets record the ticked sessions (RegistrationOption.sessionIds) at one price; scanning, attendance, certificates, reminders and capacity follow them. - Fix: per-session stock limits weren't enforced (takenCount filtered WaitlistEntry by a sessionId column that didn't exist, and the error was swallowed), and the public event page lost its stock info. - Fix: editing a door registration with picked sessions couldn't be saved. - Fix: the offline-scanning service worker served /_next/static cache-first forever, so dev browsers that had opened the scanner ran stale code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { useRouter } from "next/navigation";
|
||||
@@ -16,7 +15,8 @@ import { DoorOpen, UserPlus, CreditCard, CheckSquare, Ticket, RotateCcw, type Lu
|
||||
import { errorMessage } from "@/lib/utils";
|
||||
import { optionUnitNow, variantUnitNow } from "@/lib/pricing";
|
||||
import { printTicketCards, ticketTypeLabel as ticketLabel } from "@/lib/ticketPrint";
|
||||
import { isPickOption, todaysSession } from "@/lib/sessions";
|
||||
import { bookableSessions, choosesSessions, isPickOption, todaysSession } from "@/lib/sessions";
|
||||
import { SessionPicker } from "@/components/events/SessionPicker";
|
||||
import type { Event, EventOption, PublicBundle, Registration, Ticket as TicketRecord, UserSummary } from "@/types";
|
||||
|
||||
type NewAttendee = { name: string; email: string | null; phone: string | null; notifPref: "email" | "whatsapp" | "both" };
|
||||
@@ -98,6 +98,10 @@ export default function AtTheDoorPage() {
|
||||
|
||||
const [eventOptions, setEventOptions] = useState<EventOption[]>([]);
|
||||
const [doorHasPickOptions, setDoorHasPickOptions] = useState(false);
|
||||
// "Pick sessions" events: the event (for its sessions) and the sessions chosen per
|
||||
// quantity key. Picked sessions are booked on new registrations only.
|
||||
const [doorEvent, setDoorEvent] = useState<Event | null>(null);
|
||||
const [picks, setPicks] = useState<Record<string, string[]>>({});
|
||||
const [showOptionsModal, setShowOptionsModal] = useState(false);
|
||||
const [pendingUser, setPendingUser] = useState<NewAttendee | null>(null);
|
||||
const [doorCoupon, setDoorCoupon] = useState<AppliedCoupon | null>(null);
|
||||
@@ -160,16 +164,16 @@ export default function AtTheDoorPage() {
|
||||
authToken: token
|
||||
});
|
||||
|
||||
// Per-session tickets ("pick sessions") are booked from Manual registration,
|
||||
// which has the session picker.
|
||||
const all = ev.options || ev.eventOptions || [];
|
||||
setEventOptions(all.filter(o => !isPickOption(ev, o)));
|
||||
setDoorHasPickOptions(all.some(o => isPickOption(ev, o)));
|
||||
setDoorEvent(ev);
|
||||
setEventOptions(all);
|
||||
setDoorHasPickOptions(choosesSessions(ev));
|
||||
setDoorAllowsNames(!!ev.allowNamedAttendees || !!ev.requiresParentalConsent);
|
||||
setDoorYouthStart(ev.requiresParentalConsent ? ev.startDate : null);
|
||||
setDoorCollectGender(!!ev.collectGender);
|
||||
setDoorBundles(ev.bundles || []);
|
||||
} catch {
|
||||
setDoorEvent(null);
|
||||
setEventOptions([]);
|
||||
setDoorBundles([]);
|
||||
}
|
||||
@@ -213,6 +217,10 @@ export default function AtTheDoorPage() {
|
||||
|
||||
}, [activeRegistration]);
|
||||
|
||||
// Charged per session / has sessions to tick (every ticket on a "pick sessions" event).
|
||||
const isPick = (optionId: string) => isPickOption(doorEvent, eventOptions.find(o => o.id === optionId));
|
||||
const choosing = choosesSessions(doorEvent);
|
||||
|
||||
const confirmRegistration = async () => {
|
||||
if (confirming) return;
|
||||
|
||||
@@ -220,13 +228,18 @@ export default function AtTheDoorPage() {
|
||||
.filter(([, qty]) => qty > 0)
|
||||
.map(([key, quantity]) => {
|
||||
const [eventOptionId, variantId] = key.split("::");
|
||||
return { eventOptionId, quantity, ...(variantId ? { variantId } : {}) };
|
||||
return { eventOptionId, quantity, ...(variantId ? { variantId } : {}), ...(choosing && !pendingEditReg ? { sessionIds: picks[key] || [] } : {}) };
|
||||
});
|
||||
|
||||
if (!opts.length) {
|
||||
setError("Select at least one item");
|
||||
return;
|
||||
}
|
||||
const noSessions = opts.find(o => "sessionIds" in o && o.sessionIds && o.sessionIds.length === 0);
|
||||
if (noSessions) {
|
||||
setError(`Choose the sessions for "${eventOptions.find(o => o.id === noSessions.eventOptionId)?.name || "the ticket"}".`);
|
||||
return;
|
||||
}
|
||||
|
||||
for (const [key, minQty] of Object.entries(minQuantities)) {
|
||||
if (minQty > 0 && (quantities[key] || 0) < minQty) {
|
||||
@@ -244,6 +257,8 @@ export default function AtTheDoorPage() {
|
||||
if (missing) { setError(missing); return; }
|
||||
}
|
||||
|
||||
// Picked-session lines take no names.
|
||||
const nameOptions = eventOptions.filter(o => !isPick(o.id));
|
||||
setConfirming(true);
|
||||
try {
|
||||
if (pendingEditReg) {
|
||||
@@ -286,8 +301,8 @@ export default function AtTheDoorPage() {
|
||||
options: opts,
|
||||
notificationPreference: pendingUser.notifPref,
|
||||
...(doorCoupon ? { couponCode: doorCoupon.code } : {}),
|
||||
...(doorAllowsNames && (doorNaming || doorYouthStart) && attendeesPayload(eventOptions, (o, v) => quantities[v ? `${o}::${v}` : o] || 0, doorEntries).length > 0
|
||||
? { attendees: attendeesPayload(eventOptions, (o, v) => quantities[v ? `${o}::${v}` : o] || 0, doorEntries), ticketDelivery: doorDelivery }
|
||||
...(doorAllowsNames && (doorNaming || doorYouthStart) && attendeesPayload(nameOptions, (o, v) => quantities[v ? `${o}::${v}` : o] || 0, doorEntries).length > 0
|
||||
? { attendees: attendeesPayload(nameOptions, (o, v) => quantities[v ? `${o}::${v}` : o] || 0, doorEntries), ticketDelivery: doorDelivery }
|
||||
: {}),
|
||||
}
|
||||
});
|
||||
@@ -311,16 +326,20 @@ export default function AtTheDoorPage() {
|
||||
// Called when NewAttendeeModal is confirmed — proceed to options selection
|
||||
const handleNewAttendeeConfirm = ({ name, email, phone, notifPref }: { name: string; email: string; phone: string; notifPref: "email" | "whatsapp" | "both" }) => {
|
||||
const qtyMap = initQuantities(eventOptions);
|
||||
// Default main ticket to 1 (first variant if variants exist)
|
||||
const pickMap: Record<string, string[]> = {};
|
||||
// Default main ticket to 1 (first variant if variants exist). On a "pick sessions"
|
||||
// event with a session today that still has room, that's one place in today's session.
|
||||
const today = todaysSession(doorEvent);
|
||||
const todayPick = today && doorEvent && choosing ? eventOptions.find(o => o.isMainTicket
|
||||
&& bookableSessions(doorEvent, o, true).some(s => s.id === today.id && (s.left === null || s.left > 0))) : undefined;
|
||||
eventOptions.forEach(o => {
|
||||
if (!o.isMainTicket) return;
|
||||
if ((o.variants || []).length > 0) {
|
||||
qtyMap[`${o.id}::${(o.variants || [])[0].id}`] = 1;
|
||||
} else {
|
||||
qtyMap[o.id] = 1;
|
||||
}
|
||||
if (!o.isMainTicket || (todayPick ? o !== todayPick : choosing)) return;
|
||||
const key = (o.variants || []).length > 0 ? `${o.id}::${(o.variants || [])[0].id}` : o.id;
|
||||
qtyMap[key] = 1;
|
||||
if (o === todayPick && today) pickMap[key] = [today.id];
|
||||
});
|
||||
setQuantities(qtyMap);
|
||||
setPicks(pickMap);
|
||||
setMinQuantities({});
|
||||
setPendingUser({ name, email: email || null, phone: phone || null, notifPref });
|
||||
setPendingEditReg(null);
|
||||
@@ -345,8 +364,8 @@ export default function AtTheDoorPage() {
|
||||
return;
|
||||
}
|
||||
|
||||
const qtyMap = initQuantities(eventOptions);
|
||||
const regOptions = freshReg.registrationOptions || [];
|
||||
const qtyMap = initQuantities(eventOptions.filter(o => !isPick(o.id)));
|
||||
const regOptions = (freshReg.registrationOptions || []).filter(ro => !ro.sessionId);
|
||||
regOptions.forEach((ro) => {
|
||||
const key = ro.variantId ? `${ro.eventOptionId}::${ro.variantId}` : ro.eventOptionId;
|
||||
if (key in qtyMap) qtyMap[key] = ro.quantity || 0;
|
||||
@@ -361,6 +380,7 @@ export default function AtTheDoorPage() {
|
||||
});
|
||||
|
||||
setQuantities(qtyMap);
|
||||
setPicks({});
|
||||
setMinQuantities(minQtyMap);
|
||||
setPendingEditReg(freshReg);
|
||||
setPendingUser(null);
|
||||
@@ -499,15 +519,11 @@ export default function AtTheDoorPage() {
|
||||
{mode === "refund" && (
|
||||
<DoorRefundPanel token={token} eventId={eventId} setInfo={setInfo} />
|
||||
)}
|
||||
{doorHasPickOptions && (
|
||||
<div className="mt-4 p-3 border rounded bg-amber-50 border-amber-200 text-amber-900 text-sm">
|
||||
This event has per-session tickets. Book those from <Link className="underline font-medium" href="/dashboard/supervisor/manual">Manual registration</Link>, which lets you choose the sessions.
|
||||
</div>
|
||||
)}
|
||||
<OptionsModal
|
||||
open={showOptionsModal}
|
||||
onClose={() => { setShowOptionsModal(false); setPendingEditReg(null); }}
|
||||
options={eventOptions}
|
||||
options={pendingEditReg ? eventOptions.filter(o => !isPick(o.id)) : eventOptions}
|
||||
pick={doorEvent && doorHasPickOptions ? { event: doorEvent, picks, setPicks } : null}
|
||||
quantities={quantities}
|
||||
setQuantities={setQuantities}
|
||||
minQuantities={minQuantities}
|
||||
@@ -1194,15 +1210,30 @@ type OptionsModalProps = {
|
||||
bundles: PublicBundle[];
|
||||
// Named-attendee editor settings, or null when the event doesn't take names.
|
||||
names: Omit<React.ComponentProps<typeof AttendeeNamesEditor>, "options" | "qtyFor" | "payerLabel"> | null;
|
||||
// A "pick sessions" event: its sessions and the sessions chosen per quantity key.
|
||||
pick: { event: Event; picks: Record<string, string[]>; setPicks: React.Dispatch<React.SetStateAction<Record<string, string[]>>> } | null;
|
||||
};
|
||||
|
||||
function OptionsModal({ open, onClose, options, quantities, setQuantities, minQuantities = {}, onConfirm, confirming, isEdit, totalPaid = 0, eventId, token, coupon, setCoupon, couponForUserId, existingCode, bundles, names }: OptionsModalProps) {
|
||||
function OptionsModal({ open, onClose, options, quantities, setQuantities, minQuantities = {}, onConfirm, confirming, isEdit, totalPaid = 0, eventId, token, coupon, setCoupon, couponForUserId, existingCode, bundles, names, pick }: OptionsModalProps) {
|
||||
const pickOpt = (optionId: string) => !!pick && isPickOption(pick.event, (options || []).find(o => o.id === optionId));
|
||||
// Sessions are ticked on new bookings only (edits leave booked sessions as they are).
|
||||
const choiceOpt = (optionId: string) => !!pick && !isEdit && (options || []).some(o => o.id === optionId);
|
||||
// A picked option is priced per session.
|
||||
const times = (key: string) => (pick && pickOpt(key.split("::")[0]) ? (pick.picks[key] || []).length : 1);
|
||||
const basket = Object.entries(quantities)
|
||||
.filter(([, qty]) => qty > 0)
|
||||
.map(([key, quantity]) => {
|
||||
const [eventOptionId, variantId] = key.split("::");
|
||||
return { eventOptionId, quantity, variantId: variantId || null };
|
||||
return { eventOptionId, quantity, variantId: variantId || null, ...(pick && choiceOpt(eventOptionId) ? { sessionIds: pick.picks[key] || [] } : {}) };
|
||||
});
|
||||
// The sessions show straight away; ticking one when the quantity is 0 makes it 1.
|
||||
const picker = (key: string, option: EventOption) => {
|
||||
if (!pick || !choiceOpt(option.id)) return null;
|
||||
const qty = quantities[key] || 0;
|
||||
return <SessionPicker event={pick.event} option={option} staff quantity={Math.max(1, qty)} selected={qty > 0 ? pick.picks[key] || [] : []}
|
||||
onChange={ids => { pick.setPicks(p => ({ ...p, [key]: ids })); if (qty === 0 && ids.length > 0) setQuantities(q => ({ ...q, [key]: 1 })); }} />;
|
||||
};
|
||||
const perSession = (o: EventOption) => (pickOpt(o.id) ? " per session" : "");
|
||||
// Bundle deals apply to the whole registration, so this holds for edits too.
|
||||
const bundleQuote = useBundleQuote({ eventId, basket, token, forUserId: couponForUserId, enabled: open });
|
||||
|
||||
@@ -1213,9 +1244,9 @@ function OptionsModal({ open, onClose, options, quantities, setQuantities, minQu
|
||||
const total = safeOptions.reduce((sum, o) => {
|
||||
if ((o.variants || []).length > 0) {
|
||||
return sum + (o.variants || []).reduce((vs, v) =>
|
||||
vs + (quantities[`${o.id}::${v.id}`] || 0) * variantUnitNow(o, v), 0);
|
||||
vs + (quantities[`${o.id}::${v.id}`] || 0) * times(`${o.id}::${v.id}`) * variantUnitNow(o, v), 0);
|
||||
}
|
||||
return sum + (quantities[o.id] || 0) * optionUnitNow(o);
|
||||
return sum + (quantities[o.id] || 0) * times(o.id) * optionUnitNow(o);
|
||||
}, 0);
|
||||
|
||||
const afterBundles = bundleQuote ? bundleQuote.total : total;
|
||||
@@ -1236,6 +1267,11 @@ function OptionsModal({ open, onClose, options, quantities, setQuantities, minQu
|
||||
<div className="text-xl font-semibold">
|
||||
{isEdit ? "Edit Registration" : "Select Items"}
|
||||
</div>
|
||||
{isEdit && pick && (
|
||||
<div className="text-sm text-gray-500 mt-1">
|
||||
Sessions already booked stay as they are. To add sessions, book them as a new registration.
|
||||
</div>
|
||||
)}
|
||||
{isEdit && totalPaid > 0 && (
|
||||
<div className="text-sm text-gray-500 mt-1">
|
||||
Already paid: <strong>R {Number(totalPaid).toFixed(2)}</strong> — new total must be at least this amount.
|
||||
@@ -1267,11 +1303,12 @@ function OptionsModal({ open, onClose, options, quantities, setQuantities, minQu
|
||||
const key = `${opt.id}::${v.id}`;
|
||||
const minQty = minQuantities[key] || 0;
|
||||
return (
|
||||
<div key={v.id} className="flex items-center justify-between px-4 py-2.5 border-b last:border-b-0">
|
||||
<div key={v.id} className="px-4 py-2.5 border-b last:border-b-0">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<div className="text-sm">{v.name}</div>
|
||||
<div className="text-xs text-gray-500">
|
||||
R {unit.toFixed(2)}
|
||||
R {unit.toFixed(2)}{perSession(opt)}
|
||||
{unit < basePrice && basePrice > 0 && <span className="ml-1 text-green-600">(early bird)</span>}
|
||||
</div>
|
||||
{minQty > 0 && <div className="text-xs text-gray-400">{minQty} already issued</div>}
|
||||
@@ -1282,6 +1319,8 @@ function OptionsModal({ open, onClose, options, quantities, setQuantities, minQu
|
||||
<button onClick={() => stepper(key, 1)} className="w-8 h-8 border rounded flex items-center justify-center text-lg font-bold bg-emerald-50 border-emerald-300 text-emerald-700">+</button>
|
||||
</div>
|
||||
</div>
|
||||
{picker(key, opt)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
@@ -1293,7 +1332,7 @@ function OptionsModal({ open, onClose, options, quantities, setQuantities, minQu
|
||||
<div key={opt.id} className="border rounded-xl p-3">
|
||||
<div className="font-medium">{opt.name}</div>
|
||||
<div className="text-xs text-gray-500">
|
||||
R {unit.toFixed(2)}
|
||||
R {unit.toFixed(2)}{perSession(opt)}
|
||||
{unit < opt.price && opt.price > 0 && <span className="ml-1 text-green-600">(early bird, was R {opt.price.toFixed(2)})</span>}
|
||||
{opt.isMainTicket ? " • Main" : ""}
|
||||
</div>
|
||||
@@ -1303,6 +1342,7 @@ function OptionsModal({ open, onClose, options, quantities, setQuantities, minQu
|
||||
<div className="w-6 text-center text-lg font-semibold">{quantities[opt.id] || 0}</div>
|
||||
<button onClick={() => stepper(opt.id, 1)} className="w-8 h-8 border rounded flex items-center justify-center text-lg font-bold bg-emerald-50 border-emerald-300 text-emerald-700">+</button>
|
||||
</div>
|
||||
{picker(opt.id, opt)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
@@ -1323,7 +1363,7 @@ function OptionsModal({ open, onClose, options, quantities, setQuantities, minQu
|
||||
{names && (
|
||||
<div className="mb-3 max-h-64 overflow-y-auto">
|
||||
<AttendeeNamesEditor
|
||||
options={safeOptions}
|
||||
options={safeOptions.filter(o => !pickOpt(o.id))}
|
||||
qtyFor={(o: string, v: string | null) => quantities[v ? `${o}::${v}` : o] || 0}
|
||||
{...names}
|
||||
payerLabel="the person registering"
|
||||
|
||||
@@ -12,7 +12,7 @@ import { AttendeeNamesEditor, AttendeeEntries, TicketDelivery, attendeesPayload,
|
||||
import { UserPlus, CreditCard } from "lucide-react";
|
||||
import { errorMessage } from "@/lib/utils";
|
||||
import { optionUnitNow, variantUnitNow } from "@/lib/pricing";
|
||||
import { isPickOption } from "@/lib/sessions";
|
||||
import { choosesSessions, isPickOption } from "@/lib/sessions";
|
||||
import { SessionPicker } from "@/components/events/SessionPicker";
|
||||
import type { Event, EventOption, PublicBundle, Registration, RegistrationOption, User } from "@/types";
|
||||
import { BackLink } from "@/components/shared/BackLink";
|
||||
@@ -289,11 +289,19 @@ export default function ManualRegistrationPage() {
|
||||
const o = (fullEvent?.eventOptions || []).find(x => x.id === optionId);
|
||||
return fullEvent && o && isPickOption(fullEvent, o) ? o : null;
|
||||
};
|
||||
// On a "pick sessions" event every ticket has sessions to tick; only pickOpt ones are charged per session.
|
||||
const choiceOpt = (optionId: string) => {
|
||||
const o = (fullEvent?.eventOptions || []).find(x => x.id === optionId);
|
||||
return fullEvent && o && choosesSessions(fullEvent) ? o : null;
|
||||
};
|
||||
const times = (key: string) => (pickOpt(key.split("::")[0]) ? (picks[key] || []).length : 1);
|
||||
const picker = (key: string, optionId: string) => {
|
||||
const o = pickOpt(optionId);
|
||||
if (!o || !fullEvent || !(quantities[key] > 0)) return null;
|
||||
return <SessionPicker event={fullEvent} option={o} staff quantity={quantities[key]} selected={picks[key] || []} onChange={ids => setPicks(p => ({ ...p, [key]: ids }))} />;
|
||||
const o = choiceOpt(optionId);
|
||||
if (!o || !fullEvent) return null;
|
||||
// The sessions show straight away; ticking one when the quantity is 0 makes it 1.
|
||||
const qty = quantities[key] || 0;
|
||||
return <SessionPicker event={fullEvent} option={o} staff quantity={Math.max(1, qty)} selected={qty > 0 ? picks[key] || [] : []}
|
||||
onChange={ids => { setPicks(p => ({ ...p, [key]: ids })); if (qty === 0 && ids.length > 0) setQuantities(q => ({ ...q, [key]: 1 })); }} />;
|
||||
};
|
||||
|
||||
const totalDue = useMemo(() => {
|
||||
@@ -307,7 +315,7 @@ export default function ManualRegistrationPage() {
|
||||
|
||||
const basket = useMemo(() => Object.entries(quantities).map(([key, quantity]) => {
|
||||
const [eventOptionId, variantId] = key.split("::");
|
||||
return { eventOptionId, quantity, variantId: variantId || null, ...(pickOpt(eventOptionId) ? { sessionIds: picks[key] || [] } : {}) };
|
||||
return { eventOptionId, quantity, variantId: variantId || null, ...(choiceOpt(eventOptionId) ? { sessionIds: picks[key] || [] } : {}) };
|
||||
}), [quantities, picks, fullEvent]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
const bundleQuote = useBundleQuote({ eventId: selectedEventId, basket, token, forUserId: pickedUserId });
|
||||
const payable = coupon ? coupon.total : bundleQuote ? bundleQuote.total : totalDue;
|
||||
@@ -322,7 +330,7 @@ export default function ManualRegistrationPage() {
|
||||
.filter(([, qty]) => qty > 0)
|
||||
.map(([key, quantity]) => {
|
||||
const [eventOptionId, variantId] = key.split("::");
|
||||
return { eventOptionId, quantity, ...(variantId ? { variantId } : {}), ...(pickOpt(eventOptionId) ? { sessionIds: picks[key] || [] } : {}) };
|
||||
return { eventOptionId, quantity, ...(variantId ? { variantId } : {}), ...(choiceOpt(eventOptionId) ? { sessionIds: picks[key] || [] } : {}) };
|
||||
});
|
||||
if (opts.length === 0) { setError("Please select at least one ticket option."); return; }
|
||||
const noSessions = opts.find(o => "sessionIds" in o && o.sessionIds && o.sessionIds.length === 0);
|
||||
|
||||
@@ -9,6 +9,7 @@ import { useDismissingState } from "@/hooks/useDismissingState";
|
||||
import { ListChecks, ArrowUp, ArrowDown } from "lucide-react";
|
||||
import { Table, TableHeader, TableBody, TableRow, TableHead, TableCell } from "@/components/ui/table";
|
||||
import { errorMessage } from "@/lib/utils";
|
||||
import { entryLineName } from "@/lib/waitlist";
|
||||
import type { Event } from "@/types";
|
||||
import { BackLink } from "@/components/shared/BackLink";
|
||||
|
||||
@@ -22,6 +23,7 @@ type Entry = {
|
||||
createdAt: string;
|
||||
eventOption: { name: string };
|
||||
variant: { name: string } | null;
|
||||
session: { label: string | null; startsAt: string } | null;
|
||||
user: { name: string; email: string; phoneNumber: string | null };
|
||||
};
|
||||
|
||||
@@ -153,7 +155,7 @@ export default function WaitlistPage() {
|
||||
<div className="text-sm font-medium">{e.user.name}</div>
|
||||
<div className="text-xs text-gray-500">{[e.user.email, e.user.phoneNumber].filter(Boolean).join(" · ")}</div>
|
||||
</TableCell>
|
||||
<TableCell className="text-sm">{e.eventOption.name}{e.variant ? ` (${e.variant.name})` : ""}</TableCell>
|
||||
<TableCell className="text-sm">{entryLineName(e)}</TableCell>
|
||||
<TableCell className="text-sm">{e.quantity}{e.status === "offered" && e.offeredQuantity !== e.quantity ? ` (${e.offeredQuantity} offered)` : ""}</TableCell>
|
||||
<TableCell className="text-xs text-gray-600">{formatDate(new Date(e.createdAt))}</TableCell>
|
||||
<TableCell>
|
||||
|
||||
@@ -6,7 +6,7 @@ import { apiFetch } from "@/lib/api";
|
||||
import { CouponCodeField, AppliedCoupon } from "@/components/shared/CouponCodeField";
|
||||
import { BundleBuilder, BundleOffers, BundleSavings, useBundleQuote } from "@/components/shared/BundleDeals";
|
||||
import type { EventSession, LateJoinInfo, PublicBundle } from "@/types";
|
||||
import { isPickOption, latePrice, registrationClosesAt } from "@/lib/sessions";
|
||||
import { choosesSessions, isPickOption, latePrice, registrationClosesAt } from "@/lib/sessions";
|
||||
import { SessionPicker } from "@/components/events/SessionPicker";
|
||||
import { AttendeeNamesEditor, AttendeeEntries, TicketDelivery, attendeesPayload, consentDetailsMissing } from "@/components/shared/AttendeeNamesEditor";
|
||||
import { JoinWaitlistButton } from "@/components/events/JoinWaitlistButton";
|
||||
@@ -80,7 +80,7 @@ function withLatePrices(event: RegisterEvent): RegisterEvent {
|
||||
};
|
||||
}
|
||||
|
||||
type WaitlistOffer = { eventOptionId: string; variantId: string | null; quantity: number; expiresAt: string; optionName: string; variantName: string | null };
|
||||
type WaitlistOffer = { eventOptionId: string; variantId: string | null; sessionId?: string | null; lineName?: string; quantity: number; expiresAt: string; optionName: string; variantName: string | null };
|
||||
|
||||
// Key format: "optionId" for no-variant options, "optionId:variantId" for variant options
|
||||
type QtyMap = Record<string, number>;
|
||||
@@ -161,8 +161,9 @@ function QtyControl({
|
||||
);
|
||||
}
|
||||
|
||||
// A "pick sessions" option: the sessions chosen per quantity key, and the event's schedule.
|
||||
type PickProps = { event: RegisterEvent; picks: Record<string, string[]>; onPick: (key: string, ids: string[]) => void };
|
||||
// A "pick sessions" event: the sessions chosen per quantity key, and the event's schedule.
|
||||
// perSession: this ticket is charged per session (otherwise one price for the sessions ticked).
|
||||
type PickProps = { event: RegisterEvent; picks: Record<string, string[]>; onPick: (key: string, ids: string[]) => void; perSession: boolean };
|
||||
|
||||
function OptionCard({
|
||||
opt,
|
||||
@@ -178,9 +179,12 @@ function OptionCard({
|
||||
pick?: PickProps | null;
|
||||
}) {
|
||||
const hasVariants = Array.isArray(opt.variants) && opt.variants.length > 0;
|
||||
const perSession = pick ? " per session" : "";
|
||||
const picker = (key: string, qty: number, unit: number) => (pick && qty > 0 ? (
|
||||
<SessionPicker event={pick.event} option={opt} selected={pick.picks[key] || []} onChange={(ids) => pick.onPick(key, ids)} quantity={qty} unitPrice={unit} />
|
||||
const perSession = pick?.perSession ? " per session" : "";
|
||||
// The sessions show straight away; ticking one when the quantity is 0 makes it 1.
|
||||
const picker = (key: string, qty: number, unit: number, variant?: { id: string; name: string }) => (pick ? (
|
||||
<SessionPicker event={pick.event} option={opt} selected={qty > 0 ? pick.picks[key] || [] : []} quantity={Math.max(1, qty)} unitPrice={pick.perSession ? unit : undefined}
|
||||
onChange={(ids) => { pick.onPick(key, ids); if (qty === 0 && ids.length > 0) onQtyChange(key, 1); }}
|
||||
waitlist={waitlist ? { ...waitlist, variantId: variant?.id ?? null, label: variant ? `${opt.name} (${variant.name})` : opt.name } : null} />
|
||||
) : null);
|
||||
const isSoldOut = (opt.stockLimit ?? 0) > 0 && opt.availableCount !== undefined && opt.availableCount <= 0;
|
||||
|
||||
@@ -246,7 +250,7 @@ function OptionCard({
|
||||
max={maxQty}
|
||||
/>
|
||||
</div>
|
||||
{picker(key, qty, unitPrice)}
|
||||
{picker(key, qty, unitPrice, variant)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
@@ -397,6 +401,10 @@ export default function RegisterForm({ event: baseEvent }: { event: RegisterEven
|
||||
...priced,
|
||||
eventOptions: (priced.eventOptions || []).map(o => {
|
||||
if (o.id !== offer.eventOptionId) return o;
|
||||
if (offer.sessionId) {
|
||||
const left = o.sessionAvailability?.[offer.sessionId];
|
||||
return { ...o, ...(left !== undefined ? { sessionAvailability: { ...o.sessionAvailability, [offer.sessionId]: left + offer.quantity } } : {}) };
|
||||
}
|
||||
return {
|
||||
...o,
|
||||
availableCount: o.availableCount !== undefined ? o.availableCount + offer.quantity : o.availableCount,
|
||||
@@ -452,11 +460,17 @@ export default function RegisterForm({ event: baseEvent }: { event: RegisterEven
|
||||
setQuantities((q) => ({ ...q, [key]: val }));
|
||||
};
|
||||
|
||||
// "Pick sessions" options: the sessions chosen for each quantity key. Whole-course
|
||||
// tickets on such an event stop selling when the course starts.
|
||||
// "Pick sessions" events: the sessions chosen for each quantity key. Every ticket
|
||||
// shows the sessions; per-session tickets are charged once per session ticked.
|
||||
const [picks, setPicks] = useState<Record<string, string[]>>({});
|
||||
const wholeCourseClosed = event.attendanceMode === "pick" && !!event.wholeCourseClosesAt && Date.now() >= new Date(event.wholeCourseClosesAt).getTime();
|
||||
const choosing = choosesSessions(event);
|
||||
const pickFor = (opt: EventOption) => isPickOption(event, opt);
|
||||
// A waitlist offer for one session: that session is ticked for them.
|
||||
useEffect(() => {
|
||||
if (!offer?.sessionId) return;
|
||||
const key = offer.variantId ? `${offer.eventOptionId}:${offer.variantId}` : offer.eventOptionId;
|
||||
setPicks(p => ({ ...p, [key]: [offer.sessionId as string] }));
|
||||
}, [offer]);
|
||||
const sessionsFor = (key: string, opt: EventOption) => (pickFor(opt) ? (picks[key] || []).length : 1);
|
||||
|
||||
const total = useMemo(() => {
|
||||
@@ -505,7 +519,7 @@ export default function RegisterForm({ event: baseEvent }: { event: RegisterEven
|
||||
if (qty <= 0) return;
|
||||
const [eventOptionId, variantId] = key.includes(":") ? key.split(":") : [key, undefined];
|
||||
const opt = (event.eventOptions || []).find(o => o.id === eventOptionId);
|
||||
const sessionIds = opt && pickFor(opt) ? picks[key] || [] : undefined;
|
||||
const sessionIds = opt && choosing ? picks[key] || [] : undefined;
|
||||
items.push({ eventOptionId, quantity: qty, ...(variantId ? { variantId } : {}), ...(sessionIds ? { sessionIds } : {}) });
|
||||
});
|
||||
return items;
|
||||
@@ -636,7 +650,7 @@ export default function RegisterForm({ event: baseEvent }: { event: RegisterEven
|
||||
|
||||
{offer && (
|
||||
<div className="mb-4 p-4 border rounded-lg bg-green-50 border-green-200 text-sm text-green-900">
|
||||
<strong>Your waitlist place:</strong> {offer.quantity} × {offer.optionName}{offer.variantName ? ` (${offer.variantName})` : ""} — held for you until {new Date(offer.expiresAt).toLocaleString()}.
|
||||
<strong>Your waitlist place:</strong> {offer.quantity} × {offer.lineName || `${offer.optionName}${offer.variantName ? ` (${offer.variantName})` : ""}`} — held for you until {new Date(offer.expiresAt).toLocaleString()}.
|
||||
</div>
|
||||
)}
|
||||
{offerError && (
|
||||
@@ -691,18 +705,15 @@ export default function RegisterForm({ event: baseEvent }: { event: RegisterEven
|
||||
|
||||
{!eventSoldOut && <BundleOffers bundles={event.bundles} className="mb-3" />}
|
||||
|
||||
{wholeCourseClosed && (
|
||||
<p className="mb-3 text-sm text-gray-600 bg-gray-50 border rounded-lg px-3 py-2">The course has started, so whole-course tickets are no longer on sale — choose the sessions you'd like to come to.</p>
|
||||
)}
|
||||
<div className="space-y-3">
|
||||
{(event.eventOptions || []).filter(opt => !(wholeCourseClosed && !pickFor(opt))).map((opt) => (
|
||||
{(event.eventOptions || []).map((opt) => (
|
||||
<OptionCard
|
||||
key={opt.id}
|
||||
opt={opt}
|
||||
quantities={quantities}
|
||||
onQtyChange={handleQtyChange}
|
||||
waitlist={event.waitlistEnabled ? { eventId, guestsAllowed: event.requiresAuth === false } : null}
|
||||
pick={pickFor(opt) ? { event, picks, onPick: (key, ids) => setPicks(p => ({ ...p, [key]: ids })) } : null}
|
||||
pick={choosing ? { event, picks, onPick: (key, ids) => setPicks(p => ({ ...p, [key]: ids })), perSession: pickFor(opt) } : null}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -9,7 +9,7 @@ import { BundleBuilder, BundleOffers, BundleSavings, useBundleQuote } from "@/co
|
||||
import { AttendeeNamesEditor, AttendeeEntries, TicketDelivery, attendeesPayload, consentDetailsMissing } from "@/components/shared/AttendeeNamesEditor";
|
||||
import { errorMessage } from "@/lib/utils";
|
||||
import type { Event, PublicBundle, Registration } from "@/types";
|
||||
import { isPickOption } from "@/lib/sessions";
|
||||
import { choosesSessions, isPickOption } from "@/lib/sessions";
|
||||
import { SessionPicker } from "@/components/events/SessionPicker";
|
||||
|
||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||
@@ -230,11 +230,19 @@ export default function SelfServicePage() {
|
||||
const o = (kioskFull?.eventOptions || []).find(x => x.id === optionId);
|
||||
return kioskFull && o && isPickOption(kioskFull, o) ? o : null;
|
||||
};
|
||||
// On a "pick sessions" event every ticket has sessions to tick; only pickOpt ones are charged per session.
|
||||
const choiceOpt = (optionId: string) => {
|
||||
const o = (kioskFull?.eventOptions || []).find(x => x.id === optionId);
|
||||
return kioskFull && o && choosesSessions(kioskFull) ? o : null;
|
||||
};
|
||||
const times = (key: string) => (pickOpt(key.split("::")[0]) ? (picks[key] || []).length : 1);
|
||||
const picker = (key: string, optionId: string) => {
|
||||
const o = pickOpt(optionId);
|
||||
if (!o || !kioskFull || !(quantities[key] > 0)) return null;
|
||||
return <SessionPicker event={kioskFull} option={o} quantity={quantities[key]} selected={picks[key] || []} onChange={ids => setPicks(p => ({ ...p, [key]: ids }))} />;
|
||||
const o = choiceOpt(optionId);
|
||||
if (!o || !kioskFull) return null;
|
||||
// The sessions show straight away; ticking one when the quantity is 0 makes it 1.
|
||||
const qty = quantities[key] || 0;
|
||||
return <SessionPicker event={kioskFull} option={o} quantity={Math.max(1, qty)} selected={qty > 0 ? picks[key] || [] : []}
|
||||
onChange={ids => { setPicks(p => ({ ...p, [key]: ids })); if (qty === 0 && ids.length > 0) setQuantities(q => ({ ...q, [key]: 1 })); }} />;
|
||||
};
|
||||
|
||||
const total = useMemo(() => {
|
||||
@@ -456,7 +464,7 @@ export default function SelfServicePage() {
|
||||
.filter(([, qty]) => qty > 0)
|
||||
.map(([key, quantity]) => {
|
||||
const [eventOptionId, variantId] = key.split("::");
|
||||
return { eventOptionId, quantity, ...(variantId ? { variantId } : {}), ...(pickOpt(eventOptionId) ? { sessionIds: picks[key] || [] } : {}) };
|
||||
return { eventOptionId, quantity, ...(variantId ? { variantId } : {}), ...(choiceOpt(eventOptionId) ? { sessionIds: picks[key] || [] } : {}) };
|
||||
}),
|
||||
user,
|
||||
// If the visitor declined to create an account, don't push an unsolicited
|
||||
|
||||
@@ -14,6 +14,7 @@ type Claim = {
|
||||
eventStart: string;
|
||||
optionName: string;
|
||||
variantName: string | null;
|
||||
lineName?: string;
|
||||
quantity: number;
|
||||
requested: number;
|
||||
expiresAt: string;
|
||||
@@ -53,7 +54,7 @@ export default function WaitlistClaimPage() {
|
||||
{claim.status === "offered" ? (
|
||||
<>
|
||||
<p className="text-sm text-gray-700">
|
||||
{claim.name ? `Hi ${claim.name}, ` : ""}{claim.quantity} × {claim.optionName}{claim.variantName ? ` (${claim.variantName})` : ""} {claim.quantity === 1 ? "is" : "are"} being held for you until <strong>{new Date(claim.expiresAt).toLocaleString()}</strong>.
|
||||
{claim.name ? `Hi ${claim.name}, ` : ""}{claim.quantity} × {claim.lineName || `${claim.optionName}${claim.variantName ? ` (${claim.variantName})` : ""}`} {claim.quantity === 1 ? "is" : "are"} being held for you until <strong>{new Date(claim.expiresAt).toLocaleString()}</strong>.
|
||||
{claim.quantity < claim.requested && ` You asked for ${claim.requested}; this is what came free.`}
|
||||
</p>
|
||||
<a href={`/register/${claim.eventId}?waitlist=${encodeURIComponent(token)}`} className="inline-block px-4 py-2 rounded-lg bg-brand-600 text-white text-sm font-medium hover:bg-brand-700">
|
||||
|
||||
@@ -46,6 +46,7 @@ export function JoinWaitlistButton({ eventId, lines, guestsAllowed, initialLine,
|
||||
eventId,
|
||||
eventOptionId: line.eventOptionId,
|
||||
...(line.variantId ? { variantId: line.variantId } : {}),
|
||||
...(line.sessionId ? { sessionId: line.sessionId } : {}),
|
||||
quantity: qty,
|
||||
...(!loggedIn ? { guestName: guest.name.trim(), guestEmail: guest.email.trim(), guestPhone: guest.phone.trim() || undefined } : {}),
|
||||
},
|
||||
@@ -124,5 +125,5 @@ export function JoinWaitlistButton({ eventId, lines, guestsAllowed, initialLine,
|
||||
}
|
||||
|
||||
function keyOf(l?: WaitlistLine) {
|
||||
return l ? `${l.eventOptionId}::${l.variantId || ""}` : "";
|
||||
return l ? `${l.eventOptionId}::${l.variantId || ""}::${l.sessionId || ""}` : "";
|
||||
}
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
import React from "react";
|
||||
import type { Event } from "@/types";
|
||||
import { bookableSessions, formatSessionWhen, sessionLabel } from "@/lib/sessions";
|
||||
import { JoinWaitlistButton } from "@/components/events/JoinWaitlistButton";
|
||||
|
||||
// Tick boxes for the sessions of a "pick sessions" ticket. Full sessions (or ones with
|
||||
// fewer places than `quantity`) can't be ticked.
|
||||
export function SessionPicker({ event, option, selected, onChange, quantity = 1, staff = false, unitPrice }: {
|
||||
// fewer places than `quantity`) can't be ticked; with `waitlist`, they get a "Join
|
||||
// waitlist" button for that session instead.
|
||||
export function SessionPicker({ event, option, selected, onChange, quantity = 1, staff = false, unitPrice, waitlist }: {
|
||||
event: Pick<Event, "sessions">;
|
||||
option: { id: string; sessionAvailability?: Record<string, number> };
|
||||
selected: string[];
|
||||
@@ -14,6 +16,7 @@ export function SessionPicker({ event, option, selected, onChange, quantity = 1,
|
||||
quantity?: number;
|
||||
staff?: boolean;
|
||||
unitPrice?: number;
|
||||
waitlist?: { eventId: string; guestsAllowed: boolean; variantId?: string | null; label: string } | null;
|
||||
}) {
|
||||
const sessions = bookableSessions(event, option, staff);
|
||||
if (sessions.length === 0) return <p className="text-xs text-gray-500 mt-2">No sessions left to book.</p>;
|
||||
@@ -29,13 +32,20 @@ export function SessionPicker({ event, option, selected, onChange, quantity = 1,
|
||||
</div>
|
||||
{sessions.map(s => {
|
||||
const full = s.left !== null && s.left < Math.max(1, quantity);
|
||||
const name = sessionLabel(s, event.sessions);
|
||||
return (
|
||||
<label key={s.id} className={`flex items-center gap-2 rounded border px-2 py-1.5 text-sm ${full ? "bg-gray-50 text-gray-400" : selected.includes(s.id) ? "border-brand-300 bg-brand-50" : "hover:bg-gray-50"}`}>
|
||||
<input type="checkbox" disabled={full && !selected.includes(s.id)} checked={selected.includes(s.id)} onChange={() => toggle(s.id)} />
|
||||
<span className="font-medium">{sessionLabel(s, event.sessions)}</span>
|
||||
<span className="text-gray-500">{formatSessionWhen(s)}</span>
|
||||
<span className="ml-auto text-xs">{s.left === null ? "" : s.left <= 0 ? "Full" : `${s.left} left`}</span>
|
||||
</label>
|
||||
<div key={s.id} className={`flex items-center gap-2 rounded border px-2 py-1.5 text-sm ${full ? "bg-gray-50 text-gray-400" : selected.includes(s.id) ? "border-brand-300 bg-brand-50" : "hover:bg-gray-50"}`}>
|
||||
<label className="flex items-center gap-2 flex-1 min-w-0">
|
||||
<input type="checkbox" disabled={full && !selected.includes(s.id)} checked={selected.includes(s.id)} onChange={() => toggle(s.id)} />
|
||||
<span className="font-medium">{name}</span>
|
||||
<span className="text-gray-500">{formatSessionWhen(s)}</span>
|
||||
<span className="ml-auto text-xs">{s.left === null ? "" : s.left <= 0 ? "Full" : `${s.left} left`}</span>
|
||||
</label>
|
||||
{full && waitlist && !selected.includes(s.id) && (
|
||||
<JoinWaitlistButton compact eventId={waitlist.eventId} guestsAllowed={waitlist.guestsAllowed}
|
||||
lines={[{ eventOptionId: option.id, variantId: waitlist.variantId, sessionId: s.id, label: `${waitlist.label} — ${name}, ${formatSessionWhen(s)}` }]} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
@@ -4,6 +4,7 @@ import React, { useCallback, useEffect, useState } from "react";
|
||||
import { ListChecks } from "lucide-react";
|
||||
import { apiFetch } from "@/lib/api";
|
||||
import { errorMessage } from "@/lib/utils";
|
||||
import { entryLineName } from "@/lib/waitlist";
|
||||
|
||||
type Entry = {
|
||||
id: string;
|
||||
@@ -14,6 +15,7 @@ type Entry = {
|
||||
event: { id: string; title: string; startDate: string };
|
||||
eventOption: { name: string };
|
||||
variant: { name: string } | null;
|
||||
session: { label: string | null; startsAt: string } | null;
|
||||
};
|
||||
|
||||
/** My Events: the waitlists I'm on, with Leave (and a note when a place is on offer). */
|
||||
@@ -46,7 +48,7 @@ export function MyWaitlists({ token, onMessage }: { token: string; onMessage: (m
|
||||
<li key={e.id} className="py-2 flex items-center justify-between gap-3 text-sm">
|
||||
<div>
|
||||
<div className="font-medium">{e.event.title}</div>
|
||||
<div className="text-xs text-gray-500">{e.quantity} × {e.eventOption.name}{e.variant ? ` (${e.variant.name})` : ""}</div>
|
||||
<div className="text-xs text-gray-500">{e.quantity} × {entryLineName(e)}</div>
|
||||
{e.status === "offered" ? (
|
||||
<div className="text-xs text-green-700 mt-0.5">
|
||||
{e.offeredQuantity} place(s) held for you until {e.offerExpiresAt ? new Date(e.offerExpiresAt).toLocaleString() : ""} — use the link we sent you to claim.
|
||||
|
||||
@@ -43,6 +43,7 @@ export const supervisorAtTheDoorHelpContent: HelpContent = {
|
||||
<p>Selecting a registration automatically jumps to Payment mode if it's unpaid, or Check-in mode if it's already fully paid.</p>
|
||||
<p>When editing an existing registration's items, quantities can't be reduced below what's already been printed or paid for.</p>
|
||||
<p>The item picker has a "Have a code?" field for discount codes. On an existing registration the code is applied when you save.</p>
|
||||
<p>On events where people pick sessions, tick the sessions under a per-session ticket. For a new attendee, a place in today's session is selected for you when there's room. Sessions already booked on a registration can't be changed when editing it — book extra sessions as a new registration.</p>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
|
||||
@@ -38,7 +38,7 @@ export const supervisorEventsHelpContent: HelpContent = {
|
||||
Choose "Multiple sessions" for one event on several dates — e.g. every Wednesday 18:30–20:30 for 5 weeks. Use the repeat pattern to create the dates, then edit any of them, add a label ("Week 1 — …"), a different location, or an extra date. People register and pay once and get one ticket for every session. Cancel a session (e.g. a public holiday) rather than deleting it once people have been checked in. Registration closes when the first session starts unless you turn on late joining.
|
||||
</GuideItem>
|
||||
<GuideItem icon={CalendarDays} title="Pick sessions" tone="violet">
|
||||
For day passes or a drop-in class, set "How people book" to "Pick sessions", give sessions an optional capacity, and in Items & Pricing set a ticket to "Pick sessions (price per session)". People tick the sessions they want; each one is its own ticket. Whole-course tickets can still be sold too, until the course starts.
|
||||
For day passes or a drop-in class, set "How people book" to "Pick sessions", give sessions an optional capacity, and in Items & Pricing set a ticket to "Pick sessions (price per session)". People tick the sessions they want; each one is its own ticket. A ticket left on "All sessions" also shows the sessions to tick, but it's one ticket at one price — it then only scans on the sessions ticked.
|
||||
</GuideItem>
|
||||
<GuideItem icon={ListChecks} title="Items & pricing" tone="green">
|
||||
Ticket options and stock, variants of each option, and early-bird pricing tiers. An optional staff price is charged automatically to Staff and above when it's lower than the normal price.
|
||||
|
||||
@@ -19,13 +19,13 @@ export const supervisorWaitlistHelpContent: HelpContent = {
|
||||
In the event wizard's Visibility step, tick "Waitlist for sold-out tickets", set how long offered places are held (24 hours by default), and whether someone can be offered fewer places than they asked for.
|
||||
</GuideItem>
|
||||
<GuideItem icon={ListChecks} title="Joining" tone="green">
|
||||
When a ticket is sold out, the event and registration pages show "Join waitlist". People pick the ticket and how many, and can leave again from My Events.
|
||||
When a ticket is sold out, the event and registration pages show "Join waitlist". People pick the ticket and how many, and can leave again from My Events. On events where people pick sessions, the waitlist is per session: a full session shows "Join waitlist" in the session list, and the Ticket column shows which session someone is waiting for.
|
||||
</GuideItem>
|
||||
<GuideItem icon={Send} title="Offers" tone="violet">
|
||||
When places free up — a cancellation, a smaller booking, or a higher stock limit — the next person in line is emailed or WhatsApped a claim link. The places are held for them, so nobody else can buy them in the meantime.
|
||||
</GuideItem>
|
||||
<GuideItem icon={Clock} title="Expiry" tone="amber">
|
||||
If the offer isn't claimed in time, it expires and the places go to the next person. Claiming goes through normal registration and payment, with early-bird and coupon rules as usual.
|
||||
If the offer isn't claimed in time, it expires and the places go to the next person. An offer for a session never runs past the session's start. Claiming goes through normal registration and payment, with early-bird and coupon rules as usual.
|
||||
</GuideItem>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -174,6 +174,14 @@ export function todaysSession(event: Pick<Event, "scheduleType" | "sessions"> |
|
||||
return list.find(s => now <= new Date(s.endsAt).getTime()) || list[list.length - 1] || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether people tick sessions when booking this event ("pick sessions" attendance).
|
||||
* Every ticket shows the sessions; only per-session tickets are charged per session.
|
||||
*/
|
||||
export function choosesSessions(event: Pick<Event, "scheduleType" | "attendanceMode"> | null | undefined): boolean {
|
||||
return event?.scheduleType === "sessions" && event?.attendanceMode === "pick";
|
||||
}
|
||||
|
||||
/** Whether an option is bought per session (only in "pick sessions" events). */
|
||||
export function isPickOption(event: Pick<Event, "scheduleType" | "attendanceMode"> | null | undefined, option: { sessionMode?: "all" | "pick" } | null | undefined): boolean {
|
||||
return event?.scheduleType === "sessions" && event?.attendanceMode === "pick" && option?.sessionMode === "pick";
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
// Pure helpers shared by server and client components. Must not be "use client",
|
||||
// or server pages calling these get a client reference instead of the function.
|
||||
|
||||
export type WaitlistLine = { eventOptionId: string; variantId?: string | null; label: string };
|
||||
// sessionId: one session of a "pick sessions" option (those are waited for per session).
|
||||
export type WaitlistLine = { eventOptionId: string; variantId?: string | null; sessionId?: string | null; label: string };
|
||||
|
||||
/** "Drop-in (Adult)" or "Drop-in — Class 2, Wed 4 Nov" for a waitlist entry. */
|
||||
export function entryLineName(e: { eventOption: { name: string }; variant?: { name: string } | null; session?: { label?: string | null; startsAt: string } | null }): string {
|
||||
const base = `${e.eventOption.name}${e.variant ? ` (${e.variant.name})` : ""}`;
|
||||
if (!e.session) return base;
|
||||
const when = new Date(e.session.startsAt).toLocaleDateString(undefined, { weekday: "short", day: "numeric", month: "short" });
|
||||
return `${base} — ${e.session.label ? `${e.session.label}, ` : ""}${when}`;
|
||||
}
|
||||
|
||||
/** The sold-out lines of an event, for the waitlist button. */
|
||||
export function soldOutLines(options: { id: string; name: string; stockLimit?: number; availableCount?: number | null; variants?: { id: string; name: string; stockLimit?: number; availableCount?: number | null }[] | null }[]): WaitlistLine[] {
|
||||
|
||||
Reference in New Issue
Block a user