remove duplicated notification handling code

This commit is contained in:
2026-03-19 16:42:09 +01:00
parent a0c42b5e81
commit dbed114843
@@ -1,16 +1,21 @@
export const adminNotificationsListener = (echo, userData, setNotifications, setunreadNotification, updatePendingMembers) => { export const adminNotificationsListener = (echo, userData, setNotifications, setUnreadNotification, updatePendingMembers) => {
if (userData.isAdmin) { if (userData.isAdmin) {
const channelName = "users.admin"; const channelName = "users.admin";
const handleNotification = (content) => {
const newNotification = {
id: Date.now(),
content,
created_at: Date.now(),
pivot: { unread: 1 }
};
setNotifications(prev => [newNotification, ...prev]);
setUnreadNotification(true);
};
echo.private(channelName) echo.private(channelName)
.listen(".users.registration", (event) => { .listen(".users.registration", (event) => {
const newNotification = { handleNotification(`Nouvelle demande d'inscription : ${event.user.name} ${event.user.lastname}`);
id: Date.now(),
content: `Nouvelle demande d'inscription : ${event.user.name} ${event.user.lastname}`,
created_at: Date.now(),
pivot: { unread: 1 }
};
setNotifications(prev => [newNotification, ...prev]);
setunreadNotification(true);
updatePendingMembers(); updatePendingMembers();
}); });
return channelName; return channelName;