Skip to content

Commit

Permalink
setup app close pages
Browse files Browse the repository at this point in the history
  • Loading branch information
juancwu committed May 3, 2024
1 parent 39e1440 commit 3db6292
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@headlessui/react": "^1.7.18",
"@heroicons/react": "^2.1.1",
"class-variance-authority": "^0.7.0",
"date-fns": "^3.6.0",
"firebase": "^10.5.2",
"hamburger-react": "^2.5.0",
"react": "^18.2.0",
Expand Down
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import { FiLogOut } from "react-icons/fi";
import { useState, useEffect } from "react";
import { useAuth } from "@/providers/hooks";
import Hamburger from "hamburger-react";
import { isAfter } from "date-fns";
import { Link } from "react-router-dom";
import { Logo } from "@/assets";
import { appCloseDate } from "@/data/appCloseDate";

const navItems = [
{ path: "/profile", label: "Home", Icon: GoHome },
Expand Down Expand Up @@ -43,6 +45,26 @@ export const Navbar = () => {
}, [userApp]);

const renderNavItems = (isMobile: boolean) => {
const today = new Date();

if (isAfter(today, new Date(appCloseDate))) {
const { path, label, Icon } = navItems[0];
return (
<Link to={path} className="w-full">
<li className="p-4 hover:bg-slate-100 duration-300 transition-colors rounded-md w-full hover:text-black cursor-pointer flex items-center justify-start gap-2">
{isMobile ? (
label
) : (
<>
<Icon size={32} />
<span className="hidden md:flex">{label}</span>
</>
)}
</li>
</Link>
);
}

if (showAllNavItems) {
return navItems.map(({ path, label, Icon }) => (
<Link key={label} to={path} className="w-full">
Expand Down
1 change: 1 addition & 0 deletions src/data/appCloseDate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const appCloseDate = "2024-05-05T00:00:00-04:00"; // May 5th, 2024 at midnight EST
8 changes: 8 additions & 0 deletions src/navigation/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import {
} from "@pages";
import { ProtectedRoutes } from "@/navigation";
import { useEffect, useState } from "react";
import { isAfter } from "date-fns";
import { useAuth } from "@/providers/auth.provider";
import { LoadingAnimation } from "@/components";
import { PostSubmissionPage } from "@/pages/miscellaneous/PostSubmission.page";
import { appCloseDate } from "@/data/appCloseDate";

export const routes = {
admin: "/admin",
Expand Down Expand Up @@ -78,6 +80,12 @@ export const Router = () => {
useEffect(() => {
if (userApp === undefined) return;

const today = new Date();

if (isAfter(today, new Date(appCloseDate))) {
setAvailableRoutes([]);
}

if (userApp && userApp.applicationStatus === "accepted") {
setAvailableRoutes([
{
Expand Down
21 changes: 19 additions & 2 deletions src/pages/user/User.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,33 @@ import { getButtonStyles } from "@/components/Button/Button.styles";
import { routes } from "@/navigation/constants";
import { useAuth } from "@/providers/auth.provider";
import { Link } from "react-router-dom";
import { isAfter } from "date-fns";
import { useEffect, useState } from "react";
import { InfoCallout } from "@/components/InfoCallout/InfoCallout";
import { appCloseDate } from "@/data/appCloseDate";

const UserPage = () => {
const [showInfo, setShowInfo] = useState(false);
const { userApp } = useAuth();

useEffect(() => {
const today = new Date();
setShowInfo(isAfter(today, new Date(appCloseDate)));
}, []);

return (
<>
{showInfo && (
<div className="w-fit mb-4">
<InfoCallout text="Applications have now closed for HawkHacks 2024." />
</div>
)}
<h3 className="text-md md:text-2xl font-bold">My Application</h3>
<div className="mt-4">
{userApp ? (
<Button disabled={!!userApp}>Submitted</Button>
{userApp || showInfo ? (
<Button disabled={!!userApp || showInfo}>
{showInfo ? "Applications Closed" : "Submitted"}
</Button>
) : (
<Link
to={routes.application}
Expand Down

0 comments on commit 3db6292

Please sign in to comment.