feat: block no admin users to access some routes

This commit is contained in:
canove
2020-09-07 09:38:52 -03:00
parent 8e8658425f
commit 10bc003d02
5 changed files with 48 additions and 20 deletions

View File

@@ -38,6 +38,7 @@ function ListItemLink(props) {
}
const MainListItems = () => {
const userProfile = localStorage.getItem("profile");
return (
<div>
<ListItemLink to="/" primary="Dashboard" icon={<DashboardIcon />} />
@@ -57,18 +58,22 @@ const MainListItems = () => {
primary={i18n.t("mainDrawer.listItems.contacts")}
icon={<ContactPhoneIcon />}
/>
<Divider />
<ListSubheader inset>Administration</ListSubheader>
<ListItemLink
to="/users"
primary={i18n.t("mainDrawer.listItems.users")}
icon={<GroupIcon />}
/>
<ListItemLink
to="/settings"
primary={i18n.t("mainDrawer.listItems.settings")}
icon={<SettingsIcon />}
/>
{userProfile === "admin" && (
<>
<Divider />
<ListSubheader inset>Administration</ListSubheader>
<ListItemLink
to="/users"
primary={i18n.t("mainDrawer.listItems.users")}
icon={<GroupIcon />}
/>
<ListItemLink
to="/settings"
primary={i18n.t("mainDrawer.listItems.settings")}
icon={<SettingsIcon />}
/>
</>
)}
</div>
);
};