diff --git a/package.json b/package.json index 3b51cd0f..02362cc5 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6b97a653..4a2671df 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,6 +14,9 @@ dependencies: class-variance-authority: specifier: ^0.7.0 version: 0.7.0 + date-fns: + specifier: ^3.6.0 + version: 3.6.0 firebase: specifier: ^10.5.2 version: 10.5.2 @@ -2921,6 +2924,10 @@ packages: '@babel/runtime': 7.23.2 dev: true + /date-fns@3.6.0: + resolution: {integrity: sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww==} + dev: false + /debug@2.6.9: resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==} peerDependencies: diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index 421b3b14..5743f72d 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -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 }, @@ -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 ( + +
  • + {isMobile ? ( + label + ) : ( + <> + + {label} + + )} +
  • + + ); + } + if (showAllNavItems) { return navItems.map(({ path, label, Icon }) => ( diff --git a/src/data/appCloseDate.ts b/src/data/appCloseDate.ts new file mode 100644 index 00000000..efbbbb6d --- /dev/null +++ b/src/data/appCloseDate.ts @@ -0,0 +1 @@ +export const appCloseDate = "2024-06-05T00:00:00-04:00"; // May 6th, 2024 at midnight EST diff --git a/src/navigation/Router.tsx b/src/navigation/Router.tsx index d247b1f4..574e3bad 100644 --- a/src/navigation/Router.tsx +++ b/src/navigation/Router.tsx @@ -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", @@ -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([ { diff --git a/src/pages/user/User.page.tsx b/src/pages/user/User.page.tsx index e6cab127..28688c35 100644 --- a/src/pages/user/User.page.tsx +++ b/src/pages/user/User.page.tsx @@ -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 && ( +
    + +
    + )}

    My Application

    - {userApp ? ( - + {userApp || showInfo ? ( + ) : (