import { useMemo, useState } from "react"; import { Link } from "react-router-dom"; import { Pencil, Search } from "lucide-react"; import { formatDate, formatCurrency } from "@/lib/calculators"; import { EstadoBadge } from "@/components/EstadoBadge"; import { ListDeleteButton } from "./ListDeleteButton"; export interface CotizacionRow { id: string; numero: string; estado: string; fecha: string; cliente: { nombre: string; empresa: string | null }; asesor: { name: string }; servicios: { tipoPago: string; seleccionado: boolean; precio: number }[]; } export function CotizacionesList({ cotizaciones, onRefresh, }: { cotizaciones: CotizacionRow[]; onRefresh: () => void; }) { const [search, setSearch] = useState(""); const filtered = useMemo(() => { if (!search) return cotizaciones; const q = search.toLowerCase(); return cotizaciones.filter( (cot) => cot.numero.toLowerCase().includes(q) || cot.cliente.nombre.toLowerCase().includes(q) || (cot.cliente.empresa || "").toLowerCase().includes(q) || cot.asesor.name.toLowerCase().includes(q) || cot.estado.toLowerCase().includes(q) ); }, [cotizaciones, search]); return ( <>
{search ? "Sin resultados para esa busqueda" : "No hay cotizaciones"}
) : (| No. Cotizacion | Cliente | Asesor | Fecha | Estado | Total Unico | Total Mensual | Acciones |
|---|---|---|---|---|---|---|---|
| {cot.numero} |
{cot.cliente.empresa || cot.cliente.nombre}
{cot.cliente.nombre}
|
{cot.asesor.name} | {formatDate(new Date(cot.fecha))} |
|
{totalUnico > 0 ? formatCurrency(totalUnico) : "-"} | {totalMensual > 0 ? formatCurrency(totalMensual) : "-"} |
|