40227-vm/frontend/docs/policies-integration.md
Dmitri d4a5378adf Refactor: migrate frontend to Vite/React, add product backend modules
Frontend:
- Replace Next.js with Vite + React + TypeScript
- Add new component architecture (app-shell, sidebar, dashboard modules)
- Implement product modules: FRAME, safety protocols, walkthrough checkin,
  campus/staff attendance, personality quiz, sign language, classroom timer
- Add shadcn/ui component library with Tailwind CSS
- Remove legacy generated components, stores, and pages

Backend:
- Add product migrations: frame_entries, user_progress, safety_quiz_results,
  walkthrough_checkins, communication_events, personality_quiz_results,
  campus_attendance_config/summaries, staff_attendance_records, content_catalog
- Add corresponding models, services, and routes
- Implement cookie-based auth with refresh token rotation
- Add content catalog seeder with product content
- Migrate to ESLint flat config
- Switch from yarn to npm

Infrastructure:
- Update .gitignore for new tooling
- Add project documentation (CLAUDE.md, docs/)
- Remove deprecated config files and yarn.lock

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-06-09 15:18:23 +02:00

2.0 KiB

Policies Integration

Purpose

The handbook and policies workflow reads and mutates policy documents through the backend documents API.

Frontend Structure

  • Framework wrapper: frontend/src/components/frameworks/HandbookPolicy.tsx
  • Focused view components: frontend/src/components/policies/
  • Business hooks: frontend/src/business/policies/hooks.ts
  • Business page workflow hook: frontend/src/business/policies/pageHooks.ts
  • Business mappers: frontend/src/business/policies/mappers.ts
  • Business selectors: frontend/src/business/policies/selectors.ts
  • API layer: frontend/src/shared/api/documents.ts
  • DTO types: frontend/src/shared/types/documents.ts
  • Policy types/constants: frontend/src/shared/types/policies.ts, frontend/src/shared/constants/policies.ts

Backend Contract

The slice uses the existing backend route:

  • GET /api/documents?category=policy
  • POST /api/documents
  • PUT /api/documents/:id
  • DELETE /api/documents/:id

Policy records are represented as documents rows:

  • category: fixed to policy
  • entity_type: fixed to organization
  • entity_reference: policy category displayed in the handbook
  • name: policy title
  • notes: policy content
  • uploaded_at: recorded mutation timestamp

Behavior

  • HandbookPolicy is a thin wrapper that calls usePoliciesPage and renders PoliciesView.
  • Policy UI is split into focused components for the hero, create form, filters, status panels, list, cards, and empty state.
  • Policy forms and filters use shared UI primitives: Button, Input, Textarea, NativeSelect, and StatePanel.
  • Policy list/create/update/delete flows use React Query hooks and backend error states.
  • Director and superintendent roles can manage policies in the frontend.
  • Acknowledgement state remains session-local because the backend does not yet expose a policy acknowledgement contract.

Verification

  • npm run build passes.
  • npm run lint passes for the current frontend baseline.
  • npm run typecheck passes.
  • npm run test passes.