feat: update routes with color and direction, improve admin routes view, and update firebase config/auth
This commit is contained in:
@ -293,16 +293,21 @@ function handleBack() {
|
||||
async function createRoute() {
|
||||
const name = prompt("Nombre de la nueva ruta:")
|
||||
if (!name) return
|
||||
const route = await routesService.createRoute({
|
||||
name,
|
||||
origin_city: 'David',
|
||||
destination_city: 'Boquete',
|
||||
status: 'active',
|
||||
color: '#FEE715',
|
||||
direction: 'outbound'
|
||||
})
|
||||
routes.value = await routesService.getAllRoutes()
|
||||
selectRoute(route)
|
||||
try {
|
||||
const route = await routesService.createRoute({
|
||||
name,
|
||||
origin_city: 'David',
|
||||
destination_city: 'Boquete',
|
||||
status: 'active',
|
||||
color: '#FEE715',
|
||||
direction: 'outbound'
|
||||
})
|
||||
routes.value = await routesService.getAllRoutes()
|
||||
selectRoute(route)
|
||||
} catch (err: any) {
|
||||
console.error('Error creating route:', err)
|
||||
alert('No se pudo crear la ruta: ' + (err.response?.data?.detail || err.message))
|
||||
}
|
||||
}
|
||||
|
||||
async function selectRoute(route: Route) {
|
||||
@ -312,14 +317,19 @@ async function selectRoute(route: Route) {
|
||||
|
||||
async function updateRouteDetails() {
|
||||
if (!selectedRoute.value) return
|
||||
await routesService.updateRoute(selectedRoute.value.id, {
|
||||
name: selectedRoute.value.name,
|
||||
origin_city: selectedRoute.value.origin_city,
|
||||
destination_city: selectedRoute.value.destination_city,
|
||||
average_speed_kmh: selectedRoute.value.average_speed_kmh,
|
||||
status: selectedRoute.value.status,
|
||||
color: selectedRoute.value.color
|
||||
})
|
||||
try {
|
||||
await routesService.updateRoute(selectedRoute.value.id, {
|
||||
name: selectedRoute.value.name,
|
||||
origin_city: selectedRoute.value.origin_city,
|
||||
destination_city: selectedRoute.value.destination_city,
|
||||
average_speed_kmh: selectedRoute.value.average_speed_kmh,
|
||||
status: selectedRoute.value.status,
|
||||
color: selectedRoute.value.color
|
||||
})
|
||||
} catch (err: any) {
|
||||
console.error('Error updating route:', err)
|
||||
// Opcional: mostrar notificación sutil en lugar de alert recurrente
|
||||
}
|
||||
}
|
||||
|
||||
async function addStop() {
|
||||
@ -331,11 +341,16 @@ async function addStop() {
|
||||
|
||||
async function addExistingStop(stopId: string) {
|
||||
if (!selectedRoute.value) return
|
||||
await routesService.addStopToRoute(selectedRoute.value.id, {
|
||||
stop_id: stopId,
|
||||
stop_order: routeStops.value.length + 1
|
||||
})
|
||||
routeStops.value = await routesService.getRouteStops(selectedRoute.value.id)
|
||||
try {
|
||||
await routesService.addStopToRoute(selectedRoute.value.id, {
|
||||
stop_id: stopId,
|
||||
stop_order: routeStops.value.length + 1
|
||||
})
|
||||
routeStops.value = await routesService.getRouteStops(selectedRoute.value.id)
|
||||
} catch (err: any) {
|
||||
console.error('Error adding stop:', err)
|
||||
alert('Error al añadir parada: ' + (err.response?.data?.detail || err.message))
|
||||
}
|
||||
}
|
||||
|
||||
async function updateStop(stop: BusStop) {
|
||||
@ -364,9 +379,14 @@ async function removeStop(stop: BusStop) {
|
||||
async function deleteRoute() {
|
||||
if (!selectedRoute.value) return
|
||||
if (confirm(`Estás SEGURO de que quieres eliminar la ruta ${selectedRoute.value.name}? Esta acción es permanente.`)) {
|
||||
await routesService.deleteRoute(selectedRoute.value.id)
|
||||
selectedRoute.value = null
|
||||
routes.value = await routesService.getAllRoutes()
|
||||
try {
|
||||
await routesService.deleteRoute(selectedRoute.value.id)
|
||||
selectedRoute.value = null
|
||||
routes.value = await routesService.getAllRoutes()
|
||||
} catch (err: any) {
|
||||
console.error('Error deleting route:', err)
|
||||
alert('No se pudo eliminar la ruta: ' + (err.response?.data?.detail || err.message))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user