import { useState, useEffect } from 'react'; import api from '../services/api'; import { ShieldCheck, AlertCircle, CheckCircle2, User as UserIcon, Clock } from 'lucide-react'; import { motion, AnimatePresence } from 'framer-motion'; import { useToast } from '../context/use-toast'; import clsx from 'clsx'; export default function TreasuryPage() { const { showToast } = useToast(); const [pending, setPending] = useState([]); const [loading, setLoading] = useState(true); const [selectedSession, setSelectedSession] = useState(null); const [notes, setNotes] = useState(''); const loadPending = async () => { setLoading(true); try { const res = await api.get('/cashsessions/pending'); setPending(res.data); } catch (e) { showToast("Error al cargar sesiones pendientes", "error"); } finally { setLoading(false); } }; useEffect(() => { loadPending(); }, []); const handleValidate = async () => { if (!selectedSession) return; try { await api.post(`/cashsessions/${selectedSession.id}/validate`, JSON.stringify(notes), { headers: { 'Content-Type': 'application/json' } }); showToast("Caja liquidada y archivada", "success"); setSelectedSession(null); setNotes(''); loadPending(); } catch (e) { showToast("Error al validar", "error"); } }; if (loading) return
Cargando Tesorería...
; return (
Administración Central

Validación de Cajas

{/* LISTADO DE CAJAS PENDIENTES */}

Sesiones esperando cierre definitivo

{pending.length === 0 ? (

No hay cajas pendientes de validación

) : ( pending.map(s => ( setSelectedSession(s)} className={clsx( "p-6 bg-white rounded-[2rem] border-2 transition-all cursor-pointer flex justify-between items-center group", selectedSession?.id === s.id ? "border-blue-600 shadow-xl shadow-blue-100" : "border-slate-100 hover:border-blue-200 shadow-sm" )} >

{s.username}

Cerrada: {new Date(s.closingDate).toLocaleTimeString()}

$ {(s.declaredCash + s.declaredCards + s.declaredTransfers).toLocaleString()}

PENDIENTE LIQUIDAR
)) )}
{/* PANEL DE ACCIÓN (DERECHA) */}
{selectedSession ? (

Detalle de Liquidación

= 0 ? "text-emerald-400" : "text-rose-400"} />