From 0d4e341e0dd82aa7ddb6baf779566895afc7b5aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20B=C3=A4ck?= Date: Mon, 4 Sep 2023 14:03:23 +0300 Subject: [PATCH] Show page instead of redirecting unauthorized users --- components/Page.tsx | 54 +++++++++++++++++++++------------- components/Unauthorized.tsx | 18 ++++++++++++ pages/medlem/[privatePage].tsx | 14 ++------- 3 files changed, 55 insertions(+), 31 deletions(-) create mode 100644 components/Unauthorized.tsx diff --git a/components/Page.tsx b/components/Page.tsx index 91602fc..de548a5 100644 --- a/components/Page.tsx +++ b/components/Page.tsx @@ -7,6 +7,7 @@ import { NationLogo } from '@components/footer/Logos' import Footer from '@components/footer' import TableOfContents from '@components/TableOfContents' import PageSection from '@components/PageSection' +import Unauthorized from '@components/Unauthorized' const renderer: marked.RendererObject = { image(href: string | null): string { @@ -24,34 +25,47 @@ type PageProps = { logos: NationLogo[] navbarLinks: NavbarLink[] isPrivate: boolean + unauthorized?: boolean } -const Page: NextPage = ({ page, navbarLinks, logos, isPrivate }) => { +const Page: NextPage = ({ + page, + navbarLinks, + logos, + isPrivate, + unauthorized = false, +}) => { return (
-

{page?.title}

- {page?.content && ( -
+ {unauthorized ? ( + + ) : ( + <> +

{page?.title}

+ {page?.content && ( +
+ )} + {page?.showTableOfContents && ( + + )} + {page?.sections?.data.map((section, i) => ( + + ))} + )} - {page?.showTableOfContents && ( - - )} - {page?.sections?.data.map((section, i) => ( - - ))}