feat: add add new config strategy to frontend

This commit is contained in:
Elias Schneider
2022-11-28 17:50:36 +01:00
parent 1b5e53ff7e
commit 493705e4ef
20 changed files with 183 additions and 102 deletions

View File

@@ -8,16 +8,14 @@ import {
ThemeIcon,
Title,
} from "@mantine/core";
import getConfig from "next/config";
import Image from "next/image";
import Link from "next/link";
import { useRouter } from "next/router";
import { TbCheck } from "react-icons/tb";
import Meta from "../components/Meta";
import useConfig from "../hooks/config.hook";
import useUser from "../hooks/user.hook";
const { publicRuntimeConfig } = getConfig();
const useStyles = createStyles((theme) => ({
inner: {
display: "flex",
@@ -71,13 +69,14 @@ const useStyles = createStyles((theme) => ({
}));
export default function Home() {
const config = useConfig();
const user = useUser();
const { classes } = useStyles();
const router = useRouter();
if (user || publicRuntimeConfig.ALLOW_UNAUTHENTICATED_SHARES == "true") {
if (user || config.get("allowUnauthenticatedShares")) {
router.replace("/upload");
} else if (publicRuntimeConfig.SHOW_HOME_PAGE == "false") {
} else if (!config.get("showHomePage")) {
router.replace("/auth/signIn");
} else {
return (