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'; import Head from 'next/head'; 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 ( <> Hello! | The Biergarten App
{isLoading && } {user && !isLoading && ( <>

Good {isMorning && 'morning'} {isAfternoon && 'afternoon'} {isEvening && 'evening'} {`, ${user?.firstName}!`}

Welcome to the Biergarten App!

)}
); }; export const getServerSideProps: GetServerSideProps = withPageAuthRequired(); export default ProtectedPage;