import {
Button,
Container,
createStyles,
Group,
List,
Text,
ThemeIcon,
Title,
} from "@mantine/core";
import Link from "next/link";
import { useRouter } from "next/router";
import { useEffect, useState } from "react";
import { TbCheck } from "react-icons/tb";
import { FormattedMessage } from "react-intl";
import Logo from "../components/Logo";
import Meta from "../components/Meta";
import useUser from "../hooks/user.hook";
import useConfig from "../hooks/config.hook";
const useStyles = createStyles((theme) => ({
inner: {
display: "flex",
justifyContent: "space-between",
paddingTop: `calc(${theme.spacing.md} * 4)`,
paddingBottom: `calc(${theme.spacing.md} * 4)`,
},
content: {
maxWidth: 480,
marginRight: `calc(${theme.spacing.md} * 3)`,
[theme.fn.smallerThan("md")]: {
maxWidth: "100%",
marginRight: 0,
},
},
title: {
color: theme.colorScheme === "dark" ? theme.white : theme.black,
fontSize: 44,
lineHeight: 1.2,
fontWeight: 900,
[theme.fn.smallerThan("xs")]: {
fontSize: 28,
},
},
control: {
[theme.fn.smallerThan("xs")]: {
flex: 1,
},
},
image: {
[theme.fn.smallerThan("md")]: {
display: "none",
},
},
highlight: {
position: "relative",
backgroundColor:
theme.colorScheme === "dark"
? theme.fn.rgba(theme.colors[theme.primaryColor][6], 0.55)
: theme.colors[theme.primaryColor][0],
borderRadius: theme.radius.sm,
padding: "4px 12px",
},
}));
export default function Home() {
const { classes } = useStyles();
const { refreshUser } = useUser();
const router = useRouter();
const config = useConfig();
const [signupEnabled, setSignupEnabled] = useState(true);
// If user is already authenticated, redirect to the upload page
useEffect(() => {
refreshUser().then((user) => {
if (user) {
router.replace("/upload");
}
});
// If registration is disabled, get started button should redirect to the sign in page
try {
const allowRegistration = config.get("share.allowRegistration");
setSignupEnabled(allowRegistration !== false);
} catch (error) {
setSignupEnabled(true);
}
}, [config]);
const getButtonHref = () => {
return signupEnabled ? "/auth/signUp" : "/auth/signIn";
};
return (
<>
(
{chunks}
),
}}
/>
}
>
{" "}
-
{" "}
-
{" "}
-
>
);
}