Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/JuseAR27/Unisierra-eats/llms.txt

Use this file to discover all available pages before exploring further.

The inventory panel is the primary workspace for managing the UniSierra Eats product catalog. Located at admin/panel_admin.html, it is powered by the iniciarPanelInventario() function in admin.js, which is called automatically when the admin router detects the current URL includes panel_admin.html.

Dashboard Statistics

At the top of the inventory panel, three summary statistics are computed and displayed by the actualizarEstadisticas() function each time the product list is loaded:
StatSourceDOM Element
Total Productsproductos.length from GET /api/productos#total-productos
Total ReviewsSum of numResenas for all products that have at least one review#total-resenas
Average RatingWeighted average of calificacion × numResenas across reviewed products#promedio-calificacion
The weighted average calculation ensures that products with more reviews have proportionally greater influence on the platform score. Products with zero reviews do not contribute to totalResenas or sumaCalificaciones:
productos.forEach(p => {
    if (p.numResenas > 0) {
        totalResenas += p.numResenas;
        sumaCalificaciones += (p.calificacion * p.numResenas);
    }
});

const promedio = sumaCalificaciones / totalResenas;
promedioCalifEl.textContent = promedio.toFixed(1);

Product Table

The product table is populated by GET /api/productos, which returns all products joined with their aggregated review data. The columns displayed are:
ColumnSource Field
IDid_producto (formatted as #00X)
Namenombre
Categorycategoria
Priceprecio (formatted as $X.XX)
StatusAlways displayed as Disponible
ActionsEdit (pencil) and Delete (trash) buttons

Search and Filter

The table supports two simultaneous filters, both of which trigger a fresh cargarProductos() call on each change:
  • Text search — filters by product name or ID (case-insensitive). Bound to the input event on the search bar (input) inside .table-toolbar .search-bar.
  • Category dropdown — filters by the categoria field. The select element has the ID filtro-categoria-admin.

Creating a Product

1

Open the Inventory Panel

Navigate to admin/panel_admin.html. The product table loads automatically on page load.
2

Click 'Registrar Nuevo Producto'

Click the primary button (.btn-solid) in .content-header. This resets the form, sets the modal title to Registrar Nuevo Producto, and opens the #productModal overlay.
3

Fill in the Product Form

Complete all fields in the modal form:
FieldInput TypeNotes
nombreTextProduct display name
precioNumberDecimal price value
descripcionTextareaProduct description
imagenURLImage URL; defaults to a placeholder if left blank
categoriaSelectOne of: comidas, bebidas, snacks, sanas
4

Submit the Form

Click the submit button. The form handler builds the payload and sends a POST request to /api/productos. On success, the modal closes and the table reloads.
await fetch('/api/productos', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ nombre, precio, descripcion, imagen, categoria })
});
precioNivel ($, $$, $$$) is a column in the Productos table and the server accepts it on POST /api/productos. However, the admin inventory form does not expose this field — admin.js never sends precioNivel in the payload. If price tier metadata is needed, it must be set directly in the database or via a custom request.

Editing a Product

Clicking the pencil icon on any table row opens the same modal form pre-populated with the product’s current values. The productoEnEdicionId variable is set to the product’s id_producto, which the form handler uses to switch from POST to PUT:
await fetch(`/api/productos/${productoEnEdicionId}`, {
    method: 'PUT',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ nombre, precio, descripcion, imagen, categoria })
});
The server updates the Productos table row where id_producto matches the given :id.

Deleting a Product

Clicking the trash icon opens a custom confirmation modal rendered dynamically in the DOM — admin.js does not use window.confirm() for deletions. The overlay displays the product ID and offers Cancelar and Eliminar buttons. On confirmation, the handler calls:
await fetch(`/api/productos/${id}`, { method: 'DELETE' });
The product row is permanently removed from the Productos table in SQLite and the table reloads automatically.

Build docs developers (and LLMs) love