mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
Restructure codebase to use src directory
This commit is contained in:
40
src/pages/user/current.tsx
Normal file
40
src/pages/user/current.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
import Layout from '@/components/ui/Layout';
|
||||
import Spinner from '@/components/ui/Spinner';
|
||||
import withPageAuthRequired from '@/getServerSideProps/withPageAuthRequired';
|
||||
import UserContext from '@/contexts/userContext';
|
||||
|
||||
import { GetServerSideProps, NextPage } from 'next';
|
||||
import { useContext } from 'react';
|
||||
|
||||
const ProtectedPage: NextPage = () => {
|
||||
const { user, isLoading } = useContext(UserContext);
|
||||
|
||||
const currentTime = new Date().getHours();
|
||||
|
||||
const isMorning = currentTime > 4 && currentTime < 12;
|
||||
const isAfternoon = currentTime > 12 && currentTime < 18;
|
||||
const isEvening = (currentTime > 18 && currentTime < 24) || currentTime < 4;
|
||||
|
||||
return (
|
||||
<Layout>
|
||||
<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>
|
||||
);
|
||||
};
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = withPageAuthRequired();
|
||||
|
||||
export default ProtectedPage;
|
||||
Reference in New Issue
Block a user