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.

Corpointa is a frontend-only single-page application (SPA) built with React. It does not contain any server-side logic of its own — instead, every data operation is delegated to a companion REST API backend over HTTP. All network communication is handled through a single, centrally configured Axios instance that lives in src/lib/api-client.ts. Understanding this client is the starting point for any integration or debugging work.

Base URL Configuration

The API base URL is supplied at build time through the VITE_API_URL environment variable. When that variable is absent — for example in a local development environment — the client falls back to http://localhost:4000.
# Set this in your .env file to point at your backend
VITE_API_URL=https://api.your-backend.com
# When VITE_API_URL is unset, the client falls back to http://localhost:4000
The Axios instance is created with that base URL and a default Content-Type header:
import axios from 'axios'

const apiClient = axios.create({
  baseURL: import.meta.env.VITE_API_URL ?? 'http://localhost:4000',
  headers: {
    'Content-Type': 'application/json',
  },
})
Every API module in the application imports this single apiClient instance, so changing VITE_API_URL at build time is the only configuration required to point the entire frontend at a different backend.

Request Interceptor

Before any request leaves the browser, a request interceptor reads the JWT access token from a cookie named thisisjustarandomstring, JSON-parses its value, and attaches it as an Authorization: Bearer header. This happens automatically for every call — individual API functions do not need to handle token attachment themselves.
apiClient.interceptors.request.use((config) => {
  const cookieName = 'thisisjustarandomstring'
  const cookieValue = document.cookie
    .split('; ')
    .find((row) => row.startsWith(`${cookieName}=`))
    ?.split('=')[1]

  if (cookieValue) {
    try {
      const token = JSON.parse(decodeURIComponent(cookieValue))
      if (token) {
        config.headers.Authorization = `Bearer ${token}`
      }
    } catch {
      // Invalid cookie — silently ignored
    }
  }

  return config
})
The cookie value is URI-decoded first and then JSON-parsed because the Zustand auth store serialises the token string with JSON.stringify before writing it to the cookie. If the cookie is absent or its value cannot be parsed, the interceptor skips token attachment without throwing, and the request is sent unauthenticated — the backend will return 401 Unauthorized.

Content-Type

All requests use Content-Type: application/json by default, set at instance creation time. This means every request body must be a JSON-serialisable JavaScript object. Axios handles serialisation automatically when you pass a plain object to .post(), .put(), or .patch().
The one exception is the PDF download endpoint (GET /salidas/:id/pdf), which overrides responseType to 'blob' on a per-request basis to handle the binary response correctly.

Response Handling

Axios unwraps the HTTP response envelope automatically. API module functions return response.data directly, so callers receive the parsed JSON body without any additional unwrapping:
// Example pattern used throughout all API modules
const response = await apiClient.get('/materiales')
return response.data  // the parsed JSON array — not the AxiosResponse wrapper
HTTP errors (4xx, 5xx) propagate as Axios errors. You can inspect the HTTP status code via error.response?.status and the error body via error.response?.data. If the network is unreachable, error.response will be undefined and error.request will be populated instead.
Wrap API calls in try/catch and check axios.isAxiosError(error) to distinguish API errors from unexpected runtime errors in your error handlers.

API Modules

The frontend is organised into feature modules, each with a dedicated API file. The table below maps each feature to its base URL path.

Auth

Sign in and token refresh — /auth

Dashboard

Aggregate stats for the home screen — /dashboard

Materials

Inventory item catalogue — /materiales

Entries / Receipts

Control perceptivo (goods received notes) — /controles-perceptivos

Dispatches

Outbound material dispatches — /salidas

Stock

Current stock levels and min/max thresholds — /existencias

Categories

Material category catalogue — /categorias

Units of Measure

Unit of measure catalogue — /unidades-medidas

Destinations

Destination / department catalogue — /destinos

Suppliers

Supplier catalogue — /proveedores

Employees

Employee records — /empleados

Users

System user accounts — /users

Audit Log

Immutable activity log — /bitacoras

Build docs developers (and LLMs) love