mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
Update: change identifiers to cuid
This commit is contained in:
41
src/pages/users/current.tsx
Normal file
41
src/pages/users/current.tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
import Spinner from '@/components/ui/Spinner';
|
||||
import withPageAuthRequired from '@/util/withPageAuthRequired';
|
||||
import UserContext from '@/contexts/UserContext';
|
||||
|
||||
import { GetServerSideProps, NextPage } from 'next';
|
||||
import { useContext } from 'react';
|
||||
import useMediaQuery from '@/hooks/utilities/useMediaQuery';
|
||||
|
||||
const ProtectedPage: NextPage = () => {
|
||||
const { user, isLoading } = useContext(UserContext);
|
||||
|
||||
const currentTime = new Date().getHours();
|
||||
|
||||
const isMorning = currentTime >= 3 && currentTime < 12;
|
||||
const isAfternoon = currentTime >= 12 && currentTime < 18;
|
||||
const isEvening = currentTime >= 18 || currentTime < 3;
|
||||
|
||||
const isDesktop = useMediaQuery('(min-width: 768px)');
|
||||
return (
|
||||
<div className="flex h-full flex-col items-center justify-center space-y-3 bg-primary text-center">
|
||||
{isLoading && <Spinner size={isDesktop ? 'xl' : 'md'} />}
|
||||
{user && !isLoading && (
|
||||
<>
|
||||
<h1 className="text-2xl font-bold lg:text-7xl">
|
||||
Good {isMorning && 'morning'}
|
||||
{isAfternoon && 'afternoon'}
|
||||
{isEvening && 'evening'}
|
||||
{`, ${user?.firstName}!`}
|
||||
</h1>
|
||||
<h2 className="text-xl font-bold lg:text-4xl">
|
||||
Welcome to the Biergarten App!
|
||||
</h2>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = withPageAuthRequired();
|
||||
|
||||
export default ProtectedPage;
|
||||
Reference in New Issue
Block a user