fix: Only show admin Page when user is admin; Remove Overview section

This commit is contained in:
Myzel394 2023-02-12 16:21:34 +01:00
parent f0ecace475
commit b405a0817f
2 changed files with 8 additions and 7 deletions

View File

@ -11,15 +11,17 @@ import NavigationButton, {
NavigationSection, NavigationSection,
} from "~/route-widgets/AuthenticateRoute/NavigationButton" } from "~/route-widgets/AuthenticateRoute/NavigationButton"
const sections = (Object.keys(NavigationSection) as Array<keyof typeof NavigationSection>).filter(
value => isNaN(Number(value)),
)
export default function AuthenticatedRoute(): ReactElement { export default function AuthenticatedRoute(): ReactElement {
const {t} = useTranslation() const {t} = useTranslation()
const theme = useTheme() const theme = useTheme()
const user = useUser()
useUser() const sections = [
NavigationSection.Aliases,
NavigationSection.Reports,
NavigationSection.Settings,
user.isAdmin && NavigationSection.Admin,
].filter(value => value !== false) as NavigationSection[]
return ( return (
<LockNavigationContextProvider> <LockNavigationContextProvider>
@ -50,7 +52,7 @@ export default function AuthenticatedRoute(): ReactElement {
<List component="nav"> <List component="nav">
{sections.map(key => ( {sections.map(key => (
<ListItem key={key}> <ListItem key={key}>
<NavigationButton section={NavigationSection[key]} /> <NavigationButton section={key} />
</ListItem> </ListItem>
))} ))}
</List> </List>

View File

@ -45,7 +45,6 @@ export default function VerifyEmailRoute(): ReactElement {
verifyEmail, verifyEmail,
{ {
onSuccess: ({user}) => { onSuccess: ({user}) => {
setEmail("")
login(user) login(user)
navigate("/auth/complete-account") navigate("/auth/complete-account")
}, },