refactor: add gssp hoc func for auth

gssp -> getServerSideProps
hoc -> Higher-Order Components
This commit is contained in:
Sonny
2023-06-10 18:57:07 +02:00
parent f562b7c433
commit 1c9c65e074
10 changed files with 161 additions and 234 deletions

View File

@@ -5,7 +5,6 @@ import nProgress from "nprogress";
import { useEffect } from "react";
import { useHotkeys } from "react-hotkeys-hook";
import AuthRequired from "components/AuthRequired";
import * as Keys from "constants/keys";
import PATHS from "constants/paths";
@@ -36,13 +35,7 @@ function MyApp({ Component, pageProps: { session, ...pageProps } }) {
return (
<SessionProvider session={session}>
<DefaultSeo titleTemplate="MyLinks — %s" defaultTitle="MyLinks" />
{Component.authRequired ? (
<AuthRequired>
<Component {...pageProps} />
</AuthRequired>
) : (
<Component {...pageProps} />
)}
<Component {...pageProps} />
</SessionProvider>
);
}