Overview
The Admin Panel provides authenticated administrators and editors with tools to manage users, publish content, and maintain the health information ecosystem. All admin features require specific permissions validated through thePermissionContext.
User Management
The user management interface is located atapp/(main)/dashboard/admin/users/index.tsx.
Features
- Create Users
- Edit Users
- Delete Users
Administrators can create new users with specific roles:
app/(main)/dashboard/admin/users/index.tsx:177-205
Re-Authentication System
app/(main)/dashboard/admin/users/index.tsx:227-235
- Creating a new user
- Deleting an existing user
User Search & Filtering
Real-time search across multiple fields:app/(main)/dashboard/admin/users/index.tsx:324-333
Role Assignment
Roles are loaded dynamically from the backend:app/(main)/dashboard/admin/users/index.tsx:87-96
app/(main)/dashboard/admin/users/index.tsx:437-452
Audit Trail
Each user record tracks creation and modification history:app/(main)/dashboard/admin/users/index.tsx:547-593
Content Management
All content management routes follow a similar pattern and are located underapp/(main)/dashboard/manage/.
Available Content Types
Noticias
Route:
/manage/noticiasPublish institutional news with:- Title and description
- Featured images
- Facebook link integration
- Publication date
Establecimientos
Route:
/manage/establecimientosRegister health facilities with:- Name and address
- Phone number
- Google Maps link
- Associated services
Servicios
Route:
/manage/serviciosConfigure medical services:- Service name
- Description
- Availability
Estrategias
Route:
/manage/estrategiasManage health programs:- Strategy title
- Detailed description
- Target population
Normas
Route:
/manage/normasAdminister regulations:- Document title
- Official links
- Publication date
Roles
Route:
/manage/rolesConfigure permissions:- Role name
- Permission assignments
- Active status
Permission Validation
All admin features validate permissions both on frontend and backend:Frontend Permission Check
src/context/PermissionContext.tsx:50-53
Backend Validation
The backend API validates permissions on every protected endpoint using JWT tokens and role-based access control.Role Color System
Visual role identification using deterministic colors:app/(main)/dashboard/admin/users/index.tsx:30-52
Password Management
Password Visibility Toggle
Secure password input with show/hide functionality:app/(main)/dashboard/admin/users/index.tsx:380-398
Password Confirmation
Real-time password match validation:app/(main)/dashboard/admin/users/index.tsx:165-175
API Endpoints
User Management Endpoints
| Method | Endpoint | Purpose | Permission |
|---|---|---|---|
| GET | /users | List all users | manage_users |
| GET | /users/:id | Get user details | manage_users |
| POST | /users | Create new user | manage_users |
| PUT | /users/:id | Update user | manage_users |
| DELETE | /users/:id | Delete user | manage_users |
| POST | /auth/verify | Verify password | Authenticated |
Content Management Endpoints
| Method | Endpoint | Purpose |
|---|---|---|
| GET | /roles | List available roles |
| GET | /noticias | List news (admin) |
| POST | /noticias | Create news article |
| GET | /establecimientos | List establishments (admin) |
| POST | /establecimientos | Register facility |
Security Best Practices
Implemented Security Measures:
- Re-authentication for critical operations
- Permission validation on every protected route
- Audit trails with created_by/updated_by fields
- Self-deletion prevention for logged-in users
- JWT token validation on backend
Error Handling
Comprehensive error messages for common scenarios:app/(main)/dashboard/admin/users/index.tsx:202-204
Related Documentation
Dashboard
Role-based navigation system
Authentication
Login and session management
