5.6 KiB
5.6 KiB
Campus Attendance Frontend Integration
Purpose
Attendance now tracks staff attendance only. The page still reads legacy campus
attendance config/summary endpoints where existing report plumbing requires
them, but visible entry, rollups, details, and dashboard-facing metrics use
staff_attendance_records.
View -> Business Logic -> API/Data Access -> Backend
Files
View layer:
frontend/src/components/frameworks/CampusAttendance.tsxfrontend/src/components/campus-attendance/AttendanceSummaryCard.tsxfrontend/src/components/campus-attendance/CampusAttendanceEntryForm.tsxfrontend/src/components/campus-attendance/CampusAttendanceHeader.tsxfrontend/src/components/campus-attendance/CampusAttendanceLinkConfig.tsxfrontend/src/components/campus-attendance/CampusAttendanceStatus.tsxfrontend/src/components/campus-attendance/IndividualCampusAttendanceView.tsxfrontend/src/components/campus-attendance/SuperintendentAttendanceView.tsxfrontend/src/components/campus-attendance/styles.tsfrontend/src/components/campus-attendance/types.ts
Business logic layer:
frontend/src/business/campus-attendance/hooks.tsfrontend/src/business/campus-attendance/mappers.tsfrontend/src/business/campus-attendance/printReport.tsfrontend/src/business/campus-attendance/selectors.tsfrontend/src/business/campus-attendance/types.ts
API/data access layer:
frontend/src/shared/api/campusAttendance.tsfrontend/src/shared/api/staffAttendance.ts(staff summary and office/staff attendance entry)frontend/src/shared/types/campusAttendance.tsfrontend/src/shared/constants/campusAttendance.ts
Behavior
- Attendance links load from
GET /api/campus_attendance/configs. - Attendance links save through
PUT /api/campus_attendance/configs/:campusKey. - The active UI no longer reads or writes
GET /api/campus_attendance/summaries; those backend endpoints remain legacy plumbing outside the staff-only attendance workflow. - Staff attendance records load from
GET /api/staff_attendance/recordswhen the user hasREAD_STAFF_ATTENDANCE_REPORTS. Campus views group these records by campus and date. - The page derives its mode from the effective scope, not from the signed-in role label:
- campus effective scope shows campus staff attendance.
- class effective scope is read-only for attendance entry.
- school effective scope aggregates scoped campus staff attendance plus school staff attendance.
- organization effective scope aggregates scoped school/campus staff attendance plus organization staff attendance.
- Users with
FILL_ATTENDANCEcan enter daily staff attendance from organization, school, or campus effective scope. Class effective scope no longer renders attendance entry controls. - Organization office attendance targets organization-owned users without school/campus assignment. School office attendance targets school-owned users without campus assignment. Campus attendance targets campus-bound and class-scoped staff inside the campus.
- School and organization percentage cards use staff attendance only. Campus attendance entered by office managers appears in school-level rollups; school-level staff attendance appears in organization-level rollups with staff records from other schools and campuses.
- The top-bar notification uses the current staff summary as a completion signal. Users with
FILL_ATTENDANCEorREAD_STAFF_ATTENDANCE_REPORTSare nudged at organization, school, or campus effective scope until today's staff attendance record count reaches the current scope's staff count. Class effective scope does not receive this attendance reminder. - Aggregate cards follow the tenant hierarchy: organization scope shows school cards, and school
scope shows campus cards. Clicking a child card opens
/attendance/details/:level/:tenantId. The details page shows staff attendance records for that child scope. - Each staff row has Present/Late/Absent controls, and saving writes one record per user through
PUT /api/staff_attendance/records/:userId/:date. Late staff count as present for attendance percentage and remain visible as late exceptions. - Attendance page staff summary cards load from
GET /api/staff_attendance/summary?startDate=today&endDate=todaywhen the user hasREAD_STAFF_ATTENDANCE_REPORTS; the top-bar completion reminder uses the same summary endpoint for users withFILL_ATTENDANCEorREAD_STAFF_ATTENDANCE_REPORTS. - Campus screens show staff-only summary cards and recent staff attendance history.
- Aggregate views render only campus cards represented by scoped campus tenants or attendance config rows, because the campus catalog endpoint is not the source of scoped reporting data.
- The backend calculates the attendance percentage.
CampusAttendance.tsxis a thin composition wrapper.- CampusAttendance uses typed business hooks/selectors for access, form state, today, weekly staff rollups, campus summary calculations, and print report generation.
- Print report generation escapes dynamic strings before writing report HTML.
- Blocked print popups return an explicit print result and show a visible attendance status error.
Verification
frontend/src/business/campus-attendance/selectors.test.tscovers attendance calculations, scope titles, staff daily summaries, and staff-only summary selectors.frontend/src/business/campus-attendance/printReport.test.tscovers printable staff-attendance report generation and no-data labels.frontend/src/business/campus-attendance/printReport.test.tscovers blocked-popup handling for attendance report printing.frontend/src/business/campus-attendance/mappers.test.tscovers API DTO mapping.