Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
add hackathon constants filtering, logo fix, schedule scroll (#574)
Browse files Browse the repository at this point in the history
* add hackathon constants filtering, logo fix, schedule scroll

* add typings
  • Loading branch information
refcell authored Jan 29, 2021
1 parent a1284a5 commit 387e9de
Show file tree
Hide file tree
Showing 12 changed files with 128 additions and 58 deletions.
5 changes: 3 additions & 2 deletions components/hackerDashboard/AdminDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ import ActionsWidget from "./widgets/admin/actions";
type Props = {
profile: Profile;
events: Array<any>;
hackathonConstants: any;
};

const AdminDashboard = (props: Props) => {
const { profile, events } = props;
const { profile, events, hackathonConstants } = props;

return (
<Container>
<Navbar activePage="dashboard" />
<Navbar hackathonConstants={hackathonConstants} activePage="dashboard" />
<Header text={"Admin Dashboard"} />
<WidgetFrame
widget="one"
Expand Down
6 changes: 5 additions & 1 deletion components/hackerDashboard/Application.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
export {};
const Application = () => {
return <div></div>;
};

export default Application;
27 changes: 15 additions & 12 deletions components/hackerDashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,35 @@ import Image from "next/image";
import Logo from "@/assets/hackscFox.png";

// Layout
import Navbar from "./layout/Navbar";
import Sidebar from "./layout/Sidebar";
import Footer from "./layout/Footer";
import Header from "./layout/Header";
import { Navbar, Sidebar, Footer, Header } from "./layout";
import WidgetFrame from "./HackerWidgetFrame";

// Widgets
import Battlepass from "./widgets/battlepass";
import Updates from "./widgets/updates";
import { getHackathonConstants, getProfile, getPublicEvents } from "@/lib";
import { BattlepassWidget, UpdatesWidget } from "./widgets";

type HackathonConstant = {
id: number;
name: string;
boolean: boolean;
date: string;
type: any;
};

type Props = {
profile: Profile;
events: Array<any>;
hackathonConstants: Array<HackathonConstant>;
};

const Dashboard = ({ profile, events }: Props) => {
console.log(events);
const Dashboard = ({ profile, events, hackathonConstants }: Props) => {
return (
<Container>
<FoxLogo />
<Navbar activePage="dashboard" />
<Navbar hackathonConstants={hackathonConstants} activePage="dashboard" />
<Header />
<WidgetFrame widget="one" component={<h2>Your team</h2>} />
<WidgetFrame widget="two" component={<Battlepass />} />
<WidgetFrame widget="three" component={<Updates />} />
<WidgetFrame widget="two" component={<BattlepassWidget />} />
<WidgetFrame widget="three" component={<UpdatesWidget />} />
<Empty />
<Sidebar view="hacker" events={events} />
<Footer />
Expand Down
9 changes: 9 additions & 0 deletions components/hackerDashboard/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// * Subdirs
export * from "./layout";
export * from "./widgets";

// * Files
export { default as AdminDashboard } from "./AdminDashboard";
export { default as Application } from "./Application";
export { default as Dash } from "./Dashboard";
export { default as HackerWidgetFrame } from "./HackerWidgetFrame";
2 changes: 1 addition & 1 deletion components/hackerDashboard/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const DashHeader = ({ text }: Props) => {
<Title>HackSC 2021</Title>
) : (
<LogoWrapper>
<Image src={Logo} width="100%" height="100%" alt="" />
<Image src={Logo} width="220%" height="100%" alt="" />
</LogoWrapper>
)}
</Header>
Expand Down
88 changes: 61 additions & 27 deletions components/hackerDashboard/layout/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,72 @@
import styled from "styled-components";

const MenuItems = [
{ title: "Dashboard", route: "dashboard" },
{ title: "Application", route: "application" },
{ title: "Results", route: "results" },
{ title: "Team", route: "team" },
{ title: "Maps", route: "maps" },
{ title: "Resources", route: "resources" },
{ title: "Dashboard", route: "dashboard", constant: "showDash" },
{ title: "Application", route: "application", constant: "showApp" },
{ title: "Results", route: "results", constant: "showResults" },
{ title: "Team", route: "team", constant: "showTeam" },
{ title: "Maps", route: "maps", constant: "showMaps" },
{ title: "Resources", route: "resources", constant: "showAPI" },
];

const MenuItem = ({ activePage, title, route }) => (
<BoxShadowWrapper>
<SidebarMenuItem
href={"/" + route}
active={activePage === route || activePage === title}
>
<SidebarMenuItemLabel>{title}</SidebarMenuItemLabel>
</SidebarMenuItem>
</BoxShadowWrapper>
);
type Item = {
title: string;
route: string;
constant: string;
};

type HackathonConstant = {
id: number;
name: string;
boolean: boolean;
date: string;
type: any;
};

type NavbarProps = {
activePage: string;
hackathonConstants: Array<HackathonConstant>;
};

type MenuItemProps = {
activePage: string;
item: Item;
hackathonConstants: Array<HackathonConstant>;
};

const MenuItem = ({ activePage, item, hackathonConstants }: MenuItemProps) => {
let show = true;
hackathonConstants.forEach((c) => {
if (item.constant == c.name) show = c.boolean;
});

return show ? (
<BoxShadowWrapper>
<NavbarMenuItem
href={"/" + item.route}
active={activePage === item.route || activePage === item.title}
>
<NavbarMenuItemLabel>{item.title}</NavbarMenuItemLabel>
</NavbarMenuItem>
</BoxShadowWrapper>
) : (
""
);
};

const Sidebar = ({ activePage }) => {
const Navbar = ({ activePage, hackathonConstants }: NavbarProps) => {
return (
<SidebarContainer>
<SidebarMenu>
<NavbarContainer>
<NavbarMenu>
{MenuItems.map((item) =>
MenuItem({ activePage, title: item.title, route: item.route })
MenuItem({ activePage, item: item, hackathonConstants })
)}
</SidebarMenu>
</SidebarContainer>
</NavbarMenu>
</NavbarContainer>
);
};

const SidebarContainer = styled.div`
const NavbarContainer = styled.div`
grid-area: Navbar;
background-color: #1d2c3f;
color: #fff;
Expand All @@ -41,7 +75,7 @@ const SidebarContainer = styled.div`
font-family: "Work Sans", sans-serif;
`;

const SidebarMenu = styled.ul`
const NavbarMenu = styled.ul`
display: flex;
align-items: left;
flex-direction: column;
Expand All @@ -61,7 +95,7 @@ type AProps = {
active: boolean;
};

const SidebarMenuItem = styled.a<AProps>`
const NavbarMenuItem = styled.a<AProps>`
display: flex;
height: 60px;
width: auto;
Expand All @@ -78,7 +112,7 @@ const SidebarMenuItem = styled.a<AProps>`
active ? "rgba(255, 255, 255, 0.03)" : "#2d4158"};
`;

const SidebarMenuItemLabel = styled.p`
const NavbarMenuItemLabel = styled.p`
font-family: "Work Sans", sans-serif;
font-size: 24px;
font-weight: 600;
Expand All @@ -88,4 +122,4 @@ const SidebarMenuItemLabel = styled.p`
margin-left: 8px;
`;

export default Sidebar;
export default Navbar;
4 changes: 4 additions & 0 deletions components/hackerDashboard/layout/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { default as Footer } from "./Footer";
export { default as Header } from "./Header";
export { default as Navbar } from "./Navbar";
export { default as Sidebar } from "./Sidebar";
1 change: 1 addition & 0 deletions components/hackerDashboard/widgets/admin/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as ActionsWidget } from "./actions";
15 changes: 8 additions & 7 deletions components/hackerDashboard/widgets/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export {
HackathonCountdown,
HackathonDates,
HackathonEvents,
Stats,
Uptime,
} from "./sidebar";
// * Subdirs
export * from "./admin";
export * from "./sidebar";

// * Files
export { default as BattlepassWidget } from "./battlepass";
export { default as TeamWidget } from "./team";
export { default as UpdatesWidget } from "./updates";
2 changes: 2 additions & 0 deletions components/hackerDashboard/widgets/sidebar/events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const HackathonEvents = ({ events }) => {

const EventList = styled.div`
border-radius: 4px;
max-height: 400px;
overflow: scroll;
`;

const Event = styled.div`
Expand Down
4 changes: 2 additions & 2 deletions components/hackerDashboard/widgets/updates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import styled from "styled-components";

import Logo from "@/assets/hackscFox.png";

const Updates = () => {
const UpdatesWidget = () => {
return (
<div>
<Header>Announcements</Header>
Expand Down Expand Up @@ -86,4 +86,4 @@ const UpdateText = styled.div`
letter-spacing: 1px;
`;

export default Updates;
export default UpdatesWidget;
23 changes: 17 additions & 6 deletions pages/dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useState } from "react";
import Dash from "../components/hackerDashboard/Dashboard";
import AdminDashboard from "../components/hackerDashboard/AdminDashboard";
import { Dash, AdminDashboard } from "@/components/hackerDashboard";

import {
handleLoginRedirect,
Expand All @@ -13,7 +12,7 @@ import {
getPublicEvents,
} from "@/lib";

const Dashboard = ({ profile, events }) => {
const Dashboard = ({ profile, events, hackathonConstants }) => {
const [view, setView] = useState("hacker");

const switchRole = () => {
Expand All @@ -25,11 +24,22 @@ const Dashboard = ({ profile, events }) => {
};

const getDashToRender = () => {
//@ts-ignore - the NODE_ENV var doesnt support dev
if (view === "admin") {
return <AdminDashboard profile={profile} events={events} />;
return (
<AdminDashboard
profile={profile}
events={events}
hackathonConstants={hackathonConstants}
/>
);
} else {
return <Dash profile={profile} events={events} />;
return (
<Dash
profile={profile}
events={events}
hackathonConstants={hackathonConstants}
/>
);
}
};

Expand Down Expand Up @@ -86,6 +96,7 @@ export async function getServerSideProps({ req }) {
profile,
socialPosts,
events,
hackathonConstants,
},
};
}
Expand Down

0 comments on commit 387e9de

Please sign in to comment.