fix(admin): nav issues and blank screens fix

This commit is contained in:
2026-02-26 16:20:59 -05:00
parent 10cb37c866
commit 34a73f0f94
8 changed files with 57 additions and 15 deletions

View File

@ -92,6 +92,7 @@ const router = createRouter({
path: '/admin/routes', path: '/admin/routes',
name: 'admin-routes', name: 'admin-routes',
component: () => import('@/views/AdminRoutes.vue'), component: () => import('@/views/AdminRoutes.vue'),
meta: { requiresAuth: true, role: 'ADMIN' }
}, },
{ {
path: '/admin/reports', path: '/admin/reports',

View File

@ -2,7 +2,30 @@
* Reports are now generated directly from Supabase queries in the AdminReports view. */ * Reports are now generated directly from Supabase queries in the AdminReports view. */
import { supabase } from '@/supabase'; import { supabase } from '@/supabase';
export interface Report {
id: string;
user_id: string;
user_name?: string;
message: string;
status: 'pending' | 'resolved' | 'archived';
created_at: string;
}
export const reportsService = { export const reportsService = {
async getReports(): Promise<Report[]> {
const { data, error } = await supabase.from('reports').select('*').order('created_at', { ascending: false })
if (error) {
console.warn('Reports table might not exist or error fetching', error)
return []
}
return data as Report[]
},
async updateReportStatus(id: string, status: string): Promise<void> {
const { error } = await supabase.from('reports').update({ status }).eq('id', id)
if (error) throw new Error(error.message)
},
async getRoutesReport() { async getRoutesReport() {
const { data, error } = await supabase.from('routes').select('*') const { data, error } = await supabase.from('routes').select('*')
if (error) throw new Error(error.message) if (error) throw new Error(error.message)

View File

@ -65,7 +65,8 @@ onMounted(loadStops)
async function loadStops() { async function loadStops() {
isLoading.value = true isLoading.value = true
try { try {
stops.value = await busStopsService.getAllBusStops() const data = await busStopsService.getAllBusStops()
stops.value = data || []
} catch (e) { } catch (e) {
error.value = 'Error al cargar las paradas' error.value = 'Error al cargar las paradas'
} finally { } finally {

View File

@ -399,14 +399,16 @@ async function loadData() {
isLoading.value = true isLoading.value = true
try { try {
// Load drivers from Supabase // Load drivers from Supabase
const { data: drivers } = await supabase.from('users').select('*, driver_profiles(*)').eq('role', 'DRIVER') const { data: drivers, error: errorDrivers } = await supabase.from('users').select('*, driver_profiles(*)').eq('role', 'DRIVER')
if (errorDrivers) throw errorDrivers
activeDrivers.value = drivers || [] activeDrivers.value = drivers || []
// Load taxis from Supabase // Load taxis from Supabase
const { data: taxisData } = await supabase.from('taxis').select('*').order('owner_name') const { data: taxisData, error: errorTaxis } = await supabase.from('taxis').select('*').order('owner_name')
if (errorTaxis) throw errorTaxis
taxis.value = taxisData || [] taxis.value = taxisData || []
} catch (e) { } catch (e) {
console.error(e) console.error('Error cargando datos:', e)
} finally { } finally {
isLoading.value = false isLoading.value = false
} }

View File

@ -90,7 +90,8 @@ onMounted(async () => {
async function fetchReports() { async function fetchReports() {
isLoading.value = true isLoading.value = true
try { try {
reports.value = await reportsService.getReports() const data = await reportsService.getReports()
reports.value = data || []
} catch (e) { } catch (e) {
console.error('Error fetching reports:', e) console.error('Error fetching reports:', e)
} finally { } finally {

View File

@ -206,12 +206,18 @@ onMounted(async () => {
}) })
async function loadInitialData() { async function loadInitialData() {
try {
const [routesData, stopsData] = await Promise.all([ const [routesData, stopsData] = await Promise.all([
routesService.getAllRoutes(), routesService.getAllRoutes(),
busStopsService.getAllBusStops() busStopsService.getAllBusStops()
]) ])
routes.value = routesData || [] routes.value = routesData || []
allStops.value = stopsData || [] allStops.value = stopsData || []
} catch (e) {
console.error('Error loading initial data:', e)
routes.value = []
allStops.value = []
}
} }
const availableStops = computed(() => { const availableStops = computed(() => {

View File

@ -159,7 +159,8 @@ const form = ref({
onMounted(async () => { onMounted(async () => {
try { try {
routes.value = await routesService.getAllRoutes() const data = await routesService.getAllRoutes()
routes.value = data || []
} catch (e) { } catch (e) {
console.error('Error loading routes', e) console.error('Error loading routes', e)
} }
@ -177,7 +178,8 @@ async function loadSchedules() {
isLoadingSchedules.value = true isLoadingSchedules.value = true
try { try {
// Get all schedules including drafts (false for onlyPublished) // Get all schedules including drafts (false for onlyPublished)
schedules.value = await schedulesService.getRouteSchedules(selectedRouteId.value, false) const data = await schedulesService.getRouteSchedules(selectedRouteId.value, false)
schedules.value = data || []
} catch (e) { } catch (e) {
console.error('Error loading schedules', e) console.error('Error loading schedules', e)
} finally { } finally {
@ -347,6 +349,11 @@ async function handleDelete(id: string) {
cursor: pointer; cursor: pointer;
} }
.premium-select option {
background: var(--bg-primary, #1e1e2d);
color: var(--text-primary, #ffffff);
}
.actions-header { .actions-header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;

View File

@ -200,9 +200,10 @@ async function loadTaxis() {
try { try {
const { data, error } = await supabase.from('taxis').select('*').order('owner_name') const { data, error } = await supabase.from('taxis').select('*').order('owner_name')
if (error) throw error if (error) throw error
taxis.value = data taxis.value = data || []
} catch (e) { } catch (e) {
console.error('Error loading taxis:', e) console.error('Error cargando taxis:', e)
error.value = 'Failed to load taxis'
} finally { } finally {
isLoading.value = false isLoading.value = false
} }