Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/EricMartinez758/corpointa-frontend/llms.txt

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

Categories provide the primary classification system for materials in Corpointa. Every material record requires a category assignment (fk_id_categoria), making categories a foundational reference table that must be populated before materials can be created. Categories are available at the /categorias route, and their names appear throughout the application — in the Materials table, filter dropdowns, and the Stock por Categoría bar chart on the Analytics tab of the Dashboard.

Data Model

The Categoria type is derived from the Zod schema in src/features/categorias/data/schema.ts.
export const categoriaSchema = z.object({
  id_categoria: z.number(),
  nombre:       z.string().min(1, { message: 'El nombre es requerido' }).max(50),
})

export type Categoria = z.infer<typeof categoriaSchema>

Field Reference

FieldTypeConstraintsDescription
id_categorianumberAuto-assignedPrimary key. Referenced as fk_id_categoria in material records.
nombrestringRequired, max 50 charsDisplay name for the category (e.g., Eléctrico, Ferretería, Limpieza).

Features

CRUD Table

A simple data table lists all categories with their names. Inline action menus on each row provide access to edit and delete operations.

Create Dialog

A compact modal form with a single nombre field and client-side Zod validation. The record is persisted via POST /categorias.

Edit Dialog

Pre-populates the form with the selected category’s current name. Changes are saved via PUT /categorias/:id.

Referenced by Materials

Any category that has associated materials will appear in the category filter dropdown on the Materials table and contribute data to the Dashboard’s Analytics chart.

API Operations

All functions live in src/features/categorias/api/categorias.ts.
MethodEndpointFunctionDescription
GET/categoriasgetCategorias()Returns all category records.
GET/categorias/:idgetCategoria(id)Returns a single category by id_categoria.
POST/categoriascreateCategoria(data)Creates a new category. Body: { nombre: string }.
PUT/categorias/:idupdateCategoria(id, data)Updates the name of an existing category. Body: { nombre: string }.
DELETE/categorias/:iddeleteCategoria(id)Permanently removes a category record.

Create Payload

When creating or updating a category, id_categoria is excluded from the request body:
type CategoriaPayload = Omit<Categoria, 'id_categoria'>
// { nombre: string }

Example: Create a Category

import { createCategoria } from '@/features/categorias/api/categorias'

const category = await createCategoria({ nombre: 'Herramientas Manuales' })
// Returns: { id_categoria: 8, nombre: 'Herramientas Manuales' }

Example: GET /categorias Response

[
  { "id_categoria": 1, "nombre": "Eléctrico" },
  { "id_categoria": 2, "nombre": "Ferretería" },
  { "id_categoria": 3, "nombre": "Limpieza" },
  { "id_categoria": 4, "nombre": "Herramientas Manuales" }
]
Deleting a category that is currently assigned to one or more materials will likely be blocked by the backend with a foreign-key constraint error. Reassign or delete the associated materials before removing the category.
Create your full category taxonomy before onboarding materials. Well-defined categories make the Stock por Categoría analytics chart on the Dashboard significantly more useful for tracking inventory distribution across departments.

Build docs developers (and LLMs) love