The Products 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.
/productos) is the primary catalogue management interface in FerreMarket. It lets you browse every product in the Supabase productos table, search and filter by name, SKU, category, or status, switch between grid and table layouts, and perform full CRUD operations — add, edit, and delete — through modal dialogs that persist changes back to the database in real time.
Product Fields
Every product is modelled by theProducto TypeScript interface defined in src/types/index.ts:
| Field | Type | Description |
|---|---|---|
id | string | Unique numeric identifier assigned by Supabase |
sku | string | Stock-keeping unit code; also used as the Cloudflare CDN image filename (<sku>.webp) |
nombre | string | Display name shown in cards, tables, and search results |
descripcion | string | Short product description; searchable via the search bar |
precio | number | Unit price in Chilean pesos (CLP) |
categoria | string | Foreign key matching one of the six category IDs (1–6) |
stock | number | Current on-hand quantity in units |
imagen | string | Absolute URL to the product image on the Cloudflare CDN |
destacado | boolean | true marks the product as featured; used by the Dashboard ProductosDestacados panel |
Viewing Products
Products are loaded on mount viaobtenerProductos() and stored in local React state. Two view modes are available via a toggle in the page header (desktop only):
Grid View
Default view on all screen sizes. Products appear as responsive cards (1 → 2 → 3 → 4 columns). Each card shows the product image, name, category badge, description, price, stock count, and stock status indicator. Click any image to open a full-screen preview overlay.
Table View
Available on screens ≥ 1024 px. Products appear in a scrollable table with sortable columns for Categoría, Precio, and Stock. Click any column header to toggle ascending/descending sort via the
ArrowUpDown icon.| Control | Behaviour |
|---|---|
| Search box | Matches against nombre and descripcion (case-insensitive) |
| Category dropdown | Filters to a single category; options populated from the categorias constant |
| Status dropdown | Filters by the destacado boolean — Activo matches destacado === true; Inactivo matches destacado === false |
| Items per page | 10 / 25 / 50 / 100; resets to page 1 on change |
| Limpiar button | Resets all three filters and returns to page 1 |
Adding and Editing
Open the modal
Click the + Nuevo Producto button in the top-right header to open
ProductoModal in “create” mode. To edit an existing product, click the Editar (pencil) button on a card or table row; the modal opens pre-filled with that product’s current values.Fill in the form
Complete all required fields: SKU, name, description, price, category, stock quantity. Toggle Destacado to include the product in the Dashboard featured panel.
Upload image (new products only)
Select a product image. On save, FerreMarket encodes the image as Base64, converts it to a
.webp File object, and uploads it to Cloudflare Workers via a PUT request before inserting the product row.Save
- New product → calls
agregarProducto(producto)which inserts into Supabase and uploads the CDN image. - Existing product → calls
actualizarProducto(id, producto)which issues a SupabaseUPDATE(image URL is not changed on edit). After either operation, the modal closes andcargarProductos()re-fetches the full product list.
Deleting Products
Click the delete icon
Click the red Trash icon on a product card or table row. This stores the product in
productoSeleccionado state and opens the ConfirmDialog.Confirm in the dialog
The dialog reads: “¿Estás seguro de que deseas eliminar el producto ‘[nombre]’?”. Click Confirmar to proceed or Cancelar to abort.
Stock Status Indicators
Each product displays a coloured badge derived from its currentstock value:
| Stock Level | Icon | Badge Colour | Label |
|---|---|---|---|
stock > 20 | CheckCircle | Green | Disponible |
5 ≤ stock ≤ 20 | AlertTriangle | Yellow | Stock bajo |
1 ≤ stock < 5 | AlertCircle | Red | Muy bajo |
stock === 0 | Circle | Grey | Sin stock |
CircleDot icon (rendered via CircleDot from Lucide React). The Producto interface does not include a separate estado field — the getEstadoIcono helper defaults to the 'activo' (green) icon for all products.
URL Category Filter
The Products page reads a?categoria=<id> query parameter on mount. This is used by the Dashboard’s CategoriasProductos panel, which appends the category ID to the navigation link so users land on the Products page with that category pre-selected.
replace: true) so that sharing or bookmarking the URL does not lock users into a category filter.