Archived
- EventPicker replaces the plain event dropdowns on staff/supervisor pages and the kiosk:
upcoming first, past behind "Show past events", search across all, keyboard support.
- Reports events list can be searched ("Select these N").
- Site settings -> Webhooks: "How webhooks work" guide with headers, signature checking
(Node.js/PHP) and an example of every event type (EVENT_TYPES[].example, shape-tested).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ls1vMdg2GYqbnKZmPaX1ot
69 lines
3.4 KiB
TypeScript
69 lines
3.4 KiB
TypeScript
"use client";
|
|
|
|
import React, { useEffect, useState } from "react";
|
|
import { useAuth } from "@/hooks/useAuth";
|
|
import { apiFetch } from "@/lib/api";
|
|
import { errorMessage } from "@/lib/utils";
|
|
import { useDismissingState } from "@/hooks/useDismissingState";
|
|
import { BackLink } from "@/components/shared/BackLink";
|
|
import { RosterSheet } from "@/components/volunteers/RosterSheet";
|
|
import { CheckInQr } from "@/components/volunteers/CheckInQr";
|
|
import { HandHeart } from "lucide-react";
|
|
import type { RosterEvent } from "@/lib/volunteers";
|
|
import { EventPicker } from "@/components/shared/EventPicker";
|
|
|
|
/** Staff → Volunteers: the roster on the day — who's here, ticking people in, and the check-in QR code. */
|
|
export default function StaffVolunteersPage() {
|
|
const { token } = useAuth();
|
|
const [events, setEvents] = useState<RosterEvent[] | null>(null);
|
|
const [eventId, setEventId] = useState("");
|
|
const [showQr, setShowQr] = useState(false);
|
|
const [msg, setMsg] = useDismissingState<{ type: "ok" | "err"; text: string } | null>(null);
|
|
|
|
useEffect(() => {
|
|
if (!token) return;
|
|
apiFetch<RosterEvent[]>("/api/volunteers/manage/events", { authToken: token })
|
|
.then(list => {
|
|
setEvents(list);
|
|
const now = Date.now();
|
|
const current = list.find(e => new Date(e.endDate).getTime() >= now);
|
|
if (current) setEventId(current.id);
|
|
})
|
|
.catch(e => setMsg({ type: "err", text: errorMessage(e) || "Could not load events" }));
|
|
}, [token, setMsg]);
|
|
|
|
const event = events?.find(e => e.id === eventId);
|
|
|
|
return (
|
|
<div className="max-w-4xl mx-auto w-full p-6">
|
|
<div className="flex items-center gap-3 mb-4 print:hidden">
|
|
<div className="w-10 h-10 rounded-xl bg-brand-50 flex items-center justify-center shrink-0"><HandHeart className="w-5 h-5 text-brand-600" /></div>
|
|
<div>
|
|
<BackLink href="/dashboard" />
|
|
<h1 className="text-2xl font-semibold text-gray-900 mt-0.5">Volunteers</h1>
|
|
<p className="text-sm text-gray-500">Who's serving today, and checking them in</p>
|
|
</div>
|
|
</div>
|
|
|
|
{events && !events.length && <div className="p-3 border rounded bg-amber-50 text-amber-800 text-sm">No events have volunteer rosters yet. A supervisor adds serving roles under Supervisor → Volunteer rosters.</div>}
|
|
{events && events.length > 0 && (
|
|
<div className="flex flex-wrap gap-2 items-end print:hidden">
|
|
<div className="text-sm">
|
|
<label className="block text-xs text-gray-500 mb-1" htmlFor="staff-volunteers-event">Event</label>
|
|
<EventPicker id="staff-volunteers-event" className="w-full" events={events} value={eventId} onChange={setEventId} />
|
|
</div>
|
|
{eventId && <button onClick={() => setShowQr(q => !q)} className="px-3 py-2 rounded-lg border text-sm">{showQr ? "Show the roster" : "Show the check-in QR code"}</button>}
|
|
</div>
|
|
)}
|
|
|
|
{msg && <div role="status" className={`mt-3 p-3 rounded-lg text-sm print:hidden ${msg.type === "ok" ? "bg-green-50 text-green-800 border border-green-200" : "bg-red-50 text-red-800 border border-red-200"}`}>{msg.text}</div>}
|
|
|
|
<div className="mt-4">
|
|
{eventId && (showQr
|
|
? <CheckInQr token={token} eventId={eventId} title={event?.title || ""} />
|
|
: <RosterSheet token={token} eventId={eventId} canEdit={false} onMessage={setMsg} />)}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|