Cobros recurrentes: panel de cliente, comprobantes verificados y notificaciones
- Panel de cliente con acceso propio (role=cliente): resumen, cotizaciones con descarga PDF y guia de pagos recurrentes con subida de comprobante (imagen->WebP o PDF). - Módulo admin /cobros: programas de pago (semanal/quincenal/mensual), generación idempotente manual y automatica cada hora (scheduler en instrumentation, zona America/Mexico_City), revisión de comprobantes con aprobar/rechazar (el rechazo borra el archivo del servidor y permite re-subir). - Cuentas de cliente creadas/rotadas/revocadas desde la página de clientes. - Notificaciones: servicio SMTP configurable por env (se omite con aviso si no hay credenciales) y Web Push con VAPID + service worker. - Separación de roles en middleware (cliente solo ve /cliente, staff no entra al panel de cliente; PDF y comprobantes son rutas compartidas con validación de pertenencia). - Producción: volumen uploads_data en ambos compose, env vars documentadas en .env.example, migración 20261020000000.
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
"use client";
|
||||
|
||||
import { Check, X, FileText } from "lucide-react";
|
||||
import { formatCurrency } from "@/lib/calculators";
|
||||
import { formatFechaCorta } from "@/lib/cobros-fechas";
|
||||
import { EstadoPagoBadge } from "./EstadoPagoBadge";
|
||||
import type { PagoRow } from "./types";
|
||||
|
||||
export function PagosTabla({
|
||||
pagos,
|
||||
cargando,
|
||||
onAprobar,
|
||||
onRechazar,
|
||||
}: {
|
||||
pagos: PagoRow[];
|
||||
cargando: boolean;
|
||||
onAprobar: (p: PagoRow) => void;
|
||||
onRechazar: (p: PagoRow) => void;
|
||||
}) {
|
||||
if (cargando) {
|
||||
return (
|
||||
<div className="bg-card-bg rounded-xl border border-border p-12 text-center">
|
||||
<p className="text-muted">Cargando cobros...</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (pagos.length === 0) {
|
||||
return (
|
||||
<div className="bg-card-bg rounded-xl border border-border p-12 text-center">
|
||||
<h3 className="text-lg font-semibold mb-2">No hay cobros</h3>
|
||||
<p className="text-muted">
|
||||
Genera cobros con el boton o ajusta los filtros
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<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">Fecha</th>
|
||||
<th className="text-left px-5 py-3 font-medium text-muted">Concepto</th>
|
||||
<th className="text-left px-5 py-3 font-medium text-muted">Cliente</th>
|
||||
<th className="text-right px-5 py-3 font-medium text-muted">Monto</th>
|
||||
<th className="text-center px-5 py-3 font-medium text-muted">Estado</th>
|
||||
<th className="text-center px-5 py-3 font-medium text-muted">Comprobante</th>
|
||||
<th className="text-center px-5 py-3 font-medium text-muted">Acciones</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{pagos.map((p) => (
|
||||
<tr key={p.id} className="border-b border-border hover:bg-gray-50">
|
||||
<td className="px-5 py-3">{formatFechaCorta(new Date(p.fecha))}</td>
|
||||
<td className="px-5 py-3">{p.programa.concepto}</td>
|
||||
<td className="px-5 py-3">{p.programa.cliente.nombre}</td>
|
||||
<td className="px-5 py-3 text-right">{formatCurrency(p.monto)}</td>
|
||||
<td className="px-5 py-3 text-center">
|
||||
<EstadoPagoBadge estado={p.estado} />
|
||||
{p.estado === "rechazado" && p.rechazoMotivo && (
|
||||
<div className="text-xs text-muted mt-1">{p.rechazoMotivo}</div>
|
||||
)}
|
||||
</td>
|
||||
<td className="px-5 py-3 text-center">
|
||||
{p.comprobante ? (
|
||||
<a
|
||||
href={`/api/comprobantes/${p.id}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center gap-1 text-xs text-primary hover:underline"
|
||||
>
|
||||
<FileText className="w-3 h-3" />
|
||||
Ver
|
||||
</a>
|
||||
) : (
|
||||
<span className="text-muted text-xs">—</span>
|
||||
)}
|
||||
</td>
|
||||
<td className="px-5 py-3">
|
||||
{p.estado === "en_revision" ? (
|
||||
<div className="flex items-center justify-center gap-3">
|
||||
<button
|
||||
onClick={() => onAprobar(p)}
|
||||
className="text-xs text-success hover:underline flex items-center gap-1"
|
||||
>
|
||||
<Check className="w-3 h-3" />
|
||||
Aprobar
|
||||
</button>
|
||||
<button
|
||||
onClick={() => onRechazar(p)}
|
||||
className="text-xs text-danger hover:underline flex items-center gap-1"
|
||||
>
|
||||
<X className="w-3 h-3" />
|
||||
Rechazar
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<span className="text-muted text-xs">—</span>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user