Skip to content

Commit bb38c1d

Browse files
committed
live update and display notifications based on last viewed database
1 parent bee62ea commit bb38c1d

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

app/components/Occupied.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,8 @@ const Occupied = React.memo(() => {
6161
useEffect(() => {
6262
setServicesData([]);
6363
getApplications();
64-
// update communication data from last visited database
65-
for (const app of applications) {
66-
const temp = commsData;
67-
const newComm = fetchCommsData('', true);
68-
setCommsData([...temp, newComm])
69-
}
7064
}, []);
71-
65+
7266
// Ask user for deletetion confirmation
7367
const confirmDelete = (event: ClickEvent, app: string, i: number) => {
7468
const message = `The application '${app}' will be permanently deleted. Continue?`;
@@ -194,6 +188,10 @@ const Occupied = React.memo(() => {
194188
}));
195189

196190
let classes = (mode === 'light mode')? useStylesLight({} as StyleProps) : useStylesDark({} as StyleProps) ;
191+
192+
// update notification count based on statuscode >= 400
193+
const notification = commsData.filter((item: { responsestatus: number; }) => item.responsestatus >= 400)
194+
197195
return (
198196
<div className="entireArea">
199197
<div className="dashboardArea">
@@ -223,9 +221,9 @@ const Occupied = React.memo(() => {
223221

224222

225223
<div className="notificationsIconArea">
226-
<span className="notificationsTooltip">You have {commsData.length} new alerts</span>
224+
<span className="notificationsTooltip">You have {notification ? notification.length : 0} new alerts</span>
227225
< NotificationsIcon className="navIcon" id="notificationsIcon" />
228-
<Badge badgeContent={commsData.length} color="secondary"/>
226+
<Badge badgeContent={notification ? notification.length : 0} color="secondary"/>
229227
</div>
230228

231229

0 commit comments

Comments
 (0)