// Vehicle Dashboard JavaScript - Navegación por tarjetas class VehicleDashboard { constructor() { this.currentView = 'brands'; // brands, models, vehicles this.selectedBrand = null; this.selectedModel = null; this.allVehicles = []; this.filteredVehicles = []; this.stats = { brands: 0, models: 0, vehicles: 0 }; this.init(); } async init() { await this.loadStats(); await this.showBrands(); this.bindFilterEvents(); } async loadStats() { try { const [brandsRes, vehiclesRes] = await Promise.all([ fetch('/api/brands'), fetch('/api/vehicles') ]); if (brandsRes.ok && vehiclesRes.ok) { const brands = await brandsRes.json(); const vehicles = await vehiclesRes.json(); // Contar modelos únicos const uniqueModels = new Set(vehicles.map(v => `${v.brand}-${v.model}`)); this.stats.brands = brands.length; this.stats.models = uniqueModels.size; this.stats.vehicles = vehicles.length; document.getElementById('totalBrands').textContent = this.stats.brands; document.getElementById('totalModels').textContent = this.stats.models; document.getElementById('totalVehicles').textContent = this.stats.vehicles; } } catch (error) { console.error('Error loading stats:', error); } } updateBreadcrumb() { const breadcrumb = document.getElementById('breadcrumb'); let html = ''; if (this.currentView === 'brands') { html = `
Agrega algunas marcas a la base de datos
${error.message}
Esta marca no tiene modelos registrados
${error.message}
${error.message}
Intenta ajustar los filtros