Skip to content

Commit

Permalink
Hotfix: add hacker count to Admin Dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
taesungh committed Jan 27, 2024
1 parent d707da1 commit bfa8f03
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apps/site/src/app/admin/dashboard/AdminDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { isApplicationManager } from "@/lib/admin/authorization";
import UserContext from "@/lib/admin/UserContext";

import ApplicantSummary from "./components/ApplicantSummary";
import HackerCount from "./components/HackerCount";

function AdminDashboard() {
const { role } = useContext(UserContext);
Expand All @@ -19,6 +20,7 @@ function AdminDashboard() {
<SpaceBetween size="l">
<Container>Admin Dashboard</Container>
{isApplicationManager(role) && <ApplicantSummary />}
<HackerCount />
</SpaceBetween>
</ContentLayout>
);
Expand Down
33 changes: 33 additions & 0 deletions apps/site/src/app/admin/dashboard/components/HackerCount.tsx
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;

0 comments on commit bfa8f03

Please sign in to comment.