The Users module (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ProyectoFerretek/FerreMarket/llms.txt
Use this file to discover all available pages before exploring further.
/admin/usuarios) is the central hub for managing every account that has access to the FerreMarket back-office. From here, administrators can create new staff accounts, assign roles, monitor last-login activity, trigger password-recovery emails, and permanently remove accounts when needed. Access to this module is restricted exclusively to users whose role is admin and whose account status is activo — anyone else is shown an Acceso Restringido screen and must contact an administrator to request the necessary permissions.
User Fields
Every account in FerreMarket is represented by theUsuario TypeScript interface defined in src/types/index.ts. The table below documents each field:
| Field | Type | Required | Description |
|---|---|---|---|
id | string | ✅ | Internal database record identifier. |
uid | string | ✅ | Supabase Auth UUID — links the database row to the Supabase Auth user. |
nombre | string | ✅ | Full display name of the user. |
email | string | ✅ | Email address used for login and password recovery. |
rol | 'admin' | 'usuario' | 'cliente' | ✅ | Access role. See Roles & Permissions for details. |
estado | 'activo' | 'inactivo' | ✅ | Account status. Inactive accounts cannot log in or access the system. |
fechaCreacion | string (ISO 8601) | ✅ | Timestamp when the account was first created. |
ultimaModificacion | string (ISO 8601) | ✅ | Timestamp of the most recent update to the record. |
ultimoAcceso | string (ISO 8601) | ❌ | Last login time. Absent if the user has never signed in. |
avatar | string (URL) | ❌ | Optional profile picture URL. Falls back to a generic icon when absent. |
Creating a User
Clicking the Nuevo Usuario button (visible only to users who passpuedeRealizarAccion('crear')) opens the UsuarioModal in create mode. Complete the form and click Save to provision the new account.
Open the creation modal
Click the Nuevo Usuario button in the top-right corner of the Users page. The
UsuarioModal component opens in create mode.Fill in the required fields
Provide the following information:
| Field | Description |
|---|---|
nombre | Full name of the new user. |
email | A unique email address — used for login and recovery emails. |
password | Initial password for the account. |
confirmPassword | Must match password exactly. |
rol | Choose admin or usuario. |
estado | Set to activo to allow immediate access, or inactivo to create the account in a disabled state. |
UsuarioFormData interface:
Internal record ID. Only present when editing an existing user.
Full display name.
Unique email address. Converted to lowercase before being sent to Supabase.
Plain-text password. Transmitted securely to the Edge Function; never stored in the client.
Confirmation of the password. Must match
password.Access role to assign to the user. The creation and edit form presents
admin and usuario as selectable options. The cliente value is stored in the database and readable but is not offered as a selection in the UI form.Initial account status.
Editing a User
To edit an existing account, click the pencil icon (Edit) in the user’s row. TheUsuarioModal opens in edit mode, pre-filled with the current values from the selected Usuario record.
Password fields are optional when editing. Leave them blank to keep the current password unchanged. Only
nombre, email, rol, and estado are updated via actualizarUsuario() when performing an edit — the password is only changed through the dedicated Password Recovery flow.Profile fields
nombre and email — update the user’s display name and login address.Access fields
rol and estado — change the user’s permission level or activate/deactivate the account without deleting it.Deactivating vs. Deleting
FerreMarket offers two distinct ways to remove a user’s access, each with different consequences.Deactivate (Recommended)
Set
estado to 'inactivo' by editing the user record. The account and all associated historical data are preserved in the database. The user cannot log in while deactivated but can be reactivated at any time by setting estado back to 'activo'.Delete (Permanent)
Click the trash icon on a user row to open a confirmation dialog. Confirming the action calls
deleteUser(uid) (Supabase Edge Function delete-user) followed by eliminarUsuario(id) to remove both the Supabase Auth entry and the database record. This action cannot be undone.Password Recovery
Every user row includes a lock icon button that allows an administrator to trigger a password-reset email for that user without knowing their current password.Click the recovery icon
Click the lock icon on the target user’s row. A confirmation modal opens showing the user’s name and email address.
Confirm the action
Click Enviar Email in the modal. The UI calls
recoverPassword(email), which invokes the Supabase Edge Function send-password-recovery-email with the user’s email address (lowercased).Filtering and Search
The Users page provides several controls for narrowing down the user list:| Control | Options | Description |
|---|---|---|
| Search bar | Free text | Filters by nombre or email (case-insensitive). |
| Role filter | admin, usuario, cliente | Shows only users with the selected role. |
| Status filter | activo, inactivo | Shows only users matching the selected status. |
| Items per page | 10, 25, 50 | Controls how many users appear per page. |
| Column sort | rol, estado, ultimoAcceso, fechaCreacion | Click any column header to toggle ascending/descending sort. |
| Clear filters | — | Resets all filters and returns to page 1. |
useMemo on the locally loaded usuarios array — no additional network requests are made when changing filters.
The Last Access column uses colour-coded indicators to help administrators identify inactive accounts at a glance:
| Indicator | Meaning |
|---|---|
| 🟢 Today | The user logged in today. |
| 🟡 Within 7 days | The user logged in within the last week. |
| 🔴 More than 7 days | The user has not logged in for over a week. |
| ⚫ Never | The user has never signed in. |