-
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.
Show check-ins per day in Participants table (#363)
- Provide checkins list in participants endpoint - Add columns for each day of the event with an icon on check-in status - Disable resizable columns
- Loading branch information
Showing
4 changed files
with
85 additions
and
3 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
38 changes: 38 additions & 0 deletions
38
apps/site/src/app/admin/participants/components/CheckinDayIcon.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,38 @@ | ||
import Icon from "@cloudscape-design/components/icon"; | ||
import dayjs from "dayjs"; | ||
import timezone from "dayjs/plugin/timezone"; | ||
import utc from "dayjs/plugin/utc"; | ||
|
||
import { Checkin } from "@/lib/admin/useParticipants"; | ||
|
||
dayjs.extend(utc); | ||
dayjs.extend(timezone); | ||
const EVENT_TIMEZONE = "America/Los_Angeles"; | ||
|
||
interface CheckinDayProps { | ||
checkins: Checkin[]; | ||
date: Date; | ||
} | ||
|
||
const today = dayjs().tz(EVENT_TIMEZONE); | ||
|
||
function CheckinDayIcon({ checkins, date }: CheckinDayProps) { | ||
// Timezones are weird, but comparing the days of the check-ins | ||
const day = dayjs(date).tz(EVENT_TIMEZONE); | ||
const checkinTimes = checkins.map(([datetime]) => | ||
dayjs(datetime).tz(EVENT_TIMEZONE), | ||
); | ||
|
||
const checkedIn = checkinTimes.some((checkin) => day.isSame(checkin, "date")); | ||
const past = day.isBefore(today, "date"); | ||
|
||
if (checkedIn) { | ||
return <Icon name="status-positive" variant="success" alt="Checked in" />; | ||
} | ||
if (past) { | ||
return <Icon name="status-negative" variant="error" alt="No show" />; | ||
} | ||
return <Icon name="status-pending" variant="subtle" alt="Pending" />; | ||
} | ||
|
||
export default CheckinDayIcon; |
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
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