diff --git a/frontend/src/pages/Communication.jsx b/frontend/src/pages/Communication.jsx index ac75c33..865b7e1 100644 --- a/frontend/src/pages/Communication.jsx +++ b/frontend/src/pages/Communication.jsx @@ -510,6 +510,7 @@ export default function Communication() { const { user, isAdmin } = useAuth(); const [searchParams, setSearchParams] = useSearchParams(); const navigate = useNavigate(); + const [notifMenuPos, setNotifMenuPos] = useState(null); // { x, y } const [tab, setTab] = useState('support'); // 'support' | 'notifications' const [showBroadcastForm, setShowBroadcastForm] = useState(false); @@ -718,6 +719,16 @@ export default function Communication() { setBcSending(false); }; + // ── Supprimer toutes les notifications ──────────────────────────────────── + const deleteAllNotifs = async () => { + try { + await Promise.all(notifs.map(n => api.del(`/notifications/${n.id}`))); + setNotifs([]); + setSelectedNotif(null); + window.dispatchEvent(new CustomEvent('notif:refresh')); + } catch { /* silencieux */ } + }; + // ── Supprimer une notification ──────────────────────────────────────────── const deleteNotif = async (id) => { try { @@ -787,26 +798,26 @@ export default function Communication() { {/* Colonne 2 — Dossier + filtres */}
- {tab === 'support' ? 'Support' : 'Notifications'} -
- {tab === 'support' && ( - <> - {[['all','Tous'],['open','Ouverts'],['resolved','Résolus']].map(([v,l]) => ( - - ))} - - )} - {tab === 'notifications' && ( - <> - {[['all','Tous'],['unread','Non lus']].map(([v,l]) => ( - - ))} - {unreadCount > 0 && ( - - )} - - )} -
+ {tab === 'support' ? 'Support' : 'Notifications'} + {tab === 'support' && ( +
+ {[['all','Tous'],['open','Ouverts'],['resolved','Résolus']].map(([v,l]) => ( + + ))} +
+ )} + {tab === 'notifications' && ( + + )}
{/* Colonne 3 — Toolbar contextuelle */}
@@ -822,20 +833,13 @@ export default function Communication() {
)} - {tab === 'notifications' && selectedNotif && ( + {tab === 'notifications' && selectedNotif && !selectedNotif.read && (
- {!selectedNotif.read && ( - - )} - {selectedNotif.link && ( - - )} +
)} @@ -972,7 +976,14 @@ export default function Communication() { return ( <>
- Notifications +
+ {[['all','Tous'],['unread','Non lus']].map(([v,l]) => ( + + ))} + {unreadCount > 0 && ( + + )} +
{notifs.length === 0 && ( @@ -991,6 +1002,8 @@ export default function Communication() {
{n.title} +
+
{/* end comm-wrap */}
{/* end comm-page */} + {/* ── Menu ⋮ notifications ── */} + {notifMenuPos && ( + <> +
setNotifMenuPos(null)} /> +
+ {unreadCount > 0 && ( + + )} + +
+ + )} + {/* ── Lightbox image ── */} {lightbox && (
setLightbox(null)}>