FlotillasGPS - Sistema completo de monitoreo de flotillas GPS
Sistema completo para monitoreo y gestion de flotas de vehiculos con: - Backend FastAPI con PostgreSQL/TimescaleDB - Frontend React con TypeScript y TailwindCSS - App movil React Native con Expo - Soporte para dispositivos GPS, Meshtastic y celulares - Video streaming en vivo con MediaMTX - Geocercas, alertas, viajes y reportes - Autenticacion JWT y WebSockets en tiempo real Documentacion completa y guias de usuario incluidas.
This commit is contained in:
95
frontend/src/api/viajes.ts
Normal file
95
frontend/src/api/viajes.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
import { api } from './client'
|
||||
import {
|
||||
Viaje,
|
||||
Parada,
|
||||
EventoViaje,
|
||||
ViajeReplayData,
|
||||
PaginatedResponse,
|
||||
} from '@/types'
|
||||
|
||||
export const viajesApi = {
|
||||
// List viajes with pagination
|
||||
list: (params?: {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
vehiculoId?: string
|
||||
conductorId?: string
|
||||
estado?: string
|
||||
desde?: string
|
||||
hasta?: string
|
||||
}): Promise<PaginatedResponse<Viaje>> => {
|
||||
return api.get<PaginatedResponse<Viaje>>('/viajes', params)
|
||||
},
|
||||
|
||||
// Get single viaje
|
||||
get: (id: string): Promise<Viaje> => {
|
||||
return api.get<Viaje>(`/viajes/${id}`)
|
||||
},
|
||||
|
||||
// Get viaje replay data (includes route points, events, recordings)
|
||||
getReplayData: (id: string): Promise<ViajeReplayData> => {
|
||||
return api.get<ViajeReplayData>(`/viajes/${id}/replay`)
|
||||
},
|
||||
|
||||
// Get viaje route
|
||||
getRuta: (id: string): Promise<Array<{
|
||||
lat: number
|
||||
lng: number
|
||||
timestamp: string
|
||||
velocidad: number
|
||||
}>> => {
|
||||
return api.get(`/viajes/${id}/ruta`)
|
||||
},
|
||||
|
||||
// Get viaje events
|
||||
getEventos: (id: string): Promise<EventoViaje[]> => {
|
||||
return api.get<EventoViaje[]>(`/viajes/${id}/eventos`)
|
||||
},
|
||||
|
||||
// Get viaje paradas
|
||||
getParadas: (id: string): Promise<Parada[]> => {
|
||||
return api.get<Parada[]>(`/viajes/${id}/paradas`)
|
||||
},
|
||||
|
||||
// Get current/active viajes
|
||||
getActivos: (): Promise<Viaje[]> => {
|
||||
return api.get<Viaje[]>('/viajes/activos')
|
||||
},
|
||||
|
||||
// Start a new viaje
|
||||
iniciar: (vehiculoId: string, conductorId?: string): Promise<Viaje> => {
|
||||
return api.post<Viaje>('/viajes/iniciar', { vehiculoId, conductorId })
|
||||
},
|
||||
|
||||
// End a viaje
|
||||
finalizar: (id: string): Promise<Viaje> => {
|
||||
return api.post<Viaje>(`/viajes/${id}/finalizar`)
|
||||
},
|
||||
|
||||
// Add a parada to viaje
|
||||
addParada: (id: string, parada: Partial<Parada>): Promise<Parada> => {
|
||||
return api.post<Parada>(`/viajes/${id}/paradas`, parada)
|
||||
},
|
||||
|
||||
// Get viaje statistics
|
||||
getStats: (params?: {
|
||||
vehiculoId?: string
|
||||
conductorId?: string
|
||||
desde?: string
|
||||
hasta?: string
|
||||
}): Promise<{
|
||||
totalViajes: number
|
||||
distanciaTotal: number
|
||||
tiempoTotal: number
|
||||
velocidadPromedio: number
|
||||
paradasTotal: number
|
||||
combustibleTotal: number
|
||||
}> => {
|
||||
return api.get('/viajes/stats', params)
|
||||
},
|
||||
|
||||
// Export viaje
|
||||
exportar: (id: string, formato: 'pdf' | 'excel'): Promise<Blob> => {
|
||||
return api.get(`/viajes/${id}/exportar`, { formato })
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user