40227-vm/frontend/docs/dashboard-integration.md
2026-06-12 10:56:13 +02:00

68 lines
2.9 KiB
Markdown

# Dashboard Integration
## Purpose
`Dashboard` composes current-user operational data from backend APIs and content catalog payloads through the three-layer frontend architecture.
```text
View -> Business Logic -> API/Data Access -> Backend
```
Runtime quote, compliance, sign-of-week, FRAME, communication event, and zone check-in data comes from backend-backed hooks. The frontend owns only UI state, navigation config, zone option styling, and presentation.
## Frontend Layers
View:
- `frontend/src/components/frameworks/Dashboard.tsx`
- `frontend/src/components/dashboard/DashboardView.tsx`
- `frontend/src/components/dashboard/DashboardHero.tsx`
- `frontend/src/components/dashboard/DashboardQuotePanel.tsx`
- `frontend/src/components/zone-checkin/ZoneCheckInCard.tsx`
- `frontend/src/components/dashboard/DashboardFramePreview.tsx`
- `frontend/src/components/dashboard/DashboardUpcomingEvents.tsx`
- `frontend/src/components/dashboard/DashboardWeeklyProgress.tsx`
- `frontend/src/components/dashboard/DashboardSignOfWeek.tsx`
- `frontend/src/components/dashboard/DashboardQuickActions.tsx`
Business logic:
- `frontend/src/business/dashboard/hooks.ts`
- `frontend/src/business/dashboard/selectors.ts`
- `frontend/src/business/dashboard/types.ts`
Shared contracts and UI config:
- `frontend/src/shared/types/dashboard.ts`
- `frontend/src/shared/constants/dashboard.ts`
- `frontend/src/shared/constants/contentCatalog.ts`
## Backend Contracts
Content catalog:
- `GET /api/public/content-catalog/dashboard-encouraging-quotes`
- `GET /api/public/content-catalog/dashboard-compliance-items`
- `GET /api/public/content-catalog/dashboard-sign-of-week`
Feature APIs:
- F.R.A.M.E. entries through `useFrameEntries`
- Communication events through `useCommunicationEvents`
- Current-user daily Emotional Zone check-in through `useTodayZoneCheckIn` (campus-staff roles only; see `zone-checkin-integration.md`)
## Behavior
- `useDashboardPage` composes all dashboard data sources into one page model.
- The hero's "Week of …" uses the shared American (Sunday-start) week util (`shared/business/week.ts`) — the same canonicalization as the F.R.A.M.E. week picker and the safety-quiz week.
- Selectors handle greeting calculation, day-based quote selection, zone normalization, event limiting, and role-filtered quick actions.
- View components receive prepared props and do not call API/data access modules.
- Loading, empty, and error states remain explicit for each dashboard section.
- The existing `Dashboard` props API is preserved while the framework component becomes a thin wrapper.
## Data Ownership Rules
- Do not add dashboard quote, compliance, sign-of-week, FRAME, event, or zone progress records to frontend constants.
- Keep frontend constants limited to quick-action navigation config, zone button style config, and display limits.
- Test-only fixtures may live in selector tests or `frontend/src/test-seeds/`.