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 Drivers module is the backbone of fleet personnel management in Aibar SRL App. Every trip must be assigned to a driver, making accurate driver data — name, contact details, availability status, and home-truck assignment — critical for day-to-day operations. The ListaChoferes component provides a paginated directory with inline actions to create, edit, and deactivate drivers, while ChoferesService handles all backend communication.

Driver States

Each driver carries an estado field that reflects their current availability:

disponible

The driver is on duty and free to be assigned to a new trip. Only drivers in this state appear in the new-trip dropdown.

viajando

The driver is currently on an active (en_curso) trip. They cannot be assigned to another trip until the current one is finalised or cancelled.

inactivo

The driver has been taken out of rotation, either temporarily or permanently. They will not appear in the available-driver list but their historical trip data is preserved.

Data Models

Chofer Interface

The full read model returned by the API for every driver record:
export interface Chofer {
  id: string;
  nombre_completo: string;
  dni: string | null;
  telefono: string | null;
  estado: 'disponible' | 'viajando' | 'inactivo';
  camion_id: string | null;
  activo: boolean;
  creado_en: string;
  creado_por: string | null;
}

ChoferCreate Interface

The payload used when registering a new driver. Only nombre_completo is required:
export interface ChoferCreate {
  nombre_completo: string;
  dni?: string;
  telefono?: string;
  camion_id?: string;
}

ChoferCreate Fields

nombre_completo
string
required
Full legal name of the driver. Used throughout the UI wherever a human-readable driver label is needed (e.g., the trip list shows nombreChofer(viaje.chofer_id) which resolves to this value).
dni
string
National identity document number. Optional but recommended for compliance and driver verification.
telefono
string
Contact phone number for the driver. Optional — stored as a string to accommodate country codes and formatting variations.
camion_id
string
UUID of the driver’s “home” truck — the vehicle habitually assigned to this driver. This is a default or preference field only. The actual truck used on any given trip is recorded directly on the Viaje object and may differ from camion_id.

ChoferesService

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

  constructor(private http: HttpClient) {}
}

listar()

Returns a paginated list of drivers. By default, only active drivers (activo: true) are included.
listar(activosOnly: boolean = true, pagina: number = 1, tamanoPagina: number = 20): Observable<RespuestaPaginada<Chofer>>
HTTP call:
GET /choferes/?activos_only=true&pagina=1&tamano_pagina=20
Pass activosOnly=false to include deactivated drivers in the response. The trip list view uses this to build the complete choferesPorId name map so that historical trips still display the driver’s name even after they have been deactivated: this.choferesService.listar(false, 1, 1000).

obtenerPorId()

Retrieves a single driver by their UUID.
obtenerPorId(id: string): Observable<Chofer>
HTTP call:
GET /choferes/{id}
Returns the full Chofer object for the given id.

crear()

Registers a new driver. The driver is created with estado: 'disponible' and activo: true by default.
crear(datos: ChoferCreate): Observable<Chofer>
HTTP call:
POST /choferes/
Body: a ChoferCreate object serialised as JSON. Returns the newly created Chofer. The component validates that nombre_completo is non-empty before calling this method.

cambiarEstado()

Updates the driver’s availability state directly, without modifying any other fields.
cambiarEstado(id: string, estado: string): Observable<Chofer>
HTTP call:
PATCH /choferes/{id}/estado
Body:
{ "estado": "inactivo" }
Returns the updated Chofer. The backend also calls this endpoint internally when a trip is started (sets viajando) or completed/cancelled (resets to disponible).

actualizar()

Performs a partial update on a driver record. Accepts any subset of ChoferCreate fields.
actualizar(id: string, datos: Partial<ChoferCreate>): Observable<Chofer>
HTTP call:
PATCH /choferes/{id}
Body example:
{
  "nombre_completo": "Juan Carlos Pérez",
  "telefono": "+54 9 11 5555-1234"
}
Returns the updated Chofer. The edit modal pre-populates nombre_completo, dni, and telefono from the selected driver before sending only the changed values.

darDeBaja()

Soft-deletes a driver by setting activo: false on the backend. The driver record and all associated trip history are preserved.
darDeBaja(id: string): Observable<Chofer>
HTTP call:
DELETE /choferes/{id}
Returns the updated Chofer with activo: false. Deactivated drivers are hidden from the default listing (activos_only=true) but remain visible when queried with activos_only=false.

Driver Lifecycle

1

Register a new driver

Open the registration modal via + Nuevo chofer. Provide at least the driver’s full name. DNI, phone, and a home truck are optional at registration time.
2

Assign to a trip

When creating a trip, only drivers with estado === 'disponible' are shown in the dropdown. Selecting the driver and saving the trip transitions them to the correct state automatically.
3

Edit contact details

Use the Editar action on any driver row to update nombre_completo, dni, or telefono via a PATCH /choferes/{id} call.
4

Deactivate a driver

Use the Dar de baja action to soft-delete the driver. A confirmation dialog (<app-confirmar>) is displayed before the DELETE /choferes/{id} call is made. The driver disappears from the active list but their data remains intact.

Home Truck Assignment (camion_id)

The camion_id on a Chofer record represents an optional default truck preference — the vehicle that is habitually driven by that person. It is purely informational at the driver level.
The truck that actually carries a given shipment is recorded on the Viaje object (Viaje.camion_id), not derived from the driver’s home truck. A driver can be dispatched with any truck regardless of what Chofer.camion_id contains.

Pagination

The driver list uses the same RespuestaPaginada<Chofer> wrapper as all other modules. Pagination state is managed with Angular signals:
pagina       = signal(1);
totalPaginas = signal(1);
total        = signal(0);
tamanoPagina = 20;
The shared <app-paginacion> component emits a (cambioPagina) event which calls cambiarPagina(nueva), updating the signal and re-fetching the current page.

Build docs developers (and LLMs) love