Skip to content

Commit

Permalink
fix bugs in hacker page
Browse files Browse the repository at this point in the history
  • Loading branch information
JihengLi committed Sep 13, 2024
1 parent 7bc82c8 commit 9da4e7d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 71 deletions.
2 changes: 1 addition & 1 deletion components/hacker/HackerDash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ export default function HackerDash({ userApplicationStatus, setUserApplicationSt
<div style={{ padding: '20px' }}>
<Header user={user} signOut={signOut} setting={setting as HackathonSettingsData} />

<TeamManagement />
{/* <TeamManagement /> */}
<JudgingSchedule judgingSessionData={judgingSessionData} />
<Leaderboard />

Expand Down
8 changes: 3 additions & 5 deletions components/hacker/JudgingSchedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,23 @@ const JudgingSchedule = ({ judgingSessionData }: JudgingScheduleProps) => {
return (
<div className={styles.Container}>
Judging Schedule
<div className={styles.Description}>
You will be assigned a table and judge for judging. Please be at your table at the time indicated below.
</div>
<div className={styles.Description}>You will be assigned a table and judge for judging.</div>
{judgingSessionData?.length === 0 ? (
<div className={styles.Placeholder}>Schedule will show up here when hacking ends!</div>
) : (
<div className={styles.TableContainer}>
<table>
<thead>
<tr>
<th>Time</th>
{/* <th>Time</th> */}
<th>Table</th>
<th>Judge</th>
</tr>
</thead>
<tbody>
{judgingSessionData?.map(entry => (
<tr key={entry.time.toString()}>
<td>{renderJudgingTime(entry.time.toString())}</td>
{/* <td>{renderJudgingTime(entry.time.toString())}</td> */}
<td>{entry.team.locationNum}</td>
<td>{entry.judge.name}</td>
</tr>
Expand Down
56 changes: 0 additions & 56 deletions components/judges/JudgeDash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ async function handleSubmit(
export default function JudgeDash() {
const { data: session, status } = useSession();
const [teamID, setTeamID] = useState('');
// const [currentScheduleItem, setCurrentScheduleItem] = useState<JudgingSessionData | undefined>(undefined);
// const [nextScheduleItem, setNextScheduleItem] = useState<JudgingSessionData | undefined>(undefined);
const [isNewForm, setIsNewForm] = useState(false);
const [nextIndex, setNextIndex] = useState(-1);
const { mutate } = useSWRConfig();
Expand Down Expand Up @@ -133,60 +131,6 @@ export default function JudgeDash() {
return (await res.json()) as JudgingSessionData[];
});

// // Initialize state if data was just received
// useEffect(() => {
// if (nextIndex === -1 && scheduleData) {
// const now = Date.now();
// let index = scheduleData.findIndex(el => now < new Date(el.time as string).getTime());
// if (index === -1) index = scheduleData.length;
// let currentlyGoingTime = new Date(scheduleData[index - 1]?.time as string).getTime() + judgingLength;
// setNextScheduleItem(scheduleData[index]);
// setCurrentScheduleItem(now < currentlyGoingTime ? scheduleData[index - 1] : undefined);
// setNextIndex(index);
// }
// }, [scheduleData, nextIndex, judgingLength]);

// // Loop to manage current schedule state
// useEffect(() => {
// const interval = setInterval(() => {
// const now = Date.now();
// if (scheduleData && nextIndex > -1) {
// // Data has been received and state is initialized
// let time2 = new Date(scheduleData[scheduleData.length - 1]?.time as string).getTime() + judgingLength;
// if (now <= time2) {
// // Not yet done judging
// let time3 = new Date((currentScheduleItem?.time as string) || 0).getTime() + judgingLength;

// if (
// nextIndex < scheduleData.length &&
// now >= new Date((nextScheduleItem?.time as string) || 0).getTime()
// ) {
// // Next event should be current
// setNextScheduleItem(scheduleData[nextIndex + 1]);
// setCurrentScheduleItem(scheduleData[nextIndex]);
// setNextIndex(nextIndex + 1);
// } else if (now > time3) {
// // Next event has not yet arrived but current event is over
// setCurrentScheduleItem(undefined);
// }
// } else {
// // Done judging
// setCurrentScheduleItem(undefined);
// }
// }
// }, 1000);
// return () => clearInterval(interval);
// });

// useEffect(() => {
// if (nextIndex === -1 && scheduleData) {
// const today = new Date().setHours(0, 0, 0, 0);
// let index = scheduleData.findIndex(el => today < new Date(el.time as string).getTime());
// if (index === -1) index = scheduleData.length;
// setNextIndex(index);
// }
// }, [scheduleData, nextIndex, judgingLength]);

const handleTeamChange: Dispatch<SetStateAction<string>> = e => {
setTeamID(e);
setTimeout(() => {
Expand Down
8 changes: 0 additions & 8 deletions components/judges/TeamSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,6 @@ export default function TeamSelect(props: TeamSelectProps) {
))}
</OptGroup>
)}
{/* // we should not allow the judge to see and update the score of others
<OptGroup label="All Teams">
{teamsData.map(team => (
<Option value={team._id} key={`${team._id}ALL`}>
{team.haveJudged ? withCheckMark(team.name) : team.name}
</Option>
))}
</OptGroup> */}
</Select>
</Space>
);
Expand Down
5 changes: 4 additions & 1 deletion pages/api/leaderboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
await dbConnect();
switch (req.method) {
case 'GET':
const users = await User.find({ nfcPoints: { $exists: true } })
const users = await User.find({
userType: 'HACKER',
nfcPoints: { $exists: true },
})
.sort({ nfcPoints: -1 })
.limit(10)
.populate('team')
Expand Down

0 comments on commit 9da4e7d

Please sign in to comment.