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:
@@ -115,7 +115,7 @@ function PatternBuilder({ onGenerate }: { onGenerate: (rows: SessionDraft[], mod
|
||||
);
|
||||
}
|
||||
|
||||
export function SessionsEditor({ sessions, onChange, defaultLocation }: { sessions: KeyedSession[]; onChange: (s: KeyedSession[]) => void; defaultLocation?: string }) {
|
||||
export function SessionsEditor({ sessions, onChange, defaultLocation, showCapacity }: { sessions: KeyedSession[]; onChange: (s: KeyedSession[]) => void; defaultLocation?: string; showCapacity?: boolean }) {
|
||||
const [showPattern, setShowPattern] = useState(sessions.length === 0);
|
||||
const sorted = sortSessions(sessions);
|
||||
const activeCount = sessions.filter(s => !s.cancelled).length;
|
||||
@@ -137,7 +137,7 @@ export function SessionsEditor({ sessions, onChange, defaultLocation }: { sessio
|
||||
const start = new Date(base.getTime() + (last ? 7 * 24 * 60 * 60 * 1000 : 0));
|
||||
const p = (n: number) => String(n).padStart(2, "0");
|
||||
const fmt = (d: Date) => `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())}T${p(d.getHours())}:${p(d.getMinutes())}`;
|
||||
onChange([...sessions, keyed({ label: "", startsAt: fmt(start), endsAt: fmt(new Date(start.getTime() + dur)), location: "", cancelled: false })]);
|
||||
onChange([...sessions, keyed({ label: "", startsAt: fmt(start), endsAt: fmt(new Date(start.getTime() + dur)), location: "", cancelled: false, capacity: last?.capacity || "" })]);
|
||||
};
|
||||
|
||||
let position = 0;
|
||||
@@ -180,7 +180,7 @@ export function SessionsEditor({ sessions, onChange, defaultLocation }: { sessio
|
||||
)}
|
||||
</div>
|
||||
{!s.cancelled && (
|
||||
<div className="grid sm:grid-cols-3 gap-2 pl-8">
|
||||
<div className={`grid gap-2 pl-8 ${showCapacity ? "sm:grid-cols-4" : "sm:grid-cols-3"}`}>
|
||||
<label className="text-[11px] text-gray-500">Starts
|
||||
<input type="datetime-local" className="mt-0.5 w-full border rounded px-2 py-1 text-sm" value={s.startsAt} onChange={e => {
|
||||
const v = e.target.value;
|
||||
@@ -197,6 +197,11 @@ export function SessionsEditor({ sessions, onChange, defaultLocation }: { sessio
|
||||
<label className="text-[11px] text-gray-500">Location (optional)
|
||||
<input className="mt-0.5 w-full border rounded px-2 py-1 text-sm" placeholder={defaultLocation || "Event location"} value={s.location} onChange={e => update(s.key, { location: e.target.value })} />
|
||||
</label>
|
||||
{showCapacity && (
|
||||
<label className="text-[11px] text-gray-500" title="Most people at this session (picked places plus whole-course tickets). Blank = no limit.">Capacity
|
||||
<input type="number" min={1} className="mt-0.5 w-full border rounded px-2 py-1 text-sm" placeholder="No limit" value={s.capacity} onChange={e => update(s.key, { capacity: e.target.value })} />
|
||||
</label>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{s.hasCheckIns && <p className="pl-8 text-[10px] text-gray-400">Has check-ins — it can be cancelled but not removed.</p>}
|
||||
|
||||
@@ -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