53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
|
import Head from "next/head";
|
||
|
import { GetStaticProps } from "next";
|
||
|
import React from "react";
|
||
|
import { AuthProvider, useAuth } from "components/Login/authcontext";
|
||
|
import LoginHead from "components/Login/loginhead";
|
||
|
import LoginBox from "components/Login/loginbox";
|
||
|
import Editor from "components/editor";
|
||
|
|
||
|
export const getStaticProps: GetStaticProps = async () => {
|
||
|
// TODO: Fetch links here
|
||
|
|
||
|
return {
|
||
|
props: { data: null }, // will be passed to the page component as props
|
||
|
// Next.js will attempt to re-generate the page:
|
||
|
// - When a request comes in
|
||
|
// - At most once every second
|
||
|
revalidate: 1,
|
||
|
};
|
||
|
};
|
||
|
|
||
|
const LoginScreen: React.FC = () => {
|
||
|
return (
|
||
|
<div className="fixed h-screen w-full overflow-auto bg-gray-100">
|
||
|
<div className="m-auto h-full flex justify-center items-center">
|
||
|
<div className="container m-auto h-auto flex flex-col justify-center items-center p-10 space-y-20">
|
||
|
<Head>
|
||
|
<title>Login</title>
|
||
|
</Head>
|
||
|
<LoginHead />
|
||
|
<div className="flex justify-center items-center px-10 py-8 bg-gray-50 border-2 border-gray-300 rounded-lg">
|
||
|
<LoginBox />
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
);
|
||
|
};
|
||
|
|
||
|
const LoginChecker: React.FC = () => {
|
||
|
const { loggedIn } = useAuth();
|
||
|
return loggedIn ? <Editor /> : <LoginScreen />;
|
||
|
};
|
||
|
|
||
|
const Login: React.FC = () => {
|
||
|
return (
|
||
|
<AuthProvider>
|
||
|
<LoginChecker />
|
||
|
</AuthProvider>
|
||
|
);
|
||
|
};
|
||
|
|
||
|
export default Login;
|