Assignment History Repository
Component Detail
Description
Data access layer for Blindeforbundet assignment records linked to a peer mentor. Fetches assigned contacts with their open/closed assignment status, assignment date, and follow-up deadlines. Returns empty list for organizations without the formal assignment workflow.
assignment-history-repository
Summaries
The Assignment History Repository is the core data layer that tracks formal peer mentor assignments within the Blindeforbundet workflow. It enables the platform to monitor open and closed case loads, enforce office-fee thresholds tied to assignment counts, and give program coordinators a clear view of each mentor's active obligations. This directly supports compliance with Blindeforbundet's operational rules around mentor compensation and workload limits. Accurate assignment tracking reduces administrative overhead, prevents billing errors, and provides the audit trail required for formal reporting to the organization.
It is foundational to the formal assignment workflow that differentiates Blindeforbundet from other partner organizations.
This low-complexity repository covers four well-scoped operations: fetching active assignments, retrieving full assignment history, counting open assignments, and updating assignment status. The countOpenAssignments function is particularly important as it feeds into the office-fee threshold business rule, making it a dependency for any UI or logic that displays or enforces that threshold. The updateAssignmentStatus interface introduces a write path, which requires integration testing against a Supabase test instance. Timeline risk is minimal, but the AssignedContact Dart model and AssignmentStatus enum must be defined before this component is built.
Organizations without the formal assignment workflow will simply receive empty lists, so branching logic in the UI layer handles that case.
Consumes supabase-client-provider and maps Supabase rows to the typed AssignedContact Dart model and AssignmentStatus enum. getActiveAssignments and getAssignmentHistory issue filtered SELECT queries on the assignments table with mentorId as the primary filter; the history query may include additional status and date ordering. countOpenAssignments should use a Supabase count query with a status filter for open assignments rather than fetching all rows and counting in Dart. updateAssignmentStatus issues a targeted UPDATE with RLS enforcement on the Supabase side.
All methods run in frontend and mobile contexts, so keep response payloads lean. Add error handling for network failures and empty result sets to ensure graceful degradation in the UI.
Responsibilities
- Fetch all active assignments for a given peer mentor
- Return assignment history with status and deadline metadata
- Count open assignments for Blindeforbundet office-fee threshold tracking
- Map Supabase assignment rows to typed AssignedContact Dart model
Interfaces
getActiveAssignments(String mentorId)
getAssignmentHistory(String mentorId)
countOpenAssignments(String mentorId)
updateAssignmentStatus({required String assignmentId, required AssignmentStatus status})
Relationships
Dependencies (1)
Components this component depends on
Dependents (2)
Components that depend on this component