"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(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("/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 (

Volunteers

Who's serving today, and checking them in

{events && !events.length &&
No events have volunteer rosters yet. A supervisor adds serving roles under Supervisor → Volunteer rosters.
} {events && events.length > 0 && (
{eventId && }
)} {msg &&
{msg.text}
}
{eventId && (showQr ? : )}
); }