-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hotfix: add hacker count to Admin Dashboard
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
apps/site/src/app/admin/dashboard/components/HackerCount.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import Container from "@cloudscape-design/components/container"; | ||
import dayjs from "dayjs"; | ||
import timezone from "dayjs/plugin/timezone"; | ||
import utc from "dayjs/plugin/utc"; | ||
|
||
import useParticipants, { Role } from "@/lib/admin/useParticipants"; | ||
|
||
dayjs.extend(utc); | ||
dayjs.extend(timezone); | ||
|
||
const EVENT_TIMEZONE = "America/Los_Angeles"; | ||
|
||
const FRIDAY = dayjs(new Date("2024-01-26T12:00:00")).tz(EVENT_TIMEZONE); | ||
|
||
function HackerCount() { | ||
const { participants, loading } = useParticipants(); | ||
|
||
const checkedIn = participants | ||
.filter((participant) => participant.role === Role.Applicant) | ||
.filter((participant) => | ||
participant.checkins.some(([datetime]) => | ||
FRIDAY.isSame(dayjs(datetime).tz(EVENT_TIMEZONE), "date"), | ||
), | ||
); | ||
|
||
if (loading) { | ||
return <Container>-</Container>; | ||
} | ||
|
||
return <Container>HackerCount {checkedIn.length}</Container>; | ||
} | ||
|
||
export default HackerCount; |