Trips are the central entity of the Aibar SRL App. Every movement of cargo is modelled as aDocumentation 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.
Viaje — capturing the assigned driver, the optional truck, origin and destination, client, freight description, fare, and kilometre count. The full lifecycle of a trip, from creation through departure and arrival to cancellation, is tracked via a state machine so that fleet managers always have an accurate real-time picture of operations.
Trip States
A trip moves through up to four states. The normal path ispendiente → en_curso → finalizado. At any point before finalization the trip can also move to cancelado.
estado field is a TypeScript union type defined in viaje.model.ts:
| State | Meaning |
|---|---|
pendiente | Trip created but not yet started. The driver has been assigned and is on standby. |
en_curso | Trip is underway. The driver’s status becomes viajando. |
finalizado | Trip completed. Kilometres travelled have been recorded. |
cancelado | Trip was called off. A cancellation reason is stored for audit purposes. |
Data Models
Viaje Interface
The full read model returned by the API for every trip:
ViajeCreate Interface
The payload sent when creating a new trip. Required fields are chofer_id, origen, destino, and fecha_inicio; all other fields are optional:
ViajeCreate Fields
UUID of the driver to assign to this trip. The driver must have
estado: 'disponible' at the time of creation.Free-text departure location (city, address, or waypoint name).
Free-text arrival location.
ISO 8601 datetime string for the planned departure. The UI converts a
datetime-local input value with new Date(...).toISOString() before sending.UUID of the truck assigned to this trip. Optional — can be omitted when the truck is not yet decided.
Name of the customer or company receiving the cargo.
Free-text description of the freight being transported.
Agreed fare for the trip in the local currency.
ViajesService
ViajesService is an Angular Injectable provided at the root level. It wraps all REST calls to the /viajes resource.
listar()
Fetches a paginated list of trips, with an optional state filter.
estado is omitted (or 'todos' is selected in the UI), the query string parameter is not appended and the API returns trips in all states.
crear()
Creates a new trip in pendiente state.
ViajeCreate object serialised as JSON.
Returns the newly created Viaje. If the driver is no longer available (race condition), the API responds with 409 Conflict.
iniciar()
Transitions a pendiente trip to en_curso.
{}). Returns the updated Viaje.
finalizar()
Closes an en_curso trip and records the end date and kilometres driven.
Viaje in finalizado state.
cancelar()
Cancels a pendiente or en_curso trip and stores the reason.
Viaje in cancelado state.
Listing and Filtering Trips
TheListaViajes component exposes five filter buttons. Selecting a filter resets pagination to page 1 and re-fetches the list:
'todos' option passes undefined to listar(), omitting the &estado= parameter entirely so the backend returns all states.
Creating a Trip
Open the new-trip modal
The UI calls
abrirModalNuevoViaje(), which simultaneously fetches available drivers (estado === 'disponible') and active trucks to populate the form dropdowns.Fill in required fields
chofer_id, origen, destino, and fecha_inicio are mandatory. The component validates these before calling the service.Submit
confirmarNuevoViaje() converts the local datetime to an ISO string and calls viajesService.crear().A trip can only be started if the assigned driver’s
estado is disponible at the moment of creation. The driver list in the new-trip modal is pre-filtered to show only drivers with estado === 'disponible'. If the driver’s state changes between loading the form and submitting, the API returns 409 Conflict.Cancelling a Trip
Cancellation is available for bothpendiente and en_curso trips. The motivoCancelacion field is required and must contain at least 5 characters — the component enforces this before calling the service:
Pagination
All list responses are wrapped inRespuestaPaginada<Viaje>. The component stores pagina, totalPaginas, and total as Angular signals and passes them to the shared <app-paginacion> component:
pagina to 1 to avoid landing on a non-existent page.