Data Layer low complexity frontendmobile
1
Dependencies
2
Dependents
1
Entities
0
Integrations

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.

Feature: Peer Mentor Profile & Status Screen

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

Related Data Entities (1)

Data entities managed by this component

API Contract

View full contract →
REST /api/v1/assignments 9 endpoints
GET /api/v1/assignments List assignments with optional filtering
GET /api/v1/assignments/:id Get a single assignment by ID
POST /api/v1/assignments Create a new mentor-contact assignment
PUT /api/v1/assignments/:id Update assignment details
DELETE /api/v1/assignments/:id Delete an assignment record
GET /api/v1/assignments/mentor/:mentor_id/active Get all active (open) assignments for a mentor
+3 more