Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup app close pages #297

Merged
merged 2 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-06-05T00:00:00-04:00"; // May 6th, 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
Loading