Merge pull request #92 from Telecominfraproject/bugfix/WIFI-1452

bugfix/WIFI-1452: Fixed bug on Edit User page
This commit is contained in:
Sean Macfarlane
2021-03-09 12:04:06 -05:00
committed by GitHub
2 changed files with 14 additions and 7 deletions

View File

@@ -92,7 +92,9 @@ const App = () => {
<ProtectedRouteWithLayout exact path={ROUTES.addprofile} component={AddProfile} /> <ProtectedRouteWithLayout exact path={ROUTES.addprofile} component={AddProfile} />
<ProtectedRouteWithLayout exact path={ROUTES.alarms} component={Alarms} /> <ProtectedRouteWithLayout exact path={ROUTES.alarms} component={Alarms} />
{user?.id !== 0 && (
<ProtectedRouteWithLayout exact path={ROUTES.account} component={EditAccount} /> <ProtectedRouteWithLayout exact path={ROUTES.account} component={EditAccount} />
)}
{user?.roles?.[0] === 'SuperUser' && ( {user?.roles?.[0] === 'SuperUser' && (
<ProtectedRouteWithLayout exact path={ROUTES.users} component={Accounts} /> <ProtectedRouteWithLayout exact path={ROUTES.users} component={Accounts} />
)} )}

View File

@@ -13,7 +13,7 @@ import { removeItem } from 'utils/localStorage';
import UserContext from 'contexts/UserContext'; import UserContext from 'contexts/UserContext';
const MasterLayout = ({ children }) => { const MasterLayout = ({ children }) => {
const { roles, customerId } = useContext(UserContext); const { roles, customerId, id: currentUserId } = useContext(UserContext);
const client = useApolloClient(); const client = useApolloClient();
const location = useLocation(); const location = useLocation();
@@ -56,11 +56,15 @@ const MasterLayout = ({ children }) => {
key: 'settings', key: 'settings',
text: 'Settings', text: 'Settings',
children: [ children: [
...(currentUserId !== 0
? [
{ {
key: 'editAccount', key: 'editAccount',
path: ROUTES.account, path: ROUTES.account,
text: 'Edit Account', text: 'Edit Account',
}, },
]
: []),
{ {
key: 'logout', key: 'logout',
path: ROUTES.root, path: ROUTES.root,
@@ -90,6 +94,7 @@ const MasterLayout = ({ children }) => {
menuItems={menuItems} menuItems={menuItems}
mobileMenuItems={mobileMenuItems} mobileMenuItems={mobileMenuItems}
totalAlarms={data && data.getAlarmCount} totalAlarms={data && data.getAlarmCount}
currentUserId={currentUserId}
> >
{children} {children}
</Layout> </Layout>