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:
2026-02-25 21:49:26 -05:00
parent 7cd97365f2
commit 84055a25de
267 changed files with 377 additions and 37834 deletions

View File

@ -1,6 +1,6 @@
import { defineStore } from 'pinia'
import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
import { apiClient } from '@/services/apiClient'
import { supabase } from '@/supabase'
export interface Favorite {
id: string
@ -16,19 +16,24 @@ export const useFavoritesStore = defineStore('favorites', () => {
const favorites = ref<Favorite[]>([])
const isLoading = ref(false)
// Computed
const coupons = computed(() => favorites.value.filter(f => f.item_type === 'coupon'))
const businesses = computed(() => favorites.value.filter(f => f.item_type === 'business'))
const taxis = computed(() => favorites.value.filter(f => f.item_type === 'taxi'))
const routes = computed(() => favorites.value.filter(f => f.item_type === 'route'))
const stops = computed(() => favorites.value.filter(f => f.item_type === 'stop'))
// Actions
async function loadFavorites() {
isLoading.value = true
try {
const response = await apiClient.get('/api/favorites')
favorites.value = response.data
const { data: userData } = await supabase.auth.getUser()
if (!userData?.user) { favorites.value = []; return }
const { data, error } = await supabase
.from('favorites')
.select('*')
.eq('user_id', userData.user.id)
if (error) throw error
favorites.value = data as Favorite[]
} catch (error) {
console.error('Error loading favorites:', error)
} finally {
@ -43,19 +48,20 @@ export const useFavoritesStore = defineStore('favorites', () => {
itemImage?: string
) {
try {
const response = await apiClient.post('/api/favorites', {
const { data: userData } = await supabase.auth.getUser()
if (!userData?.user) throw new Error('Not authenticated')
const { data, error } = await supabase.from('favorites').insert([{
user_id: userData.user.id,
item_type: itemType,
item_id: itemId,
item_name: itemName,
item_image: itemImage
})
favorites.value.unshift(response.data)
}]).select().single()
if (error) throw error
favorites.value.unshift(data as Favorite)
return true
} catch (error: any) {
if (error.response?.status === 400) {
// Already favorited
return false
}
} catch (error) {
console.error('Error adding favorite:', error)
throw error
}
@ -63,7 +69,15 @@ export const useFavoritesStore = defineStore('favorites', () => {
async function removeFavorite(itemType: string, itemId: string) {
try {
await apiClient.delete(`/api/favorites/${itemType}/${itemId}`)
const { data: userData } = await supabase.auth.getUser()
if (!userData?.user) throw new Error('Not authenticated')
const { error } = await supabase.from('favorites')
.delete()
.eq('user_id', userData.user.id)
.eq('item_type', itemType)
.eq('item_id', itemId)
if (error) throw error
favorites.value = favorites.value.filter(
f => !(f.item_type === itemType && f.item_id === itemId)
)
@ -83,7 +97,6 @@ export const useFavoritesStore = defineStore('favorites', () => {
const existing = favorites.value.find(
f => f.item_type === itemType && f.item_id === itemId
)
if (existing) {
await removeFavorite(itemType, itemId)
return false
@ -100,17 +113,7 @@ export const useFavoritesStore = defineStore('favorites', () => {
}
return {
favorites,
isLoading,
coupons,
businesses,
taxis,
routes,
stops,
loadFavorites,
addFavorite,
removeFavorite,
toggleFavorite,
isFavorite
favorites, isLoading, coupons, businesses, taxis, routes, stops,
loadFavorites, addFavorite, removeFavorite, toggleFavorite, isFavorite
}
})