Panel de cliente y /cobros: pulido de interfaz, movil y contraste
Panel de cliente - Mis pagos: primero lo que hay que pagar (mas antiguo primero, atraso y motivo de rechazo) con su boton de comprobante; datos bancarios con boton de copiar; historial compacto por programa con los pagos viejos plegados. En movil la tabla anterior recortaba "Subir comprobante": ya no hay tablas. - Inicio: estado de cuenta con saldo, cobro mas antiguo y accion de pagar. Las dobles propuestas muestran el total de cada opcion (antes se sumaban ambas en uno solo). - Mis cotizaciones: lista responsive compartida con el inicio (FilaCotizacion). - Montos respetan la moneda del programa (USD ya no sale como "$"). - Esqueleto de carga para que la navegacion responda al instante. - Avisos push como boton secundario; login con encabezado propio en ?panel=cliente y etiquetas en espanol. /cobros (admin) - Franja de resumen: por cobrar, comprobantes por revisar, programas activos. - Orden por frecuencia de uso: cobrar, revisar comprobantes, programas. - Un solo boton primario; tablas con scroll horizontal en movil (Aprobar y Rechazar quedaban fuera de pantalla); montos por moneda; acentos. Global: --muted pasa de slate-400 (2.6:1) a slate-500 (4.8:1), foco de teclado visible y seleccion de texto con la paleta. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
76e93e6615
commit
6402128dfc
@@ -1,20 +1,14 @@
|
||||
import Link from "next/link";
|
||||
import { redirect } from "next/navigation";
|
||||
import { ArrowRight, FileText } from "lucide-react";
|
||||
import { FileText } from "lucide-react";
|
||||
import { requireRole } from "@/lib/auth";
|
||||
import { prisma } from "@/lib/db";
|
||||
import {
|
||||
IVA_RATE,
|
||||
calcularTotalesCotizacion,
|
||||
calcularTotalesOpcion,
|
||||
formatCurrency,
|
||||
formatDate,
|
||||
} from "@/lib/calculators";
|
||||
import { EstadoBadge } from "@/components/EstadoBadge";
|
||||
import { calcularTotalesCotizacion, calcularTotalesOpcion, conIva } from "@/lib/calculators";
|
||||
import { FilaCotizacion } from "../FilaCotizacion";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
// Lista de cotizaciones del cliente: numero, proyecto, fecha, estado y totales.
|
||||
// Lista de cotizaciones del cliente: numero, proyecto, fecha, estado y totales
|
||||
// (con IVA cuando la cotizacion lo incluye; por opcion si es doble propuesta).
|
||||
export default async function ClienteCotizacionesPage() {
|
||||
const session = await requireRole("cliente");
|
||||
if (!session) redirect("/login?panel=cliente");
|
||||
@@ -38,116 +32,53 @@ export default async function ClienteCotizacionesPage() {
|
||||
return (
|
||||
<div>
|
||||
<div className="mb-8">
|
||||
<h1 className="text-2xl font-bold">Mis cotizaciones</h1>
|
||||
<h1 className="text-2xl font-bold tracking-tight">Mis cotizaciones</h1>
|
||||
<p className="text-muted text-sm mt-1">
|
||||
{cotizaciones.length === 0
|
||||
? "Aún no tienes cotizaciones"
|
||||
: `${cotizaciones.length} cotizacion${cotizaciones.length === 1 ? "" : "es"} a tu nombre`}
|
||||
: `${cotizaciones.length} ${cotizaciones.length === 1 ? "cotización" : "cotizaciones"} a tu nombre`}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{cotizaciones.length === 0 ? (
|
||||
<div className="bg-card-bg rounded-xl border border-border p-12 text-center">
|
||||
<FileText className="w-16 h-16 text-muted mx-auto mb-4" />
|
||||
<FileText className="w-12 h-12 text-muted mx-auto mb-4" />
|
||||
<h2 className="text-lg font-semibold mb-2">No hay cotizaciones todavía</h2>
|
||||
<p className="text-muted">
|
||||
Cuando tengas una cotización disponible aparecerá en esta sección.
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="bg-card-bg rounded-xl border border-border overflow-hidden">
|
||||
<table className="w-full text-sm">
|
||||
<thead>
|
||||
<tr className="border-b border-border bg-gray-50">
|
||||
<th className="text-left px-5 py-3 font-medium text-muted">No. Cotizacion</th>
|
||||
<th className="text-left px-5 py-3 font-medium text-muted">Proyecto</th>
|
||||
<th className="text-left px-5 py-3 font-medium text-muted">Fecha</th>
|
||||
<th className="text-left px-5 py-3 font-medium text-muted">Estado</th>
|
||||
<th className="text-right px-5 py-3 font-medium text-muted">Total Unico</th>
|
||||
<th className="text-right px-5 py-3 font-medium text-muted">Total Mensual</th>
|
||||
<th className="text-right px-5 py-3 font-medium text-muted"> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{cotizaciones.map((c) => {
|
||||
const totales = calcularTotalesCotizacion(c.servicios, {
|
||||
incluirIva: c.incluirIva,
|
||||
});
|
||||
const conIva = (m: number) =>
|
||||
c.incluirIva ? Math.round(m * (1 + IVA_RATE) * 100) / 100 : m;
|
||||
return (
|
||||
<tr key={c.id} className="border-b border-border hover:bg-gray-50 transition-colors">
|
||||
<td className="px-5 py-3">
|
||||
<Link
|
||||
href={`/cliente/cotizaciones/${c.id}`}
|
||||
className="font-medium text-primary hover:underline"
|
||||
>
|
||||
{c.numero}
|
||||
</Link>
|
||||
{c.esDoble && (
|
||||
<span className="ml-2 text-[11px] font-semibold uppercase tracking-wide px-2 py-0.5 rounded-full bg-primary-light text-primary">
|
||||
Doble propuesta
|
||||
</span>
|
||||
)}
|
||||
</td>
|
||||
<td className="px-5 py-3 text-muted">{c.proyecto}</td>
|
||||
<td className="px-5 py-3 text-muted">{formatDate(c.fecha)}</td>
|
||||
<td className="px-5 py-3">
|
||||
<EstadoBadge estado={c.estado} />
|
||||
</td>
|
||||
<td className="px-5 py-3 text-right font-medium">
|
||||
{c.esDoble ? (
|
||||
<div className="space-y-0.5">
|
||||
{(["1", "2"] as const).map((op) => {
|
||||
const t = calcularTotalesOpcion(c.servicios, op);
|
||||
return (
|
||||
<p key={op} className="text-xs">
|
||||
<span className="text-muted">Op {op}:</span>{" "}
|
||||
{t.totalUnico > 0 ? formatCurrency(conIva(t.totalUnico)) : "-"}
|
||||
</p>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
) : totales.totalUnico > 0 ? (
|
||||
formatCurrency(totales.totalUnico)
|
||||
) : (
|
||||
"-"
|
||||
)}
|
||||
</td>
|
||||
<td className="px-5 py-3 text-right font-medium">
|
||||
{c.esDoble ? (
|
||||
<div className="space-y-0.5">
|
||||
{(["1", "2"] as const).map((op) => {
|
||||
const t = calcularTotalesOpcion(c.servicios, op);
|
||||
return (
|
||||
<p key={op} className="text-xs">
|
||||
<span className="text-muted">Op {op}:</span>{" "}
|
||||
{t.totalMensual > 0 ? formatCurrency(conIva(t.totalMensual)) : "-"}
|
||||
</p>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
) : totales.totalMensual > 0 ? (
|
||||
formatCurrency(totales.totalMensual)
|
||||
) : (
|
||||
"-"
|
||||
)}
|
||||
</td>
|
||||
<td className="px-5 py-3 text-right">
|
||||
<Link
|
||||
href={`/cliente/cotizaciones/${c.id}`}
|
||||
className="text-xs text-primary hover:underline inline-flex items-center gap-1"
|
||||
>
|
||||
Ver
|
||||
<ArrowRight className="w-3 h-3" />
|
||||
</Link>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<ul className="bg-card-bg rounded-xl border border-border divide-y divide-border overflow-hidden">
|
||||
{cotizaciones.map((c) => {
|
||||
const totales = calcularTotalesCotizacion(c.servicios, { incluirIva: c.incluirIva });
|
||||
return (
|
||||
<FilaCotizacion
|
||||
key={c.id}
|
||||
id={c.id}
|
||||
numero={c.numero}
|
||||
proyecto={c.proyecto}
|
||||
fecha={c.fecha}
|
||||
estado={c.estado}
|
||||
montos={{ unico: totales.totalUnico, mensual: totales.totalMensual }}
|
||||
opciones={
|
||||
c.esDoble
|
||||
? (["1", "2"] as const).map((op) => {
|
||||
const t = calcularTotalesOpcion(c.servicios, op);
|
||||
return {
|
||||
clave: op,
|
||||
montos: {
|
||||
unico: conIva(t.totalUnico, c.incluirIva),
|
||||
mensual: conIva(t.totalMensual, c.incluirIva),
|
||||
},
|
||||
};
|
||||
})
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user