Skip to content

Commit 75d1934

Browse files
committed
display notification
1 parent e0870e6 commit 75d1934

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

app/components/Occupied.tsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import ListIcon from '@material-ui/icons/List';
2222
import SearchIcon from '@material-ui/icons/Search';
2323
import DashboardIcon from '@material-ui/icons/Dashboard';
2424
import NotificationsIcon from '@material-ui/icons/Notifications';
25+
import Badge from '@material-ui/core/Badge';
2526
import PersonIcon from '@material-ui/icons/Person';
2627
import UpdateIcon from '@material-ui/icons/Update';
2728
// MODALS
@@ -38,6 +39,8 @@ import { DashboardContext } from '../context/DashboardContext';
3839

3940
import { ApplicationContext } from '../context/ApplicationContext';
4041

42+
import { CommsContext } from '../context/CommsContext';
43+
4144
// TYPESCRIPT
4245
interface StyleProps {
4346
root: BaseCSSProperties;
@@ -47,6 +50,7 @@ type ClickEvent = React.MouseEvent<HTMLElement>;
4750
const Occupied = React.memo(() => {
4851
const { setServicesData } = useContext(ApplicationContext);
4952
const { applications, getApplications, deleteApp, mode, getMode } = useContext(DashboardContext);
53+
const { commsData, setCommsData, fetchCommsData } = useContext(CommsContext);
5054
const [open, setOpen] = useState<boolean>(false);
5155
const [addOpen, setAddOpen] = useState<boolean>(false);
5256
const [index, setIndex] = useState<number>(0);
@@ -56,9 +60,14 @@ const Occupied = React.memo(() => {
5660
const delRef = useRef<any>([]);
5761
useEffect(() => {
5862
setServicesData([]);
59-
getApplications();
63+
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+
}
6070
}, []);
61-
6271

6372
// Ask user for deletetion confirmation
6473
const confirmDelete = (event: ClickEvent, app: string, i: number) => {
@@ -185,7 +194,6 @@ const Occupied = React.memo(() => {
185194
}));
186195

187196
let classes = (mode === 'light mode')? useStylesLight({} as StyleProps) : useStylesDark({} as StyleProps) ;
188-
console.log(applications)
189197
return (
190198
<div className="entireArea">
191199
<div className="dashboardArea">
@@ -212,11 +220,14 @@ const Occupied = React.memo(() => {
212220
<span className="dashboardTooltip">You have {applications.length} active databases</span>
213221
<DashboardIcon className="navIcon" id="dashboardIcon" />
214222
</div>
223+
224+
225+
<div className="notificationsIconArea">
226+
<span className="notificationsTooltip">You have {commsData.length} new alerts</span>
227+
< NotificationsIcon className="navIcon" id="notificationsIcon" />
228+
<Badge badgeContent={commsData.length} color="secondary"/>
229+
</div>
215230

216-
<div className="notificationsIconArea">
217-
<span className="notificationsTooltip">You have no new alerts</span>
218-
< NotificationsIcon className="navIcon" id="notificationsIcon" />
219-
</div>
220231

221232
<div className="personIconArea">
222233
<span className="personTooltip">You are not logged in</span>

0 commit comments

Comments
 (0)