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) {
const channelName = "users.admin";
echo.private(channelName)
.listen(".users.registration", (event) => {
const handleNotification = (content) => {
const newNotification = {
id: Date.now(),
content: `Nouvelle demande d'inscription : ${event.user.name} ${event.user.lastname}`,
content,
created_at: Date.now(),
pivot: { unread: 1 }
};
setNotifications(prev => [newNotification, ...prev]);
setunreadNotification(true);
setUnreadNotification(true);
};
echo.private(channelName)
.listen(".users.registration", (event) => {
handleNotification(`Nouvelle demande d'inscription : ${event.user.name} ${event.user.lastname}`);
updatePendingMembers();
});
return channelName;