mirror of
https://github.com/Myzel394/kleckrelay-website.git
synced 2025-06-19 07:55:25 +02:00
current stand
This commit is contained in:
parent
6a9aa24e2d
commit
517b49a5c4
@ -99,6 +99,10 @@ const router = createBrowserRouter([
|
|||||||
loader: getServerSettings,
|
loader: getServerSettings,
|
||||||
element: <EnterDecryptionPassword />,
|
element: <EnterDecryptionPassword />,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/admin",
|
||||||
|
element: <EnterDecryptionPassword />,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {ReactElement, useContext} from "react"
|
import {ReactElement, useContext} from "react"
|
||||||
import {BiStats} from "react-icons/bi"
|
import {BiStats} from "react-icons/bi"
|
||||||
import {MdSettings} from "react-icons/md"
|
import {MdSettings} from "react-icons/md"
|
||||||
import {FaMask} from "react-icons/fa"
|
import {FaMask, FaServer} from "react-icons/fa"
|
||||||
import {Link as RouterLink, useLocation} from "react-router-dom"
|
import {Link as RouterLink, useLocation} from "react-router-dom"
|
||||||
import {useTranslation} from "react-i18next"
|
import {useTranslation} from "react-i18next"
|
||||||
|
|
||||||
@ -16,6 +16,7 @@ export enum NavigationSection {
|
|||||||
Aliases,
|
Aliases,
|
||||||
Reports,
|
Reports,
|
||||||
Settings,
|
Settings,
|
||||||
|
Admin,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface NavigationButtonProps {
|
export interface NavigationButtonProps {
|
||||||
@ -27,6 +28,7 @@ const SECTION_ICON_MAP: Record<NavigationSection, ReactElement> = {
|
|||||||
[NavigationSection.Aliases]: <FaMask />,
|
[NavigationSection.Aliases]: <FaMask />,
|
||||||
[NavigationSection.Reports]: <Icon path={mdiTextBoxMultiple} size={0.8} />,
|
[NavigationSection.Reports]: <Icon path={mdiTextBoxMultiple} size={0.8} />,
|
||||||
[NavigationSection.Settings]: <MdSettings />,
|
[NavigationSection.Settings]: <MdSettings />,
|
||||||
|
[NavigationSection.Admin]: <FaServer />,
|
||||||
}
|
}
|
||||||
|
|
||||||
const SECTION_TEXT_MAP: Record<NavigationSection, string> = {
|
const SECTION_TEXT_MAP: Record<NavigationSection, string> = {
|
||||||
@ -34,6 +36,7 @@ const SECTION_TEXT_MAP: Record<NavigationSection, string> = {
|
|||||||
[NavigationSection.Aliases]: "components.NavigationButton.aliases",
|
[NavigationSection.Aliases]: "components.NavigationButton.aliases",
|
||||||
[NavigationSection.Reports]: "components.NavigationButton.reports",
|
[NavigationSection.Reports]: "components.NavigationButton.reports",
|
||||||
[NavigationSection.Settings]: "components.NavigationButton.settings",
|
[NavigationSection.Settings]: "components.NavigationButton.settings",
|
||||||
|
[NavigationSection.Admin]: "components.NavigationButton.admin",
|
||||||
}
|
}
|
||||||
|
|
||||||
const PATH_SECTION_MAP: Record<string, NavigationSection> = {
|
const PATH_SECTION_MAP: Record<string, NavigationSection> = {
|
||||||
@ -41,6 +44,7 @@ const PATH_SECTION_MAP: Record<string, NavigationSection> = {
|
|||||||
aliases: NavigationSection.Aliases,
|
aliases: NavigationSection.Aliases,
|
||||||
reports: NavigationSection.Reports,
|
reports: NavigationSection.Reports,
|
||||||
settings: NavigationSection.Settings,
|
settings: NavigationSection.Settings,
|
||||||
|
admin: NavigationSection.Admin,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function NavigationButton({section}: NavigationButtonProps): ReactElement {
|
export default function NavigationButton({section}: NavigationButtonProps): ReactElement {
|
||||||
|
15
src/routes/AdminRoute.tsx
Normal file
15
src/routes/AdminRoute.tsx
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import {ReactElement, useLayoutEffect} from "react";
|
||||||
|
import {useNavigateToNext, useUser} from "~/hooks";
|
||||||
|
|
||||||
|
export default function AdminRoute(): ReactElement {
|
||||||
|
const navigateToNext = useNavigateToNext();
|
||||||
|
const user = useUser();
|
||||||
|
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
if (!user.isAdmin) {
|
||||||
|
navigateToNext();
|
||||||
|
}
|
||||||
|
}, [user.isAdmin, navigateToNext])
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -41,6 +41,7 @@ export interface ServerUser {
|
|||||||
isDecrypted: false
|
isDecrypted: false
|
||||||
encryptedPassword: string
|
encryptedPassword: string
|
||||||
salt: string
|
salt: string
|
||||||
|
isAdmin: boolean
|
||||||
email: {
|
email: {
|
||||||
address: string
|
address: string
|
||||||
isVerified: boolean
|
isVerified: boolean
|
||||||
|
Loading…
x
Reference in New Issue
Block a user