mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 18:52:06 +00:00
Update login to redirect to current user page
This commit is contained in:
@@ -7,21 +7,29 @@ import { GetServerSideProps, NextPage } from 'next';
|
||||
import { useContext } from 'react';
|
||||
|
||||
const ProtectedPage: NextPage = () => {
|
||||
const { user, error, isLoading } = useContext(UserContext);
|
||||
const { user, isLoading } = useContext(UserContext);
|
||||
|
||||
const currentTime = new Date().getHours();
|
||||
|
||||
const isMorning = currentTime > 5 && currentTime < 12;
|
||||
const isAfternoon = currentTime > 12 && currentTime < 18;
|
||||
const isEvening = currentTime > 18 && currentTime < 24;
|
||||
|
||||
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 className="flex h-full flex-col items-center justify-center space-y-3">
|
||||
{isLoading && <Spinner size="xl" />}
|
||||
{user && (
|
||||
<>
|
||||
<h1 className="text-7xl font-bold">
|
||||
Good {isMorning && 'morning'}
|
||||
{isAfternoon && 'afternoon'}
|
||||
{isEvening && 'evening'}
|
||||
{`, ${user?.firstName}!`}
|
||||
</h1>
|
||||
<h2 className="text-4xl font-bold">Welcome to the Biergarten App!</h2>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</Layout>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user