Volunteer rosters: serving, roster and check-in pages, help, e2e
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { apiFetch } from "@/lib/api";
|
||||
import { errorMessage } from "@/lib/utils";
|
||||
import { QrImage } from "@/components/shared/QrImage";
|
||||
import { Printer } from "lucide-react";
|
||||
import { checkInUrl } from "@/lib/volunteers";
|
||||
|
||||
/** The event's volunteer check-in QR code, to show on a screen or print and put up at the venue. */
|
||||
export function CheckInQr({ token, eventId, title }: { token: string | null; eventId: string; title: string }) {
|
||||
const [qr, setQr] = useState<string | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!token || !eventId) return;
|
||||
setQr(null);
|
||||
apiFetch<{ qr: string }>(`/api/volunteers/manage/events/${eventId}/qr`, { authToken: token })
|
||||
.then(r => setQr(r.qr))
|
||||
.catch(e => setError(errorMessage(e) || "Could not load the QR code"));
|
||||
}, [token, eventId]);
|
||||
|
||||
if (error) return <div className="p-3 border rounded bg-red-50 text-red-800 text-sm">{error}</div>;
|
||||
return (
|
||||
<div className="border rounded-xl p-6 bg-white shadow-sm text-center space-y-3">
|
||||
<h2 className="text-xl font-semibold">Volunteers: check in here</h2>
|
||||
<p className="text-sm text-gray-600">{title}</p>
|
||||
{qr ? <QrImage value={checkInUrl(qr)} size={320} alt="Volunteer check-in QR code" className="mx-auto w-64 h-64" /> : <div className="mx-auto w-64 h-64 bg-gray-100 animate-pulse" />}
|
||||
<p className="text-sm text-gray-700">Scan with your phone's camera and log in — you're checked in for your shifts today.</p>
|
||||
<button onClick={() => window.print()} className="print:hidden px-3 py-1.5 rounded-lg border text-sm inline-flex items-center gap-1"><Printer className="w-4 h-4" /> Print</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user