@page "/" @attribute [Authorize] @inject IDashboardService DashboardSvc Dashboard - AutoTaller ERP @if (kpi == null) { } else {
Órdenes recientes Ver todas
@if (ordenes != null && ordenes.Any()) {
@foreach (var ot in ordenes) { var pct = EstadoToPct(ot.Estado);
@ot.Numero @ot.Vehiculo · @ot.Placa @ot.Cliente
@ot.Estado
}
} else { No hay órdenes registradas todavía. Crea la primera. }
@kpi.OrdenesTerminadasHoy Terminadas hoy
S/. @kpi.IngresosHoy.ToString("N0") Ingresos del día
S/. @kpi.MontoFacturasVencidas.ToString("N0") Facturas vencidas
DICIEMBRE S/. @kpi.IngresosHoy.ToString("N3")
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Métricas operativas del mes en curso.
@DateTime.Now.ToString("MMMM").ToUpper()
Tendencia semanal de facturación Últimos 7 días
@if (semana != null && semana.Any()) { }
Alertas accionables @(alertas?.Count ?? 0)
@if (alertas != null && alertas.Any()) { @foreach (var a in alertas.Take(6)) { @a.Titulo @a.Mensaje } } else { Todo en orden, sin alertas críticas. }
} @code { [Inject] NavigationManager Nav { get; set; } = default!; private DashboardKpiDto? kpi; private List? semana; private List? mes; private List? alertas; private List? ordenes; protected override async Task OnInitializedAsync() { await CargarAsync(); } private async Task CargarAsync() { try { var t1 = DashboardSvc.ObtenerKpisAsync(); var t2 = DashboardSvc.ObtenerTendenciaSemanalAsync(); var t3 = DashboardSvc.ObtenerTendenciaMensualAsync(); var t4 = DashboardSvc.ObtenerAlertasAsync(); var t5 = DashboardSvc.ObtenerOrdenesRecientesAsync(6); await Task.WhenAll(t1, t2, t3, t4, t5); kpi = t1.Result; semana = t2.Result; mes = t3.Result; alertas = t4.Result; ordenes = t5.Result; } catch { kpi = new DashboardKpiDto(); semana = new(); mes = new(); alertas = new(); ordenes = new(); } } private static int EstadoToPct(string estado) => estado switch { "Recibido" => 15, "EnDiagnostico" => 30, "EnReparacion" => 55, "EnEsperaRepuesto" => 45, "ControlCalidad" => 80, "Listo" => 95, "Entregado" => 100, _ => 10 }; private static Color EstadoToColor(string estado) => estado switch { "Entregado" => Color.Success, "Listo" => Color.Success, "ControlCalidad" => Color.Info, "EnReparacion" => Color.Primary, "EnEsperaRepuesto" => Color.Warning, "Cancelado" => Color.Error, _ => Color.Default }; private static Severity SeverityFromString(string s) => s switch { "error" => Severity.Error, "warning" => Severity.Warning, "success" => Severity.Success, _ => Severity.Info }; }