Unit Assignment Panel
Component Detail
Description
Admin UI panel embedded within a user's profile or a hierarchy node detail page that shows current unit assignments for that user and allows adding or removing assignments. Supports marking one assignment as primary via a toggle.
unit-assignment-panel
Summaries
The Unit Assignment Panel gives administrators direct control over which chapters a user belongs to — a foundational capability for managing access rights, program participation, and communication targeting across the organization. Incorrectly assigned users receive wrong content, miss critical chapter communications, or gain unintended access to administrative functions. By embedding this panel directly in user profiles and hierarchy node detail pages, administrators can resolve assignment issues immediately without navigating to a separate tool. The enforced maximum of five simultaneous chapter assignments prevents data sprawl and maintains the integrity of the NHF-specific peer mentor model, protecting the operational assumptions that reporting and program delivery rely on.
Medium-complexity panel embedded in two different parent contexts (user profile pages and hierarchy node detail pages), requiring flexible layout adaptation. Dependencies on unit-assignment-service and hierarchy-tree-view mean this panel cannot be finalized until both are stable. The five-assignment cap for NHF is a business rule that must be validated server-side in unit-assignment-service and enforced client-side in this panel — both layers need aligned test cases. The primary-assignment toggle introduces state ordering complexity: removing the current primary assignment should prompt for a replacement selection.
Testing must cover all permutations of add, remove, set-primary, and the cap boundary condition. Plan for a joint QA session with the admin user acceptance testing group before release.
UnitAssignmentPanel is a frontend/mobile widget initialized with `userId` and `organizationId`. It calls `loadAssignments(userId)` on mount via unit-assignment-service to populate the current assignment list. `addAssignment(unitId, isPrimary)` posts a new assignment record and re-fetches the list; `removeAssignment(assignmentId)` soft-deletes or hard-deletes depending on service implementation. `setPrimary(assignmentId)` updates the primary flag and must clear the previous primary in the same transaction — verify that the service handles this atomically.
The hierarchy-tree-view dependency suggests the add-assignment flow opens a tree-based unit picker rather than a flat dropdown, requiring careful state management to pass the selected unitId back to this panel. The five-assignment cap should be enforced both in the UI (disable add button at limit) and validated in unit-assignment-service to prevent race conditions.
Responsibilities
- Display current unit assignments for a user
- Add assignment to a unit with primary flag option
- Remove an existing assignment
- Enforce maximum 5 simultaneous chapter assignments for NHF
Interfaces
UnitAssignmentPanel(userId, organizationId)
addAssignment(unitId, isPrimary)
removeAssignment(assignmentId)
setPrimary(assignmentId)
loadAssignments(userId)
Relationships
Dependencies (2)
Components this component depends on
Related Data Entities (2)
Data entities managed by this component