diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 0a3b9ef..bd4c6e4 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -22,6 +22,7 @@ import Cumpleanos from './pages/Cumpleanos'; import Inventario from './pages/Inventario'; import WacrmMessages from './pages/WacrmMessages'; import WacrmLeads from './pages/WacrmLeads'; +import Chat from './pages/Chat'; import Login from './pages/Login'; import './App.css'; @@ -81,6 +82,7 @@ const App: FC = () => { } /> } /> } /> + } /> } /> } /> } /> diff --git a/frontend/src/components/ClasicoLayout.tsx b/frontend/src/components/ClasicoLayout.tsx index 9ed9668..503bc2f 100644 --- a/frontend/src/components/ClasicoLayout.tsx +++ b/frontend/src/components/ClasicoLayout.tsx @@ -35,6 +35,7 @@ import GlobalSearch from './GlobalSearch'; import ThemePicker from './ThemePicker'; import NotificationBell from './NotificationBell'; import { useAuth, ROLE_LABELS } from '../lib/auth'; +import { useChatUnread } from '../lib/chat'; import { useQuickLinks } from '../lib/quicklinks'; import { odooApi } from '../services/odoo'; @@ -114,6 +115,7 @@ const menuTree: MenuEntry[] = [ { label: 'Comunicación', icon: MessageSquare, children: [ + { label: 'Chat', href: '/chat' }, { label: 'Cumpleañeros', href: '/cumpleanos' }, { label: 'Mensajes', href: '/wacrm/messages' }, ], @@ -143,6 +145,7 @@ export const ClasicoLayout: FC = ({ children, title: _title, subtit const navigate = useNavigate(); const { user, canSee, hasRole, logout } = useAuth(); const [sidebarOpen, setSidebarOpen] = useState(false); + const chatUnread = useChatUnread(); const visibleLeaves = useMemo( () => menuLeaves.filter((it) => canSee(it.href)), @@ -383,7 +386,12 @@ export const ClasicoLayout: FC = ({ children, title: _title, subtit > {entry.label} - + {entry.children?.some((c) => c.href === '/chat') && chatUnread > 0 && ( + + {chatUnread} + + )} + c.href === '/chat') && chatUnread > 0 ? '' : 'ml-auto'} transition-transform ${open ? '' : '-rotate-90'}`} /> {open && (
    @@ -405,6 +413,11 @@ export const ClasicoLayout: FC = ({ children, title: _title, subtit > {child.label} + {child.href === '/chat' && chatUnread > 0 && ( + + {chatUnread} + + )} + + ))} +
+ )} + + + + {/* Columna derecha: hilo */} +
+ {!activeUser ? ( +
+ +
+ ) : ( + <> +
+ + + {initials(activeUser.name)} + +
+

{activeUser.name}

+

{ROLE_LABELS[activeUser.role] || activeUser.role}

+
+
+ +
+ {loadingThread ? ( +

Cargando mensajes...

+ ) : messages.length === 0 ? ( +

+ Aún no hay mensajes. Escribe el primero. +

+ ) : ( + messages.map((m) => ( +
+
+

{m.body}

+

+ {fmtTime(m.date)} +

+
+
+ )) + )} +
+
+ +
+