fix: enum stop_type required uppercase values in supabase
This commit is contained in:
@ -12,9 +12,9 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Tipo</label>
|
<label>Tipo</label>
|
||||||
<select v-model="formData.stop_type">
|
<select v-model="formData.stop_type">
|
||||||
<option value="regular">Regular</option>
|
<option value="REGULAR">Regular</option>
|
||||||
<option value="terminal">Terminal</option>
|
<option value="TERMINAL">Terminal</option>
|
||||||
<option value="express_only">Solo Expreso</option>
|
<option value="EXPRESS_ONLY">Solo Expreso</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ const formData = ref({
|
|||||||
name: '',
|
name: '',
|
||||||
latitude: 8.4284, // Default (David)
|
latitude: 8.4284, // Default (David)
|
||||||
longitude: -82.4309,
|
longitude: -82.4309,
|
||||||
stop_type: 'regular',
|
stop_type: 'REGULAR' as import('@/types').StopType,
|
||||||
has_shelter: false,
|
has_shelter: false,
|
||||||
has_seating: false,
|
has_seating: false,
|
||||||
is_accessible: false,
|
is_accessible: false,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/** Type definitions for the SIBU transportation app */
|
/** Type definitions for the SIBU transportation app */
|
||||||
|
|
||||||
export type RouteStatus = 'ACTIVE' | 'INACTIVE' | 'MAINTENANCE'
|
export type RouteStatus = 'ACTIVE' | 'INACTIVE' | 'MAINTENANCE'
|
||||||
export type StopType = 'terminal' | 'regular' | 'express_only'
|
export type StopType = 'TERMINAL' | 'REGULAR' | 'EXPRESS_ONLY'
|
||||||
export type ScheduleType = 'weekday' | 'weekend' | 'holiday'
|
export type ScheduleType = 'weekday' | 'weekend' | 'holiday'
|
||||||
|
|
||||||
export interface Route {
|
export interface Route {
|
||||||
|
|||||||
@ -75,6 +75,9 @@ async function loadStops() {
|
|||||||
|
|
||||||
function translateType(type: string) {
|
function translateType(type: string) {
|
||||||
const types: Record<string, string> = {
|
const types: Record<string, string> = {
|
||||||
|
'REGULAR': 'Regular',
|
||||||
|
'TERMINAL': 'Terminal',
|
||||||
|
'EXPRESS_ONLY': 'Solo Expreso',
|
||||||
'regular': 'Regular',
|
'regular': 'Regular',
|
||||||
'terminal': 'Terminal',
|
'terminal': 'Terminal',
|
||||||
'express_only': 'Solo Expreso'
|
'express_only': 'Solo Expreso'
|
||||||
|
|||||||
@ -264,7 +264,7 @@ async function initRouteMap() {
|
|||||||
name,
|
name,
|
||||||
latitude: lat,
|
latitude: lat,
|
||||||
longitude: lng,
|
longitude: lng,
|
||||||
stop_type: 'regular',
|
stop_type: 'REGULAR',
|
||||||
has_shelter: false,
|
has_shelter: false,
|
||||||
has_seating: false,
|
has_seating: false,
|
||||||
is_accessible: true,
|
is_accessible: true,
|
||||||
@ -274,8 +274,9 @@ async function initRouteMap() {
|
|||||||
allStops.value = await busStopsService.getAllBusStops()
|
allStops.value = await busStopsService.getAllBusStops()
|
||||||
// Add to current route
|
// Add to current route
|
||||||
await addExistingStop(newStop.id)
|
await addExistingStop(newStop.id)
|
||||||
} catch (err) {
|
} catch (err: any) {
|
||||||
alert('Error creando parada')
|
console.error("Error creating map stop:", err)
|
||||||
|
alert('Error creando parada: ' + (err.message || 'Error desconocido'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
41
frontend/test-enum.mjs
Normal file
41
frontend/test-enum.mjs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
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() {
|
||||||
|
await sb.auth.signInWithPassword({ email: 'admin@sibu.com', password: 'Admin123!' })
|
||||||
|
|
||||||
|
console.log("Testing REGULAR");
|
||||||
|
const { data: stopData, error: stopErr } = await sb.from('bus_stops').insert([{
|
||||||
|
name: 'test enum',
|
||||||
|
latitude: 0,
|
||||||
|
longitude: 0,
|
||||||
|
stop_type: 'REGULAR',
|
||||||
|
has_shelter: false,
|
||||||
|
has_seating: false,
|
||||||
|
is_accessible: true,
|
||||||
|
city: 'David'
|
||||||
|
}]).select()
|
||||||
|
|
||||||
|
console.log("REGULAR test:", stopErr ? stopErr.message : "Success")
|
||||||
|
|
||||||
|
if (!stopErr && stopData) {
|
||||||
|
await sb.from('bus_stops').delete().eq('id', stopData[0].id)
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Testing regular");
|
||||||
|
const { error: err2 } = await sb.from('bus_stops').insert([{
|
||||||
|
name: 'test enum',
|
||||||
|
latitude: 0,
|
||||||
|
longitude: 0,
|
||||||
|
stop_type: 'regular',
|
||||||
|
has_shelter: false,
|
||||||
|
has_seating: false,
|
||||||
|
is_accessible: true,
|
||||||
|
city: 'David'
|
||||||
|
}]).select()
|
||||||
|
console.log("regular test:", err2 ? err2.message : "Success")
|
||||||
|
}
|
||||||
|
test()
|
||||||
Reference in New Issue
Block a user