Infrastructure low complexity mobile
1
Dependencies
0
Dependents
0
Entities
0
Integrations

Description

BLoC state management layer for the pause and reactivation UI flows. Manages async status transitions, loading states, and error handling, ensuring the UI remains consistent and responsive during Supabase operations.

Feature: Peer Mentor Pause & Reactivation

mentor-status-bloc

Summaries

The Mentor Status BLoC component ensures that coordinators experience a smooth, responsive interface when pausing or reactivating peer mentors — a task that directly affects participant matching and mentor availability. Without this layer, users would face confusing UI states, potential double-submissions, or unclear error feedback during network delays. By cleanly managing loading and error states, this component protects coordinator confidence in the system and reduces the chance of accidental status changes. A reliable, predictable status management experience is essential for coordinators who manage high volumes of mentors under time pressure.

This is a low-complexity mobile state management component using the BLoC pattern, which is already established in the Flutter codebase. It depends on mentor-status-service being available, making that service a prerequisite for integration. Development effort is approximately 2–3 days including event handling, state emission, and unit tests for all state transitions (loading → success, loading → error). Risks are minimal given the low complexity, but QA should verify that rapid successive events (e.g., double-tap on pause button) are handled safely — the BLoC should debounce or ignore duplicate in-flight events.

Wire into UI only after MentorStatusService is testable end-to-end.

This Flutter BLoC manages the async lifecycle of pause and reactivation flows using the bloc library pattern. It handles two events — PauseMentorEvent and ReactivateMentorEvent — and emits three state variants: MentorStatusLoading, MentorStatusSuccess, and MentorStatusError. The BLoC delegates business logic to MentorStatusService and must not contain any direct Supabase calls. Use EventTransformer.sequential() or similar to prevent concurrent in-flight requests from the same BLoC instance.

The stream is consumed by the pause/reactivation UI widgets to drive button enable/disable states and snackbar feedback. Unit-test all transitions using bloc_test with mocked MentorStatusService. Error states must carry a user-readable message derived from the service exception, not raw Supabase error codes.

Responsibilities

  • Handle PauseMentorEvent and ReactivateMentorEvent
  • Emit loading, success, and error states to the UI
  • Coordinate with MentorStatusService and surface side effects

Interfaces

add(PauseMentorEvent)
add(ReactivateMentorEvent)
stream: Stream<MentorStatusState>
state: MentorStatusState

Relationships

Dependencies (1)

Components this component depends on

API Contract

View full contract →
REST /api/v1/mentor-status-sync 5 endpoints
GET /api/v1/mentor-status-sync List pending sync events (for BLoC hydration on app launch)
GET /api/v1/mentor-status-sync/:id Get current status snapshot for a mentor (BLoC initial state)
POST /api/v1/mentor-status-sync/events Submit a BLoC-originated status event from mobile client
PUT /api/v1/mentor-status-sync/events/:id Acknowledge or annotate a sync event
DELETE /api/v1/mentor-status-sync/events/:id Remove a sync event record