Skip to main content

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 in types.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

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
Use Case: Restaurant owners, managers, and technical administrators

User Structure

Each user account contains the following fields (from types.ts:205-212):
interface User {
    id: string;              // Unique identifier (auto-generated)
    name: string;            // Full name
    email: string;           // Email address (unique, lowercase)
    role: UserRole;          // ADMIN or EDITOR
    createdAt: string;       // ISO timestamp of creation
    lastAccess: string | null; // ISO timestamp of last login
}
Email addresses are automatically converted to lowercase and must be unique across all users.

Managing Users

Accessing the Users Panel

  1. Log in to the admin dashboard with Admin credentials
  2. Click Usuarios in the left sidebar navigation
  3. The Users panel displays all registered system users
![Users Panel Interface] The panel shows a searchable table with user details and action buttons for each user.

User Table Columns

The users table displays:
ColumnDescription
NombreUser’s full name
EmailUser’s email address (used for login)
RolRole badge (Administrador or Editor)
Último AccesoTimestamp of last dashboard login
AccionesEdit and Delete buttons

Creating a New User

1

Open Add User Modal

Click the Agregar Usuario button in the top-right corner of the Users panel
2

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
3

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)
4

Confirmation

Success toast notification appears: “Usuario agregado con éxito.”The new user is immediately synced to Firebase and appears in the users table
Duplicate email addresses are not allowed. If you attempt to create a user with an existing email, you’ll receive an error: “Ya existe un usuario con el email [email].”

Editing User Details

1

Select User to Edit

Click the Edit icon (pencil) in the Actions column for the desired user
2

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)
3

Save Changes

Click Guardar to update the user accountChanges are validated and synced immediately to Firebase
4

Confirmation

Success notification: “Usuario actualizado con éxito.”

Deleting a User

1

Initiate Deletion

Click the Delete icon (trash) in the Actions column for the user to remove
2

Confirm Deletion

A confirmation modal appears showing the user’s nameWarning: This action is permanent and cannot be undone
3

Execute Deletion

Click Eliminar to permanently remove the user accountThe user is immediately removed from Firebase and the local cache
4

Confirmation

Success notification: “Usuario eliminado con éxito.”
Deleting a user removes their account immediately. They will lose access to the admin dashboard. Ensure you have at least one Admin user before deleting accounts.

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
Buscar por nombre o email...

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-primary

Editor Badge

Blue color badge: EditorStyling: bg-blue-100 text-blue-800

Loading 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
Example: 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 by userService.ts with the following key functions:

Core Functions

addUser(userData: Omit<User, 'id' | 'createdAt' | 'lastAccess'>)
Creates a new user with:
  • 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:
  1. Firebase Realtime Listeners (AdminDashboard.tsx:106-132)
    • Automatic updates when users are added/edited/deleted
    • Real-time sync across all connected admin sessions
  2. Local Cache (localStorage)
    • Key: pizzeria-users
    • Fallback when Firebase is unavailable
    • Seeding mechanism for empty Firebase collections
  3. 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
There is no built-in protection against deleting the last Admin user. Exercise caution when managing Admin accounts to avoid losing administrative access.

Email Validation

Email addresses undergo validation:
  1. Uniqueness Check: Prevents duplicate emails across all users
  2. Lowercase Normalization: All emails stored in lowercase
  3. Required Field: Cannot be empty
  4. 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.

Build docs developers (and LLMs) love