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:
@@ -22,6 +22,7 @@ export type SessionDraft = {
|
||||
endsAt: string;
|
||||
location: string;
|
||||
cancelled: boolean;
|
||||
capacity: string; // "pick sessions" events; blank = no limit
|
||||
hasCheckIns?: boolean;
|
||||
};
|
||||
|
||||
@@ -54,7 +55,7 @@ export function generateSessions(p: SessionPattern): SessionDraft[] {
|
||||
const start = atTime(day, p.startTime);
|
||||
let end = atTime(day, p.endTime);
|
||||
if (end <= start) end = new Date(end.getTime() + 24 * 60 * 60 * 1000);
|
||||
out.push({ label: "", startsAt: localDT(start), endsAt: localDT(end), location: "", cancelled: false });
|
||||
out.push({ label: "", startsAt: localDT(start), endsAt: localDT(end), location: "", cancelled: false, capacity: "" });
|
||||
};
|
||||
|
||||
if (p.frequency === "daily") {
|
||||
@@ -83,7 +84,7 @@ export function generateSessions(p: SessionPattern): SessionDraft[] {
|
||||
}
|
||||
|
||||
export function toSessionDraft(s: EventSession & { hasCheckIns?: boolean }): SessionDraft {
|
||||
return { id: s.id, label: s.label || "", startsAt: localDT(new Date(s.startsAt)), endsAt: localDT(new Date(s.endsAt)), location: s.location || "", cancelled: !!(s.cancelled || s.cancelledAt), hasCheckIns: s.hasCheckIns };
|
||||
return { id: s.id, label: s.label || "", startsAt: localDT(new Date(s.startsAt)), endsAt: localDT(new Date(s.endsAt)), location: s.location || "", cancelled: !!(s.cancelled || s.cancelledAt), capacity: s.capacity ? String(s.capacity) : "", hasCheckIns: s.hasCheckIns };
|
||||
}
|
||||
|
||||
/** Sessions that aren't cancelled, earliest first. */
|
||||
@@ -172,3 +173,22 @@ export function todaysSession(event: Pick<Event, "scheduleType" | "sessions"> |
|
||||
const list = activeSessions(event.sessions).filter(x => new Date(x.startsAt).toDateString() === today);
|
||||
return list.find(s => now <= new Date(s.endsAt).getTime()) || list[list.length - 1] || null;
|
||||
}
|
||||
|
||||
/** 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";
|
||||
}
|
||||
|
||||
/**
|
||||
* Sessions a pick option can still be booked for, with places left (null = no limit).
|
||||
* Public: before the session starts; staff: until it ends.
|
||||
*/
|
||||
export function bookableSessions(event: Pick<Event, "sessions">, option: { sessionAvailability?: Record<string, number> }, staff = false): (EventSession & { left: number | null })[] {
|
||||
const now = Date.now();
|
||||
return activeSessions(event.sessions)
|
||||
.filter(s => new Date(staff ? s.endsAt : s.startsAt).getTime() > now)
|
||||
.map(s => {
|
||||
const limits = [s.placesLeft, option.sessionAvailability?.[s.id]].filter((n): n is number => typeof n === "number");
|
||||
return { ...s, left: limits.length ? Math.min(...limits) : null };
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Ticket as TicketRecord } from "@/types";
|
||||
import { formatDate } from "@/lib/date";
|
||||
import { scheduleSummary } from "@/lib/sessions";
|
||||
import { formatSessionWhen, scheduleSummary } from "@/lib/sessions";
|
||||
|
||||
// One ticket design for every printed ticket (user dashboard, staff event tickets, at the
|
||||
// door). The emailed/WhatsApp PDF in backend/src/controllers/ticketController.js mirrors it.
|
||||
@@ -18,8 +18,12 @@ export function ticketTypeLabel(t: TicketRecord): string {
|
||||
/** A ticket card. `buyerName` adds a "Purchased by" line. */
|
||||
export function ticketCardHtml(t: TicketRecord, buyerName?: string | null): string {
|
||||
const eventTitle = t.event?.title || t.eventId || "Event";
|
||||
// Multi-day events: "5 sessions · Wed 4 Nov – Wed 2 Dec" — one ticket for every session.
|
||||
const dateStr = (t.event && scheduleSummary(t.event)) || (t.event?.startDate ? formatDate(t.event.startDate) : "");
|
||||
// Multi-day events: "5 sessions · Wed 4 Nov – Wed 2 Dec" — one ticket for every session;
|
||||
// a picked-session ticket shows its own session.
|
||||
const session = t.registrationOption?.session;
|
||||
const dateStr = session
|
||||
? `${session.label || "Session"} · ${formatSessionWhen(session)}`
|
||||
: (t.event && scheduleSummary(t.event)) || (t.event?.startDate ? formatDate(t.event.startDate) : "");
|
||||
const qrSrc = `https://api.qrserver.com/v1/create-qr-code/?size=320x320&data=${encodeURIComponent(t.qrCode || t.id)}`;
|
||||
return `
|
||||
<div class="ticket">
|
||||
|
||||
Reference in New Issue
Block a user