From cdb6f0c94e84af04bf809bbcea96f80ff1802898 Mon Sep 17 00:00:00 2001 From: Consultoria AS Date: Tue, 17 Feb 2026 02:38:24 +0000 Subject: [PATCH] feat(web): integrate CFDI viewer modal into CFDI page - Add Eye button to table rows to view invoice - Add loading state while fetching CFDI details - Integrate CfdiViewerModal component Co-Authored-By: Claude Opus 4.5 --- apps/web/app/(dashboard)/cfdi/page.tsx | 45 ++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/apps/web/app/(dashboard)/cfdi/page.tsx b/apps/web/app/(dashboard)/cfdi/page.tsx index e0f4f3c..a415659 100644 --- a/apps/web/app/(dashboard)/cfdi/page.tsx +++ b/apps/web/app/(dashboard)/cfdi/page.tsx @@ -9,9 +9,11 @@ import { Label } from '@/components/ui/label'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; import { useCfdis, useCreateCfdi, useDeleteCfdi } from '@/lib/hooks/use-cfdi'; import { createManyCfdis } from '@/lib/api/cfdi'; -import type { CfdiFilters, TipoCfdi } from '@horux/shared'; +import type { CfdiFilters, TipoCfdi, Cfdi } from '@horux/shared'; import type { CreateCfdiData } from '@/lib/api/cfdi'; -import { FileText, Search, ChevronLeft, ChevronRight, Plus, Upload, Trash2, X, FileUp, CheckCircle, AlertCircle, Loader2 } from 'lucide-react'; +import { FileText, Search, ChevronLeft, ChevronRight, Plus, Upload, Trash2, X, FileUp, CheckCircle, AlertCircle, Loader2, Eye } from 'lucide-react'; +import { CfdiViewerModal } from '@/components/cfdi/cfdi-viewer-modal'; +import { getCfdiById } from '@/lib/api/cfdi'; import { useAuthStore } from '@/stores/auth-store'; import { useTenantViewStore } from '@/stores/tenant-view-store'; import { useQueryClient } from '@tanstack/react-query'; @@ -255,6 +257,23 @@ export default function CfdiPage() { const createCfdi = useCreateCfdi(); const deleteCfdi = useDeleteCfdi(); + // CFDI Viewer state + const [viewingCfdi, setViewingCfdi] = useState(null); + const [loadingCfdi, setLoadingCfdi] = useState(null); + + const handleViewCfdi = async (id: string) => { + setLoadingCfdi(id); + try { + const cfdi = await getCfdiById(id); + setViewingCfdi(cfdi); + } catch (error) { + console.error('Error loading CFDI:', error); + alert('Error al cargar el CFDI'); + } finally { + setLoadingCfdi(null); + } + }; + const canEdit = user?.role === 'admin' || user?.role === 'contador'; const handleSearch = () => { @@ -1067,6 +1086,7 @@ export default function CfdiPage() { Receptor Total Estado + {canEdit && } @@ -1122,6 +1142,21 @@ export default function CfdiPage() { {cfdi.estado === 'vigente' ? 'Vigente' : 'Cancelado'} + + + {canEdit && (