# Campus Attendance Frontend Integration

## Purpose

Campus attendance config and daily aggregate summaries follow the frontend three-layer architecture.

```text
View -> Business Logic -> API/Data Access -> Backend
```

## Files

View layer:

- `frontend/src/components/frameworks/CampusAttendance.tsx`
- `frontend/src/components/campus-attendance/AttendanceSummaryCard.tsx`
- `frontend/src/components/campus-attendance/CampusAttendanceEntryForm.tsx`
- `frontend/src/components/campus-attendance/CampusAttendanceHeader.tsx`
- `frontend/src/components/campus-attendance/CampusAttendanceLinkConfig.tsx`
- `frontend/src/components/campus-attendance/CampusAttendanceStatus.tsx`
- `frontend/src/components/campus-attendance/IndividualCampusAttendanceView.tsx`
- `frontend/src/components/campus-attendance/SuperintendentAttendanceView.tsx`
- `frontend/src/components/campus-attendance/styles.ts`
- `frontend/src/components/campus-attendance/types.ts`

Business logic layer:

- `frontend/src/business/campus-attendance/hooks.ts`
- `frontend/src/business/campus-attendance/mappers.ts`
- `frontend/src/business/campus-attendance/printReport.ts`
- `frontend/src/business/campus-attendance/selectors.ts`
- `frontend/src/business/campus-attendance/types.ts`

API/data access layer:

- `frontend/src/shared/api/campusAttendance.ts`
- `frontend/src/shared/types/campusAttendance.ts`
- `frontend/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`.
- Daily campus summaries load from `GET /api/campus_attendance/summaries`.
- Daily campus summaries save through `PUT /api/campus_attendance/summaries/:campusKey/:date`.
- The backend calculates the attendance percentage.
- `CampusAttendance.tsx` is a thin composition wrapper.
- CampusAttendance uses typed business hooks/selectors for role access, form state, today, weekly, campus, overall 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.ts` covers attendance calculations and summary selectors.
- `frontend/src/business/campus-attendance/printReport.test.ts` covers printable report generation.
- `frontend/src/business/campus-attendance/printReport.test.ts` covers blocked-popup handling for attendance report printing.
- `frontend/src/business/campus-attendance/mappers.test.ts` covers API DTO mapping.
