diff --git a/frontend/src/App.module.css b/frontend/src/App.module.css index 2cc1179..55762ab 100644 --- a/frontend/src/App.module.css +++ b/frontend/src/App.module.css @@ -76,4 +76,49 @@ body { .aboutPage { padding: 20px; +} + +/* --------------------------------------------------------- LEADERBOARD PAGE STYLES ---------------------------------------------------*/ + +.leaderboardPage { + padding-left: 20px; + white-space: pre-wrap; +} + +.userProfile { + font-family: monospace; +} + +.profileText { + padding-right: 8px; +} + +.userImg { + padding-right: 4px; +} + +.link { + color: #009900; + text-decoration: none; +} + +.dayLink { + color: #009900; + text-decoration: none; + cursor: pointer; + padding-left: 4px; +} + +.daySelected { + color: white; + font-weight: 700; + padding-left: 4px; +} + +.userNoLinkText { + padding-left: 24px; +} + +.leaderBoardDays { + padding-left: 4px; } \ No newline at end of file diff --git a/frontend/src/components/leaderboard/UserProfile.tsx b/frontend/src/components/leaderboard/UserProfile.tsx new file mode 100644 index 0000000..5c52142 --- /dev/null +++ b/frontend/src/components/leaderboard/UserProfile.tsx @@ -0,0 +1,25 @@ +import React, { useEffect, useState } from "react"; +import styles from "../../App.module.css"; +import { UserDetails } from "../../pages/Leaderboard"; + +const UserProfile = (props: UserDetails) => { + return ( +
+ {(props.position.toString() + ")").padStart(4)} + {props.userScore.toString().padStart(4)} + {(props.userLink != "") + ? + + + + {props.userName} + + : + {props.userName} + + } +
+ ) +}; + +export default UserProfile; diff --git a/frontend/src/pages/Leaderboard.tsx b/frontend/src/pages/Leaderboard.tsx index d9c814f..47e5afe 100644 --- a/frontend/src/pages/Leaderboard.tsx +++ b/frontend/src/pages/Leaderboard.tsx @@ -1,11 +1,45 @@ import React, { useEffect, useState } from "react"; import { Button, Container } from "react-bootstrap"; -import { useNavigate } from "react-router-dom"; +import { Navigate, useNavigate } from "react-router-dom"; +import styles from "../App.module.css"; +import UserProfile from "../components/leaderboard/UserProfile" import { BACKEND_URI } from "src/config"; +export interface UserDetails { + position: number; + userName: string; + userScore: number; + userLink: string; +} + const Leaderboard: React.FC<{}> = () => { - const [times, setTimes] = useState(0); + + const defaultUsers: UserDetails[] = [ + { + position: 1, + userName: "csesoc", + userScore: 9999, + userLink: "https://github.com/csesoc" + }, + { + position: 10, + userName: "no_github_link", + userScore: 999, + userLink: "" + }, + { + position: 100, + userName: "a-jason-liu21", + userScore: 99, + userLink: "https://github.com/a-jason-liu21" + } + ] + + const DAYS = 7; + const OVERALL = 0; + const [users, setUsers] = useState(defaultUsers); + const [day, setDay] = useState(OVERALL); useEffect(() => { const verifyToken = async () => { @@ -15,13 +49,39 @@ const Leaderboard: React.FC<{}> = () => { verifyToken(); }, []); + useEffect(() => { + console.log("Doing backend query for day " + day + "!"); + }, [day]); + return ( - <> - -

You have clicked this button {times} times.

- -
- +
+
+ This is the {(day === OVERALL) ? "overall leaderboard" : ("leaderboard for day " + day)} of the CSESoc Unnamed Puzzle Competition 2021, + which displays the users with the {(day === OVERALL) ? "highest cumulative points achieved during the contest" : "earliest submissions during the day"}. +
+
+ +
+ Points awarded for completing problems - the first to solve a problem receives 100 points, followed by 99 points for + the second solver, then 98 and so on down to 1 point for the 100th solver. +
+
+ +
+ To see the leaderboard for a particular day, choose a day here: + {Array.from({length: DAYS},(x, i) => setDay(i + 1)}>{i + 1})} +
+ + {day !== OVERALL && +
+ To see the overall leaderboard, click setDay(0)}>here. +
} +
+ + {users.map((user: UserDetails) => { + return + })} +
) };