Implement login, add useUser hook

This commit is contained in:
Aaron William Po
2023-02-06 17:17:11 -05:00
parent 087a1a4513
commit 9a9d8bcb94
18 changed files with 336 additions and 43 deletions

30
pages/user/current.tsx Normal file
View File

@@ -0,0 +1,30 @@
import Layout from '@/components/ui/Layout';
import Spinner from '@/components/ui/Spinner';
import withPageAuthRequired from '@/config/auth/withPageAuthRequired';
import useUser from '@/hooks/useUser';
import { GetServerSideProps, NextPage } from 'next';
const ProtectedPage: NextPage = () => {
const { user, isLoading, error } = useUser();
return (
<Layout>
<div className="flex h-full flex-col items-center justify-center">
<h1 className="text-7xl font-bold text-white">Hello!</h1>
<>
{isLoading && <Spinner />}
{error && <p>Something went wrong.</p>}
{user && (
<div>
<p>{user.username}</p>
</div>
)}
</>
</div>
</Layout>
);
};
export const getServerSideProps: GetServerSideProps = withPageAuthRequired();
export default ProtectedPage;