import Link from "next/link"; import { FileText, Plus, Users, Database } from "lucide-react"; import { prisma } from "@/lib/db"; import { formatCurrency, formatDate } from "@/lib/calculators"; import { EstadoBadge } from "@/components/EstadoBadge"; export const dynamic = "force-dynamic"; export default async function DashboardPage() { const [ totalCotizaciones, cotizacionesRecientes, totalClientes, totalServicios, ] = await Promise.all([ prisma.cotizacion.count(), prisma.cotizacion.findMany({ take: 10, orderBy: { createdAt: "desc" }, select: { id: true, numero: true, fecha: true, estado: true, cliente: { select: { nombre: true, empresa: true } }, servicios: { select: { tipoPago: true, seleccionado: true, precio: true }, }, }, }), prisma.cliente.count(), prisma.servicioCatalogo.count({ where: { activo: true } }), ]); const stats = [ { label: "Cotizaciones", value: totalCotizaciones, icon: FileText, color: "text-primary", bg: "bg-primary-light", }, { label: "Clientes", value: totalClientes, icon: Users, color: "text-secondary", bg: "bg-purple-100", }, { label: "Servicios Activos", value: totalServicios, icon: Database, color: "text-accent", bg: "bg-cyan-100", }, ]; return (
Bienvenido al Cotizador E3
{stat.value}
{stat.label}
No hay cotizaciones. Crea la primera.
| No. | Cliente | Fecha | Estado | Servicios |
|---|---|---|---|---|
| {cot.numero} | {cot.cliente.empresa || cot.cliente.nombre} | {formatDate(cot.fecha)} |
|
{totalUnico > 0 && ( Unico: {formatCurrency(totalUnico)} )} {totalMensual > 0 && ( Mensual: {formatCurrency(totalMensual)} )} |