Overview
The Users Panel provides comprehensive user account management for the Ai Studio admin dashboard. Control who has access to your restaurant management system and define their permission levels through role-based access control.User management is restricted to Admin users only. Editor role users cannot access the Users panel.
User Roles
Ai Studio implements a two-tier role system defined intypes.ts:200-203:
Administrador (Admin)
Full system access with all privileges including:
- User management (create, edit, delete users)
- Complete order and reservation control
- Product and menu management
- System configuration and settings
- Bot management and configuration
- All other panel access
Editor
Operational access with restrictions:
- Order and reservation management
- Customer management
- Table status updates
- Product viewing and editing
- Cannot manage users
- Cannot modify system settings
- Cannot delete critical data
Role Comparison
- Admin Role
- Editor Role
Administrator Capabilities
Administrators have unrestricted access to all dashboard features:Full Management Access:- ✅ Create, edit, and delete users
- ✅ Configure system settings
- ✅ Manage AI bots and integrations
- ✅ Access all data panels
- ✅ Delete orders and reservations
- ✅ Bulk operations
- ✅ Schedule exception management
User Structure
Each user account contains the following fields (fromtypes.ts:205-212):
Email addresses are automatically converted to lowercase and must be unique across all users.
Managing Users
Accessing the Users Panel
- Log in to the admin dashboard with Admin credentials
- Click Usuarios in the left sidebar navigation
- The Users panel displays all registered system users
User Table Columns
The users table displays:| Column | Description |
|---|---|
| Nombre | User’s full name |
| User’s email address (used for login) | |
| Rol | Role badge (Administrador or Editor) |
| Último Acceso | Timestamp of last dashboard login |
| Acciones | Edit and Delete buttons |
Creating a New User
Enter User Details
Fill in the user information form:
- Name: Full name of the user
- Email: Unique email address (validation enforced)
- Role: Select either Administrador or Editor from dropdown
Save User
Click Guardar to create the user accountThe system validates:
- Email uniqueness (prevents duplicates)
- Required fields (all must be filled)
- Email format (basic validation)
Editing User Details
Modify User Information
The Edit User modal opens with pre-filled informationYou can modify:
- Name
- Email (must remain unique)
- Role (promote Editor to Admin or vice versa)
Save Changes
Click Guardar to update the user accountChanges are validated and synced immediately to Firebase
Deleting a User
Confirm Deletion
A confirmation modal appears showing the user’s nameWarning: This action is permanent and cannot be undone
Execute Deletion
Click Eliminar to permanently remove the user accountThe user is immediately removed from Firebase and the local cache
User Interface Features
Search and Filter
The Users panel includes a search bar that filters users in real-time:- Search by name (case-insensitive)
- Search by email (case-insensitive)
- Results update instantly as you type
Pagination
User lists are paginated with 10 users per page. Use the pagination controls at the bottom of the table to navigate between pages.Role Badges
Roles are displayed with color-coded badges for quick identification:Admin Badge
Red/Primary color badge:
AdministradorStyling: bg-primary/20 text-primaryEditor Badge
Blue color badge:
EditorStyling: bg-blue-100 text-blue-800Loading States
The interface provides visual feedback during operations:- Spinner indicators appear in the Actions column while processing
- Loading text displays while fetching user data
- Disabled buttons prevent multiple simultaneous operations
Last Access Tracking
The system automatically tracks when users last accessed the admin dashboard:- New users: Display “Nunca” (Never) until first login
- Active users: Show formatted timestamp of last access
- Format: Argentine locale format (es-AR) with date and time
10/3/2026, 14:35:22
Last access tracking helps administrators monitor active users and identify inactive accounts.
User Service Architecture
The user management system is powered byuserService.ts with the following key functions:
Core Functions
- Add User
- Update User
- Delete User
- Auto-generated unique ID:
USER-{timestamp}-{random} - Creation timestamp
- Null last access (until first login)
- Lowercase email normalization
- Duplicate email validation
Data Synchronization
User data is synchronized using:-
Firebase Realtime Listeners (AdminDashboard.tsx:106-132)
- Automatic updates when users are added/edited/deleted
- Real-time sync across all connected admin sessions
-
Local Cache (localStorage)
- Key:
pizzeria-users - Fallback when Firebase is unavailable
- Seeding mechanism for empty Firebase collections
- Key:
-
Optimistic Updates
- UI updates immediately
- Firebase sync happens in background
- Error handling with rollback if needed
Permissions and Security
Access Control
The Users panel implements role-based restrictions:- Only Admin users can access the Users panel
- Editor users see the panel greyed out or hidden in navigation
- All user operations require Admin privileges
Email Validation
Email addresses undergo validation:- Uniqueness Check: Prevents duplicate emails across all users
- Lowercase Normalization: All emails stored in lowercase
- Required Field: Cannot be empty
- Format Validation: Basic email format checking
Error Handling
The system provides clear error messages:- Duplicate Email: “Ya existe un usuario con el email [email].”
- User Not Found: “Usuario no encontrado para actualizar.”
- Firebase Errors: “Error al guardar usuario en la nube: [message]”
- General Errors: Fallback error messages with toast notifications
Empty State
When no users exist in the system: ![Empty Users State] An empty state graphic appears with:- Users icon illustration
- Message: “No hay usuarios registrados”
- Subtext: “Comienza agregando tu primer usuario.”
In production, you should always have at least one Admin user to manage the system.
Best Practices
Maintain Admin Access
Always keep at least 2 Admin users to prevent lockout scenarios
Use Descriptive Names
Use full names to easily identify users in the system
Monitor Last Access
Regularly review last access times to identify inactive accounts
Role Principle of Least Privilege
Grant Editor role by default, promote to Admin only when necessary
Troubleshooting
User Cannot Login
- Verify user account exists in Users panel
- Check email address is correct (case-insensitive)
- Ensure user has been created successfully in Firebase
Duplicate Email Error
- Search for existing user with that email
- Edit existing user instead of creating new one
- Use a different email address
Changes Not Reflecting
- Check Firebase connection status in header
- Refresh the dashboard
- Verify Firebase permissions and authentication
Next Steps
Learn about tracking performance metrics and chat history in Analytics.
