updated changes

This commit is contained in:
Irtiza-h30
2020-07-14 16:43:10 -04:00
parent 12f493cba2
commit 2317b6a4ab
2 changed files with 27 additions and 13 deletions

View File

@@ -1,9 +1,12 @@
import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import { Alert } from 'antd';
import { useLocation } from 'react-router-dom';
import { useApolloClient } from '@apollo/react-hooks';
import { useApolloClient, useQuery } from '@apollo/react-hooks';
import { AppLayout as Layout } from '@tip-wlan/wlan-cloud-ui-library';
import { GET_ALL_STATUS } from 'graphql/queries';
import { AppLayout as Layout, Loading } from '@tip-wlan/wlan-cloud-ui-library';
import { AUTH_TOKEN } from 'constants/index';
@@ -12,7 +15,7 @@ import { removeItem } from 'utils/localStorage';
import UserContext from 'contexts/UserContext';
const MasterLayout = ({ children }) => {
const { role } = useContext(UserContext);
const { role, customerId } = useContext(UserContext);
const client = useApolloClient();
const location = useLocation();
@@ -38,11 +41,6 @@ const MasterLayout = ({ children }) => {
path: '/profiles',
text: 'Profiles',
},
{
key: 'alarms',
path: '/alarms',
text: 'Alarms',
},
];
const mobileMenuItems = [
@@ -61,11 +59,6 @@ const MasterLayout = ({ children }) => {
path: '/profiles',
text: 'Profiles',
},
{
key: 'alarms',
path: '/alarms',
text: 'Alarms',
},
{
key: 'settings',
@@ -98,12 +91,32 @@ const MasterLayout = ({ children }) => {
});
}
const { loading, error, data } = useQuery(GET_ALL_STATUS, {
variables: { customerId, statusDataTypes: ['CUSTOMER_DASHBOARD'] },
});
if (loading) {
return <Loading />;
}
if (error) {
return <Alert message="Error" description="Failed to load Alarms" type="error" showIcon />;
}
const alarms = data.getAllStatus.items[0].alarmsCount.totalCountsPerAlarmCodeMap;
let totalAlarms = 0;
Object.keys(alarms).forEach(i => {
totalAlarms += alarms[i];
});
return (
<Layout
onLogout={handleLogout}
locationState={location}
menuItems={menuItems}
mobileMenuItems={mobileMenuItems}
totalAlarms={totalAlarms}
>
{children}
</Layout>

View File

@@ -215,6 +215,7 @@ export const GET_ALL_STATUS = gql`
equipmentCountPerOui
clientCountPerOui
}
alarmsCount
}
context {
lastPage