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

@ -18,7 +18,7 @@
<!-- Version info -->
<div class="version-info">
<p class="app-subtitle">Transporte Público Boquete</p>
<p class="app-version">Versión 1.2.0</p>
<p class="app-version">Versión 2.0.0</p>
</div>
</div>
</template>
@ -28,14 +28,11 @@ import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { useRouteStore } from '@/stores/route'
import { useBusStopStore } from '@/stores/busStop'
import { useAuthStore } from '@/stores/auth'
import { authService } from '@/services/authService'
import { getGoogleRedirectResult } from '@/firebaseConfig'
import { supabase } from '@/supabase'
const router = useRouter()
const routeStore = useRouteStore()
const busStopStore = useBusStopStore()
const authStore = useAuthStore()
const logoVisible = ref(false)
const showLoading = ref(false)
@ -43,14 +40,10 @@ const loadingVisible = ref(false)
const statusMessage = ref('Iniciando SIBU...')
onMounted(async () => {
// Start logo animation
logoVisible.value = true
// Show loading indicator
showLoading.value = true
loadingVisible.value = true
// Perform initialization tasks with a safety timeout
const initTimeout = setTimeout(() => {
console.warn('Initialization taking too long, forcing navigation...')
statusMessage.value = 'Iniciando de todas formas...'
@ -68,54 +61,36 @@ onMounted(async () => {
}
})
function navigate() {
// Navigate based on role
const role = localStorage.getItem('user_role')?.toUpperCase()
if (role === 'ADMIN') {
router.replace('/admin')
} else if (role === 'DRIVER') {
router.replace('/driver')
} else if (role === 'PROMOTER') {
router.replace('/promoter')
} else {
async function navigate() {
const { data: { session } } = await supabase.auth.getSession()
if (!session) {
router.replace('/map')
return
}
const { data: profile } = await supabase
.from('users')
.select('role')
.eq('id', session.user.id)
.single()
const role = profile?.role?.toUpperCase()
if (role === 'ADMIN') router.replace('/admin')
else if (role === 'DRIVER') router.replace('/driver')
else if (role === 'PROMOTER') router.replace('/promoter')
else router.replace('/map')
}
async function performInitializationTasks() {
// Task 1: Check for Google Redirect Result (Mobile Login)
statusMessage.value = 'Verificando sesión...'
try {
const googleResult = await getGoogleRedirectResult()
if (googleResult) {
statusMessage.value = 'Iniciando sesión con Google...'
const response = await authService.googleLogin(googleResult.token)
authStore.login(response.access_token, response.role, response.full_name)
statusMessage.value = `¡Bienvenido ${response.full_name}!`
// Wait a bit to show the welcome message
await new Promise(r => setTimeout(r, 800))
}
} catch (error) {
console.error('Google Redirect handling failed:', error)
}
// Task 2: Check connection and load routes
statusMessage.value = 'Cargando datos de rutas...'
try {
await routeStore.loadRoutes()
} catch (error) {
console.error('Error loading routes:', error)
}
try { await routeStore.loadRoutes() } catch (e) { console.error(e) }
// Task 3: Load bus stops
statusMessage.value = 'Cargando paradas...'
try {
await busStopStore.loadBusStops()
} catch (error) {
console.error('Error loading bus stops:', error)
}
try { await busStopStore.loadBusStops() } catch (e) { console.error(e) }
// Task 4: Prepared
statusMessage.value = 'Listo para usar'
}
</script>
@ -134,7 +109,6 @@ async function performInitializationTasks() {
align-items: center;
z-index: 9999;
}
.splash-content {
display: flex;
flex-direction: column;
@ -142,18 +116,15 @@ async function performInitializationTasks() {
justify-content: center;
flex: 1;
}
.logo-container {
opacity: 0;
transform: scale(0.8);
transition: opacity 0.6s ease-out, transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.logo-container.logo-visible {
opacity: 1;
transform: scale(1);
}
.logo-box {
width: 140px;
height: 140px;
@ -164,14 +135,12 @@ async function performInitializationTasks() {
justify-content: center;
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}
.logo-icon {
width: 100%;
height: 100%;
object-fit: contain;
display: block;
}
.loading-container {
margin-top: 48px;
display: flex;
@ -180,11 +149,7 @@ async function performInitializationTasks() {
opacity: 0;
transition: opacity 0.8s ease-in;
}
.loading-container.loading-visible {
opacity: 1;
}
.loading-container.loading-visible { opacity: 1; }
.spinner {
width: 32px;
height: 32px;
@ -193,22 +158,13 @@ async function performInitializationTasks() {
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
@keyframes spin { to { transform: rotate(360deg); } }
.status-message {
margin-top: 16px;
color: rgba(255, 255, 255, 0.8);
font-size: 14px;
text-align: center;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu",
"Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
}
.version-info {
position: absolute;
bottom: 64px;
@ -219,43 +175,19 @@ async function performInitializationTasks() {
align-items: center;
gap: 8px;
}
.app-subtitle {
color: rgba(255, 255, 255, 0.6);
font-size: 12px;
text-align: center;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu",
"Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
}
.app-version {
color: rgba(255, 255, 255, 0.4);
font-size: 10px;
text-align: center;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu",
"Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
}
/* Responsive adjustments */
@media (max-width: 480px) {
.logo-box {
width: 120px;
height: 120px;
border-radius: 24px;
}
.logo-icon {
width: 85px;
height: 85px;
}
.loading-container {
margin-top: 40px;
}
.version-info {
bottom: 48px;
}
.logo-box { width: 120px; height: 120px; border-radius: 24px; }
.loading-container { margin-top: 40px; }
.version-info { bottom: 48px; }
}
</style>