Skip to main content

Documentation Index

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

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

The Trucks module provides a complete registry of every vehicle in the Aibar SRL App fleet. Each truck record stores the essential identification data — licence plate, manufacturer, model, model year, and vehicle type — that appears on trip assignments and reports. Trucks can be created, updated, and soft-deleted, ensuring that vehicles taken out of service do not corrupt historical trip records that still reference them.

Data Models

Camion Interface

The full read model returned by the API for every truck record:
export interface Camion {
  id: string;
  patente: string;
  marca: string | null;
  modelo: string | null;
  anio: number | null;
  tipo: string | null;
  activo: boolean;
  creado_en: string;
}

CamionCreate Interface

The payload used when registering a new truck. Only patente is required:
export interface CamionCreate {
  patente: string;
  marca?: string;
  modelo?: string;
  anio?: number;
  tipo?: string;
}

CamionCreate Fields

patente
string
required
The vehicle’s licence plate number. This is the unique identifier for trucks within the system — no two active trucks may share the same patente. If a duplicate plate is submitted the API returns 400 Bad Request and the UI displays “Ya existe un camión con esa patente”.
marca
string
Vehicle manufacturer name (e.g., "Volvo", "Scania", "Mercedes-Benz").
modelo
string
Model designation of the vehicle (e.g., "FH16", "R 500").
anio
number
Four-digit model year of manufacture (e.g., 2019).
tipo
string
Free-text category describing the vehicle’s configuration or purpose (e.g., "Semirremolque", "Chasis", "Cisterna").
patente (licence plate) is the unique, human-readable identifier for trucks. The id field is a UUID used internally by the API, but plate numbers are what appear in every dropdown, report, and trip record across the application.

CamionesService

CamionesService is an Angular Injectable provided at the root level. It handles all REST calls to the /camiones resource.
@Injectable({ providedIn: 'root' })
export class CamionesService {
  private apiUrl = `${environment.apiUrl}/camiones`;

  constructor(private http: HttpClient) {}
}

listar()

Returns a paginated list of trucks. By default, only active trucks (activo: true) are returned.
listar(activosOnly: boolean = true, pagina: number = 1, tamanoPagina: number = 20): Observable<RespuestaPaginada<Camion>>
HTTP call:
GET /camiones/?activos_only=true&pagina=1&tamano_pagina=20
The ListaViajes component calls camionesService.listar(true, 1, 1000) to populate the truck dropdown in the new-trip modal — only active vehicles are offered for assignment.

crear()

Registers a new truck in the fleet.
crear(datos: CamionCreate): Observable<Camion>
HTTP call:
POST /camiones/
Body: a CamionCreate object serialised as JSON. Returns the newly created Camion. The component enforces that patente is non-empty before calling this method. A 400 response indicates a duplicate licence plate.

actualizar()

Performs a partial update on an existing truck record. Accepts any subset of CamionCreate fields. Note that patente cannot be changed after creation (the edit form only exposes marca, modelo, anio, and tipo).
actualizar(id: string, datos: Partial<CamionCreate>): Observable<Camion>
HTTP call:
PATCH /camiones/{id}
Body example:
{
  "marca": "Volvo",
  "modelo": "FH 500",
  "anio": 2022,
  "tipo": "Semirremolque"
}
Returns the updated Camion. The edit modal pre-populates marca, modelo, anio, and tipo from the selected truck before sending only the changed values.

darDeBaja()

Soft-deletes a truck by setting activo: false on the backend. The truck record and all historical trip associations are fully preserved.
darDeBaja(id: string): Observable<Camion>
HTTP call:
DELETE /camiones/{id}
Returns the updated Camion with activo: false. Deactivated trucks are excluded from the default listing (activos_only=true) and will no longer appear in the new-trip dropdown.

Truck Lifecycle

1

Register a new truck

Open the registration modal via + Nuevo camión. The only mandatory field is the licence plate (patente). Optionally fill in make, model, year, and type for richer records.
2

Assign to a trip

When creating a trip, the truck dropdown is populated from camionesService.listar(true, 1, 1000). Select the desired truck or leave it blank — the camion_id field on a trip is optional.
3

Update vehicle details

Use the Editar row action to correct or enrich marca, modelo, anio, or tipo at any time via PATCH /camiones/{id}.
4

Deactivate a truck

Use the Dar de baja row action to retire a vehicle from the active fleet. A confirmation dialog is shown before the soft-delete is executed. The truck will no longer appear in trip-creation dropdowns.

Soft Delete — Preserving Historical Data

Calling darDeBaja() does not remove the truck from the database. It flips the activo flag to false, which means:
  • The truck is excluded from GET /camiones/?activos_only=true (the default query used by both the truck list and the trip form).
  • All past Viaje records that reference the truck’s id remain intact and continue to display correctly — deactivating a truck never breaks trip history.
  • The record can be retrieved directly by id or by querying with activos_only=false if needed for auditing.
There is no “reactivate” action in the current UI. If a deactivated truck needs to return to service, it must be reactivated directly through the backend API.

Pagination Wrapper

All listar() responses are typed as RespuestaPaginada<Camion>. This generic interface is shared across every list endpoint in the application:
export interface RespuestaPaginada<T> {
  items: T[];
  total: number;
  pagina: number;
  tamano_pagina: number;
  total_paginas: number;
}
items
T[]
The array of records for the current page.
total
number
Total number of records matching the query (across all pages).
pagina
number
The current page number (1-indexed).
tamano_pagina
number
Maximum number of records per page as requested.
total_paginas
number
Total number of pages available at the current tamano_pagina.
Pagination state in ListaCamiones is managed with Angular signals, and the shared <app-paginacion> component handles navigation:
pagina       = signal(1);
totalPaginas = signal(1);
total        = signal(0);
tamanoPagina = 20;

Build docs developers (and LLMs) love