1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

fixed an issue with notification system not being referenced correctly

Signed-off-by: Andrii Podriez <andrey5577990@gmail.com>
This commit is contained in:
Andrii Podriez 2024-09-25 00:35:43 +02:00 committed by Youssef Nakti
parent 68ad597231
commit 54130a56de

View file

@ -16,6 +16,7 @@
******************************************************************************/
import React from 'react';
import { useRef, useEffect } from 'react';
import { DndProvider } from 'react-dnd';
import { HTML5Backend }from 'react-dnd-html5-backend';
import NotificationSystem from 'react-notification-system';
@ -49,19 +50,28 @@ const App = () => {
return decodedToken.exp < timeNow;
}
const notificationSystem = useRef(null);
useEffect(() => {
NotificationsDataManager.setSystem(notificationSystem.current);
return () => {
NotificationsDataManager.setSystem(null);
};
}, []);
const { isAuthenticated, token, user } = useSelector((state) => state.auth);
if (!isAuthenticated || isTokenExpired(token)) {
console.log("APP redirecting to logout/login");
return (<Redirect to="/logout" />);
} else {
console.log("APP rendering app");
const pages = branding.values.pages;
return (<DndProvider backend={HTML5Backend} >
<div className="app">
<NotificationSystem />
<NotificationSystem ref={notificationSystem} />
<Header />
<div className='app-body app-body-spacing'>