Archived
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:
@@ -0,0 +1,43 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import type { Event } from "@/types";
|
||||
import { bookableSessions, formatSessionWhen, sessionLabel } from "@/lib/sessions";
|
||||
|
||||
// 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 }: {
|
||||
event: Pick<Event, "sessions">;
|
||||
option: { id: string; sessionAvailability?: Record<string, number> };
|
||||
selected: string[];
|
||||
onChange: (ids: string[]) => void;
|
||||
quantity?: number;
|
||||
staff?: boolean;
|
||||
unitPrice?: number;
|
||||
}) {
|
||||
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>;
|
||||
const toggle = (id: string) => onChange(selected.includes(id) ? selected.filter(x => x !== id) : [...selected, id]);
|
||||
const allOpen = sessions.filter(s => s.left === null || s.left >= Math.max(1, quantity)).map(s => s.id);
|
||||
return (
|
||||
<div className="mt-2 space-y-1" role="group" aria-label="Choose sessions">
|
||||
<div className="flex items-center justify-between text-xs text-gray-500">
|
||||
<span>Choose your sessions{unitPrice !== undefined ? ` — R${unitPrice.toFixed(2)} each` : ""}</span>
|
||||
<button type="button" className="text-brand-700 hover:underline" onClick={() => onChange(selected.length === allOpen.length ? [] : allOpen)}>
|
||||
{selected.length === allOpen.length && allOpen.length > 0 ? "Clear" : "Select all"}
|
||||
</button>
|
||||
</div>
|
||||
{sessions.map(s => {
|
||||
const full = s.left !== null && s.left < Math.max(1, quantity);
|
||||
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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user