refactor: migrate fully to Supabase, remove Firebase/Render/Python backend
- DELETED: entire backend/ (Python/FastAPI — replaced by Supabase)
- DELETED: old/ directory (obsolete code)
- DELETED: render.yaml, inject_api.py, check_tags.py, PENDING_FOR_TOMORROW.md
- DELETED: frontend/src/firebaseConfig.ts (Firebase Auth replaced by Supabase Auth)
- DELETED: frontend/src/services/apiClient.ts (HTTP client for dead backend)
- MIGRATED services to Supabase native:
schedulesService, favoritesService, usersService,
telemetryService (stub), reportsService, analyticsService (stub)
- MIGRATED stores/favorites.ts to Supabase direct queries
- MIGRATED views: SplashScreen, AdminTaxis, AdminDrivers, StrategicAnalytics
- MIGRATED utils/imageUrl.ts to Supabase Storage URLs
- FIXED router/index.ts: guard now uses supabase.auth.getSession()
instead of old localStorage auth_token (fixes logout + map loading)
- FIXED AuthView.vue: removed aggressive watch({ immediate: true })
that caused wrong redirects on map route
- FIXED SplashScreen.vue: navigate() now reads Supabase session + role
- FIXED RLS: added INSERT policy on public.users for trigger
- CONFIRMED: admin@sibu.com assigned ADMIN role in Supabase
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
<template>
|
||||
<template>
|
||||
<div class="admin-taxis">
|
||||
<div class="header">
|
||||
<button class="back-link" @click="$router.push('/admin')">← Volver al Panel</button>
|
||||
@ -167,7 +167,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, reactive } from 'vue'
|
||||
import { apiClient, API_URL } from '@/services/apiClient'
|
||||
import { supabase } from '@/supabase'
|
||||
|
||||
const isLoading = ref(false)
|
||||
const taxis = ref<any[]>([])
|
||||
@ -196,10 +196,9 @@ onMounted(() => {
|
||||
async function loadTaxis() {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const response = await apiClient.get('/api/taxis', {
|
||||
params: { is_active: undefined } // Get all taxis
|
||||
})
|
||||
taxis.value = response.data
|
||||
const { data, error } = await supabase.from('taxis').select('*').order('owner_name')
|
||||
if (error) throw error
|
||||
taxis.value = data
|
||||
} catch (e) {
|
||||
console.error('Error loading taxis:', e)
|
||||
} finally {
|
||||
@ -258,35 +257,32 @@ async function saveTaxi() {
|
||||
error.value = ''
|
||||
|
||||
try {
|
||||
const formData = new FormData()
|
||||
formData.append('owner_name', taxiForm.owner_name)
|
||||
formData.append('phone_number', taxiForm.phone_number)
|
||||
formData.append('license_plate', taxiForm.license_plate)
|
||||
formData.append('corregimiento', taxiForm.corregimiento)
|
||||
formData.append('shift', taxiForm.shift)
|
||||
formData.append('rating', String(taxiForm.rating))
|
||||
formData.append('english_speaking', String(taxiForm.english_speaking))
|
||||
formData.append('is_active', String(taxiForm.is_active))
|
||||
|
||||
if (taxiForm.cooperative) formData.append('cooperative', taxiForm.cooperative)
|
||||
if (photoFile.value) formData.append('image', photoFile.value)
|
||||
|
||||
let image_url = editingTaxi.value?.image_url || null
|
||||
|
||||
// Upload image to Supabase Storage if provided
|
||||
if (photoFile.value) {
|
||||
const ext = photoFile.value.name.split('.').pop()
|
||||
const filename = `taxis/${Date.now()}.${ext}`
|
||||
const { error: upErr } = await supabase.storage.from('uploads').upload(filename, photoFile.value)
|
||||
if (upErr) throw upErr
|
||||
const { data: urlData } = supabase.storage.from('uploads').getPublicUrl(filename)
|
||||
image_url = urlData.publicUrl
|
||||
}
|
||||
|
||||
const payload = { ...taxiForm, image_url }
|
||||
|
||||
if (editingTaxi.value) {
|
||||
// Update existing taxi
|
||||
await apiClient.put(`/api/taxis/${editingTaxi.value.id}`, formData, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
const { error: e } = await supabase.from('taxis').update(payload).eq('id', editingTaxi.value.id)
|
||||
if (e) throw e
|
||||
} else {
|
||||
// Create new taxi
|
||||
await apiClient.post('/api/taxis', formData, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
const { error: e } = await supabase.from('taxis').insert([payload])
|
||||
if (e) throw e
|
||||
}
|
||||
|
||||
closeModal()
|
||||
await loadTaxis()
|
||||
} catch (e: any) {
|
||||
error.value = e.response?.data?.detail || 'Error al guardar el taxi'
|
||||
error.value = e.message || 'Error al guardar el taxi'
|
||||
console.error('Error saving taxi:', e)
|
||||
} finally {
|
||||
isSaving.value = false
|
||||
@ -297,7 +293,8 @@ async function deleteTaxi(taxi: any) {
|
||||
if (!confirm(`¿Eliminar a ${taxi.owner_name} del directorio?`)) return
|
||||
|
||||
try {
|
||||
await apiClient.delete(`/api/taxis/${taxi.id}`)
|
||||
const { error: e } = await supabase.from('taxis').delete().eq('id', taxi.id)
|
||||
if (e) throw e
|
||||
await loadTaxis()
|
||||
} catch (e) {
|
||||
alert('Error al eliminar el taxi')
|
||||
@ -315,8 +312,9 @@ function getShiftLabel(shift: string) {
|
||||
}
|
||||
|
||||
function getImageUrl(path: string) {
|
||||
if (!path) return ''
|
||||
if (path.startsWith('http')) return path
|
||||
return `${API_URL}${path.startsWith('/') ? '' : '/'}${path}`
|
||||
return path
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -714,3 +712,5 @@ h1 {
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user