fix: back buttons missing router instance mapping and fix array structure in supabase route stops fetch
This commit is contained in:
@ -42,17 +42,26 @@ export const routesService = {
|
|||||||
.eq('route_id', routeId)
|
.eq('route_id', routeId)
|
||||||
.order('stop_order', { ascending: true })
|
.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
|
// Map back to the expected plain array of BusStop with merged properties
|
||||||
return (data || []).map((row: any) => ({
|
return (data || []).map((row: any) => {
|
||||||
...row.bus_stops,
|
// 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,
|
stop_order: row.stop_order,
|
||||||
travel_time_minutes: row.travel_time_minutes,
|
travel_time_minutes: row.travel_time_minutes,
|
||||||
stop_delay_minutes: row.stop_delay_minutes,
|
stop_delay_minutes: row.stop_delay_minutes,
|
||||||
is_pickup_point: row.is_pickup_point,
|
is_pickup_point: row.is_pickup_point,
|
||||||
is_dropoff_point: row.is_dropoff_point
|
is_dropoff_point: row.is_dropoff_point
|
||||||
})) as BusStop[]
|
}
|
||||||
|
}) as BusStop[]
|
||||||
},
|
},
|
||||||
|
|
||||||
/** Create a new route (Admin) */
|
/** Create a new route (Admin) */
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="admin-bus-stops">
|
<div class="admin-bus-stops">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<button class="back-link" @click="$router.push('/admin')">← Volver al Panel</button>
|
<button class="back-link" @click="router.push('/admin')">← Volver al Panel</button>
|
||||||
<h1>Gestionar Paradas</h1>
|
<h1>Gestionar Paradas</h1>
|
||||||
<button class="add-button" @click="openCreate">
|
<button class="add-button" @click="openCreate">
|
||||||
<span class="material-icons">add</span> Nueva Parada
|
<span class="material-icons">add</span> Nueva Parada
|
||||||
@ -48,10 +48,12 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
import { busStopsService } from '@/services/busStopsService'
|
import { busStopsService } from '@/services/busStopsService'
|
||||||
import type { BusStop } from '@/types'
|
import type { BusStop } from '@/types'
|
||||||
import BusStopEditor from '@/components/BusStopEditor.vue'
|
import BusStopEditor from '@/components/BusStopEditor.vue'
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
const stops = ref<BusStop[]>([])
|
const stops = ref<BusStop[]>([])
|
||||||
const isLoading = ref(true)
|
const isLoading = ref(true)
|
||||||
const error = ref<string | null>(null)
|
const error = ref<string | null>(null)
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="admin-drivers">
|
<div class="admin-drivers">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<button class="back-link" @click="$router.push('/admin')">← Volver al Panel</button>
|
<button class="back-link" @click="router.push('/admin')">← Volver al Panel</button>
|
||||||
<h1>Gestión de Conductores y Taxis</h1>
|
<h1>Gestión de Conductores y Taxis</h1>
|
||||||
<div class="header-actions">
|
<div class="header-actions">
|
||||||
<button class="btn-primary" @click="openRegisterModal">
|
<button class="btn-primary" @click="openRegisterModal">
|
||||||
@ -336,8 +336,10 @@
|
|||||||
import { ref, onMounted, reactive, computed } from 'vue'
|
import { ref, onMounted, reactive, computed } from 'vue'
|
||||||
import { usersService } from '@/services/usersService'
|
import { usersService } from '@/services/usersService'
|
||||||
import { authService } from '@/services/authService'
|
import { authService } from '@/services/authService'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
import { supabase } from '@/supabase'
|
import { supabase } from '@/supabase'
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
const activeTab = ref<'drivers' | 'taxis'>('drivers')
|
const activeTab = ref<'drivers' | 'taxis'>('drivers')
|
||||||
const isLoading = ref(false)
|
const isLoading = ref(false)
|
||||||
const activeDrivers = ref<any[]>([])
|
const activeDrivers = ref<any[]>([])
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="admin-taxis">
|
<div class="admin-taxis">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<button class="back-link" @click="$router.push('/admin')">← Volver al Panel</button>
|
<button class="back-link" @click="router.push('/admin')">← Volver al Panel</button>
|
||||||
<h1>Directorio de Taxis</h1>
|
<h1>Directorio de Taxis</h1>
|
||||||
<button class="btn-primary" @click="openModal()">
|
<button class="btn-primary" @click="openModal()">
|
||||||
<span class="material-icons">add</span>
|
<span class="material-icons">add</span>
|
||||||
@ -167,8 +167,10 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, reactive } from 'vue'
|
import { ref, onMounted, reactive } from 'vue'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
import { supabase } from '@/supabase'
|
import { supabase } from '@/supabase'
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
const isLoading = ref(false)
|
const isLoading = ref(false)
|
||||||
const taxis = ref<any[]>([])
|
const taxis = ref<any[]>([])
|
||||||
const showModal = ref(false)
|
const showModal = ref(false)
|
||||||
|
|||||||
29
frontend/test-sb.mjs
Normal file
29
frontend/test-sb.mjs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import { createClient } from '@supabase/supabase-js'
|
||||||
|
|
||||||
|
const SUPABASE_URL = 'https://bjgixlugjzsccazdfmph.supabase.co'
|
||||||
|
const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImJqZ2l4bHVnanpzY2NhemRmbXBoIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzIwNjQyMTAsImV4cCI6MjA4NzY0MDIxMH0.untLQoPi4yUr3cPnxo23wYSlg6xnNK0daKu9UHmFTp8'
|
||||||
|
const sb = createClient(SUPABASE_URL, SUPABASE_ANON_KEY)
|
||||||
|
|
||||||
|
async function test() {
|
||||||
|
console.log("Fetching a route and a bus stop to link...");
|
||||||
|
const { data: route } = await sb.from('routes').select('id').limit(1);
|
||||||
|
const { data: stop } = await sb.from('bus_stops').select('id').limit(1);
|
||||||
|
|
||||||
|
if (route?.[0] && stop?.[0]) {
|
||||||
|
console.log("Upserting route_stop link...");
|
||||||
|
const res = await sb.from('route_stops').upsert([{
|
||||||
|
route_id: route[0].id,
|
||||||
|
stop_id: stop[0].id,
|
||||||
|
stop_order: 1
|
||||||
|
}]).select()
|
||||||
|
console.log("Insert response:", JSON.stringify(res, null, 2))
|
||||||
|
|
||||||
|
console.log("Testing join...")
|
||||||
|
const { data, error } = await sb.from('route_stops').select('*, bus_stops(*)')
|
||||||
|
console.log('Join Data:', JSON.stringify(data?.[0], null, 2))
|
||||||
|
console.log('Join Error:', error)
|
||||||
|
} else {
|
||||||
|
console.log("No existing route or stop to link.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
test()
|
||||||
Reference in New Issue
Block a user