diff --git a/src/components/Dashboard/context/NotificationContext.jsx b/src/components/Dashboard/context/NotificationContext.jsx index 516d8b4..f983027 100644 --- a/src/components/Dashboard/context/NotificationContext.jsx +++ b/src/components/Dashboard/context/NotificationContext.jsx @@ -19,7 +19,7 @@ const NotificationContext = createContext() const NotificationProvider = ({ children }) => { const [api, contextHolder] = notification.useNotification() const location = useLocation() - const { authenticated } = useContext(AuthContext) + const { authenticated, token } = useContext(AuthContext) const { showError, fetchNotificationsApi, @@ -118,6 +118,12 @@ const NotificationProvider = ({ children }) => { } }, [authenticated, notificationCenterVisible, fetchNotifications]) + useEffect(() => { + if (authenticated && token) { + fetchNotifications() + } + }, [authenticated, token, fetchNotifications]) + useEffect(() => { setNotificationCenterVisible(false) }, [location.pathname])