Pick sessions (frontend), roadmap and handover docs
Event wizard: how people book (whole course / pick sessions), capacity per session and per-option session mode. Session picker on the public registration page, Manual registration and the kiosk; at the door points to Manual registration. Register, tickets and My Events handle picked sessions. Adds docs/ROADMAP-v2.md and docs/HANDOVER.md so work can carry on from another machine, and a pick-sessions e2e test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,7 +8,9 @@ import { CouponCodeField, AppliedCoupon } from "@/components/shared/CouponCodeFi
|
||||
import { BundleBuilder, BundleOffers, BundleSavings, useBundleQuote } from "@/components/shared/BundleDeals";
|
||||
import { AttendeeNamesEditor, AttendeeEntries, TicketDelivery, attendeesPayload, consentDetailsMissing } from "@/components/shared/AttendeeNamesEditor";
|
||||
import { errorMessage } from "@/lib/utils";
|
||||
import type { PublicBundle, Registration } from "@/types";
|
||||
import type { Event, PublicBundle, Registration } from "@/types";
|
||||
import { isPickOption } from "@/lib/sessions";
|
||||
import { SessionPicker } from "@/components/events/SessionPicker";
|
||||
|
||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||
type EarlyBirdTier = { deadline: string; price: number; order?: number; variantId?: string | null };
|
||||
@@ -209,25 +211,41 @@ export default function SelfServicePage() {
|
||||
[events, selectedEventId]
|
||||
);
|
||||
|
||||
// The events list doesn't carry bundle deals or places per session; the single-event
|
||||
// response does.
|
||||
const [kioskFull, setKioskFull] = useState<Event | null>(null);
|
||||
useEffect(() => {
|
||||
if (!selectedEventId) { setKioskBundles([]); setKioskFull(null); return; }
|
||||
let cancelled = false;
|
||||
apiFetch<Event>(`/api/events/${selectedEventId}`, { authToken: supervisorToken || undefined })
|
||||
.then(ev => { if (!cancelled) { setKioskBundles(ev?.bundles || []); setKioskFull(ev || null); } })
|
||||
.catch(() => { if (!cancelled) { setKioskBundles([]); setKioskFull(null); } });
|
||||
return () => { cancelled = true; };
|
||||
}, [selectedEventId, supervisorToken]);
|
||||
|
||||
// "Pick sessions" options: the sessions chosen per quantity key.
|
||||
const [picks, setPicks] = useState<Record<string, string[]>>({});
|
||||
useEffect(() => { setPicks({}); }, [selectedEventId]);
|
||||
const pickOpt = (optionId: string) => {
|
||||
const o = (kioskFull?.eventOptions || []).find(x => x.id === optionId);
|
||||
return kioskFull && o && isPickOption(kioskFull, o) ? 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 total = useMemo(() => {
|
||||
if (!selectedEvent) return 0;
|
||||
return (selectedEvent.eventOptions || []).reduce((sum, o) => {
|
||||
if ((o.variants || []).length > 0) {
|
||||
return sum + (o.variants || []).reduce((vs, v) => vs + (quantities[`${o.id}::${v.id}`] || 0) * effectiveVariantUnit(o, v), 0);
|
||||
return sum + (o.variants || []).reduce((vs, v) => vs + (quantities[`${o.id}::${v.id}`] || 0) * times(`${o.id}::${v.id}`) * effectiveVariantUnit(o, v), 0);
|
||||
}
|
||||
return sum + (quantities[o.id] || 0) * effectiveUnit(o);
|
||||
return sum + (quantities[o.id] || 0) * times(o.id) * effectiveUnit(o);
|
||||
}, 0);
|
||||
}, [selectedEvent, quantities]);
|
||||
|
||||
// The events list doesn't carry bundle deals; the single-event response does.
|
||||
useEffect(() => {
|
||||
if (!selectedEventId) { setKioskBundles([]); return; }
|
||||
let cancelled = false;
|
||||
apiFetch<{ bundles?: PublicBundle[] }>(`/api/events/${selectedEventId}`, { authToken: supervisorToken || undefined })
|
||||
.then(ev => { if (!cancelled) setKioskBundles(ev?.bundles || []); })
|
||||
.catch(() => { if (!cancelled) setKioskBundles([]); });
|
||||
return () => { cancelled = true; };
|
||||
}, [selectedEventId, supervisorToken]);
|
||||
}, [selectedEvent, quantities, picks, kioskFull]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
const kioskBasket = useMemo(() => Object.entries(quantities).map(([key, quantity]) => {
|
||||
const [eventOptionId, variantId] = key.split("::");
|
||||
@@ -438,7 +456,7 @@ export default function SelfServicePage() {
|
||||
.filter(([, qty]) => qty > 0)
|
||||
.map(([key, quantity]) => {
|
||||
const [eventOptionId, variantId] = key.split("::");
|
||||
return { eventOptionId, quantity, ...(variantId ? { variantId } : {}) };
|
||||
return { eventOptionId, quantity, ...(variantId ? { variantId } : {}), ...(pickOpt(eventOptionId) ? { sessionIds: picks[key] || [] } : {}) };
|
||||
}),
|
||||
user,
|
||||
// If the visitor declined to create an account, don't push an unsolicited
|
||||
@@ -973,7 +991,8 @@ export default function SelfServicePage() {
|
||||
const baseVariantPrice = v.price !== null && v.price !== undefined ? v.price : opt.price;
|
||||
const key = `${opt.id}::${v.id}`;
|
||||
return (
|
||||
<div key={v.id} className="flex items-center justify-between px-4 py-3">
|
||||
<div key={v.id}>
|
||||
<div className="flex items-center justify-between px-4 py-3">
|
||||
<div>
|
||||
<p className="text-gray-800">{v.name}</p>
|
||||
<p className="text-sm text-gray-500">
|
||||
@@ -999,6 +1018,8 @@ export default function SelfServicePage() {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{picker(key, opt.id) && <div className="px-4 pb-3">{picker(key, opt.id)}</div>}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
@@ -1007,7 +1028,8 @@ export default function SelfServicePage() {
|
||||
}
|
||||
const unit = effectiveUnit(opt);
|
||||
return (
|
||||
<div key={opt.id} className="flex items-center justify-between border border-gray-200 rounded-xl px-4 py-3.5">
|
||||
<div key={opt.id} className="border border-gray-200 rounded-xl px-4 py-3.5">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<p className="font-medium text-gray-800">{opt.name}</p>
|
||||
<p className="text-sm text-gray-500">{fmtCurrency(unit)}{unit !== opt.price && opt.price > 0 ? ` (was ${fmtCurrency(opt.price)})` : ""}</p>
|
||||
@@ -1030,6 +1052,8 @@ export default function SelfServicePage() {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{picker(opt.id, opt.id)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user