UserRole
Enum-like type defining all available user roles in the system.Roles
Administrator role with full system access, including:
- All CRUD operations on requisitions
- All catalog management operations
- User management (approve, reject, delete, change roles)
- Access to all modules
Coordinator role with elevated permissions:
- Create, update, and delete requisitions
- Manage catalog entries (create, update, toggle status)
- Cannot delete users or perform admin-only operations
Laboratory department role:
- View requisitions filtered by laboratory destination
- Limited editing permissions
- Department-specific access
Distribution center (CEDIS) role:
- View requisitions filtered by CEDIS destination
- Limited editing permissions
- Department-specific access
Pending approval status:
- Newly registered users start with this role
- Cannot access main application features
- Shown pending approval page until admin assigns a role
Read-only consultation role:
- View-only access to requisitions and data
- Cannot create, update, or delete any records
- Useful for auditors or external stakeholders
Profile
User profile entity linked to Supabase authentication.Fields
Unique identifier (UUID) - matches Supabase Auth user ID
User’s full name
User’s email address
User’s assigned role determining their permissions
Timestamp when the profile was created (ISO 8601 format)
Timestamp of last profile update (ISO 8601 format)
Example
RequisicionHistorial
Audit trail record for requisition changes.Fields
Unique identifier (UUID)
Foreign key to the requisition that was modified
Name of the field that was changed (e.g., ‘cantidad_entregada’, ‘estatus_id’)
Previous value before the change (stored as string, may be null for new fields)
New value after the change (stored as string, may be null if field was cleared)
Foreign key to the user (profile) who made the change
Timestamp when the change was made (ISO 8601 format)
Joined user profile object (populated when using Supabase joins)
Example
Audit Trail Usage
The audit trail is automatically populated when updating requisitions:Values are stored as strings in the audit trail to support any data type. Applications should parse and format these strings appropriately for display.
Permission Patterns
Role-Based Access Control
Conditional UI Rendering
Related Actions
- getCurrentProfile() - Get current user profile
- signIn() - Authenticate user
- signUp() - Register new user
- updateProfile() - Update profile information
- updateUserRole() - Change user role (admin only)
- approveUser() - Approve pending users
