/* global React */ // Mensajería interna — versión ligera (HU.3.3) // Canal simple de comunicación CGR ↔ Institución, sin adjuntos. const { useState: useStateMs, useMemo: useMemoMs } = React; function MensajeriaScreen({ roleId, user, onOpenDetalle }) { const I = window.Icons; const conversaciones = window.getConversaciones(roleId); const [tab, setTab] = useStateMs('inbox'); const [q, setQ] = useStateMs(''); const [activeId, setActiveId] = useStateMs(conversaciones[0]?.id || null); const [composing, setComposing] = useStateMs(false); const filtered = useMemoMs(() => { let list = conversaciones; if (tab === 'inbox') list = list.filter(c => c.folder === 'inbox'); if (tab === 'unread') list = list.filter(c => c.unread > 0); if (tab === 'sent') list = list.filter(c => c.folder === 'sent'); if (q) { list = list.filter(c => `${c.with.name} ${c.subject} ${c.preview} ${c.compromisoText || ''}` .toLowerCase().includes(q.toLowerCase()) ); } return list; }, [conversaciones, tab, q]); const active = conversaciones.find(c => c.id === activeId) || filtered[0]; const counts = useMemoMs(() => { const c = { inbox: 0, sent: 0, unread: 0 }; conversaciones.forEach(x => { c[x.folder] = (c[x.folder] || 0) + 1; c.unread += x.unread; }); return c; }, [conversaciones]); return (
{user.org}

Mensajería

Canal de comunicación interno con {roleId === 'institucion' ? ' la CGR' : ' las instituciones reportantes'}. Cada conversación queda registrada para trazabilidad.

{/* Tabs simples */}
setQ(e.target.value)} />
{/* 2-pane mailbox */}
{/* List */}
    {filtered.map(c => (
  • 0 ? ' is-unread' : ''}`} onClick={() => { setActiveId(c.id); setComposing(false); }} >
    {c.with.initials}
    {c.with.name} {c.lastDate}
    {c.subject}
    {c.compromisoId && (
    {c.compromisoId}
    )}
    {c.preview}
    {c.unread > 0 &&
    {c.unread}
    }
  • ))} {filtered.length === 0 && (
  • Sin conversaciones

    No hay mensajes con esos criterios.

  • )}
{/* Thread */}
{composing ? ( setComposing(false)} roleId={roleId} /> ) : active ? ( ) : (

Selecciona una conversación

El hilo aparecerá aquí.

)}
); } // ---------------- Thread simple ---------------- function SimpleThread({ c, onOpenDetalle }) { const I = window.Icons; return ( <>
{c.with.initials}

{c.with.name}

{c.with.sub}

{c.subject}

{c.compromisoId && ( )}
{c.mensajes.map((m, i) => (
{m.from === 'in' &&
{c.with.initials}
}
{m.author} {m.date}

{m.text}

{m.from === 'out' &&
CB
}
))}
); } // ---------------- Composer simple ---------------- function SimpleComposer({ onCancel, roleId }) { const I = window.Icons; return ( <>

Nuevo mensaje

Quedará registrado en la bandeja del destinatario
Quedará registro permanente del envío.
); } Object.assign(window, { MensajeriaScreen });