From 6303aa4b35b62c038375e19003636fb4894c8323 Mon Sep 17 00:00:00 2001 From: Hanzo_dev <2002samudiojohan@gmail.com> Date: Wed, 25 Feb 2026 23:38:05 -0500 Subject: [PATCH] fix: back buttons missing router instance mapping and fix array structure in supabase route stops fetch --- frontend/src/services/routesService.ts | 27 ++++++++++++++++-------- frontend/src/views/AdminBusStops.vue | 4 +++- frontend/src/views/AdminDrivers.vue | 4 +++- frontend/src/views/AdminTaxis.vue | 4 +++- frontend/test-sb.mjs | 29 ++++++++++++++++++++++++++ 5 files changed, 56 insertions(+), 12 deletions(-) create mode 100644 frontend/test-sb.mjs diff --git a/frontend/src/services/routesService.ts b/frontend/src/services/routesService.ts index 4fd8a66..b4a2509 100644 --- a/frontend/src/services/routesService.ts +++ b/frontend/src/services/routesService.ts @@ -42,17 +42,26 @@ export const routesService = { .eq('route_id', routeId) .order('stop_order', { ascending: true }) - if (error) throw new Error(error.message) + if (error) { + console.error('getRouteStops Error:', error) + throw new Error(error.message) + } + + console.log('getRouteStops raw data:', data) // Map back to the expected plain array of BusStop with merged properties - return (data || []).map((row: any) => ({ - ...row.bus_stops, - stop_order: row.stop_order, - travel_time_minutes: row.travel_time_minutes, - stop_delay_minutes: row.stop_delay_minutes, - is_pickup_point: row.is_pickup_point, - is_dropoff_point: row.is_dropoff_point - })) as BusStop[] + return (data || []).map((row: any) => { + // Handle possibility of bus_stops being an array or object + const busStopData = Array.isArray(row.bus_stops) ? row.bus_stops[0] : row.bus_stops; + return { + ...(busStopData || {}), + stop_order: row.stop_order, + travel_time_minutes: row.travel_time_minutes, + stop_delay_minutes: row.stop_delay_minutes, + is_pickup_point: row.is_pickup_point, + is_dropoff_point: row.is_dropoff_point + } + }) as BusStop[] }, /** Create a new route (Admin) */ diff --git a/frontend/src/views/AdminBusStops.vue b/frontend/src/views/AdminBusStops.vue index 09fe99b..1b6ff8d 100644 --- a/frontend/src/views/AdminBusStops.vue +++ b/frontend/src/views/AdminBusStops.vue @@ -1,7 +1,7 @@