import { useEffect, useMemo, useState } from 'react' import { fetchBadgeScanningList, type AttendanceManagementDashboard, } from '../../api/attendanceManagement' import { ApiHttpError } from '../../api/http' const today = new Date().toISOString().slice(0, 10) function nice(value: string | null | undefined): string { if (!value) return '—' return value.replace(/_/g, ' ') } export function BadgeScanningListPage() { const [date, setDate] = useState(today) const [status, setStatus] = useState('') const [q, setQ] = useState('') const [dashboard, setDashboard] = useState(null) const [loading, setLoading] = useState(false) const [error, setError] = useState(null) const params = useMemo( () => ({ date, attendance_status: status, q, }), [date, status, q], ) async function load() { setLoading(true) setError(null) try { setDashboard(await fetchBadgeScanningList(params)) } catch (e) { setError(e instanceof ApiHttpError ? e.message : 'Unable to load badge scanning list.') } finally { setLoading(false) } } useEffect(() => { void load() }, [params]) const rows = dashboard?.rows ?? [] return (

Badge Scanning List

Students, staff, contractors, and visitors recorded through badge scan.

{error ?
{error}
: null}
setDate(e.target.value)} />
setQ(e.target.value)} placeholder="Name, badge, grade, department" />

Scanned Badge Records

{rows.length} records
{rows.map((row) => ( ))} {!loading && rows.length === 0 ? ( ) : null} {loading ? ( ) : null}
Name Type Grade/Dept Badge ID Date Scan Time Location Status Reported Decision
{row.person_name || '—'} {nice(row.person_type)} {row.role_grade || '—'} {row.badge_id || '—'} {row.event_date} {row.official_entry_time || row.official_exit_time || '—'} {row.scan_location || row.exit_location || '—'} {nice(row.attendance_status)} {nice(row.report_status)} {row.final_decision || '—'}
No badge scans found for this filter.
Loading badge scans...
) }