-
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.
Integrate waitlist promotion modal and action (#346)
* fix: get_hackers function call * Waitlist Promotion System - Create new promote action that shows modal with confirmation button and instructions to participant - Show promote action instead of check in for waitlisted participants - Disable promote action for organizers who are not check-in leads, showing PopOver message - Disable check in action for participants with `WAIVER_SIGNED` status, showing PopOver message * Update apps/site/src/app/admin/participants/Participants.tsx Co-authored-by: Taesung Hwang <[email protected]> * grant directors promotion, along with refactoring * Update apps/site/src/app/admin/participants/Participants.tsx Co-authored-by: Taesung Hwang <[email protected]> * fix: remove export, PropsWithChildren usage * fix: typo in filename * fix: rename import, isCheckin logic * fix: disable check in button for ACCEPTED status --------- Co-authored-by: Taesung Hwang <[email protected]>
- Loading branch information
1 parent
8256afd
commit b3784fe
Showing
9 changed files
with
173 additions
and
11 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
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
50 changes: 48 additions & 2 deletions
50
apps/site/src/app/admin/participants/components/ParticipantAction.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 |
---|---|---|
@@ -1,26 +1,72 @@ | ||
import { useContext } from "react"; | ||
|
||
import Button from "@cloudscape-design/components/button"; | ||
|
||
import UserContext from "@/lib/admin/UserContext"; | ||
import { isCheckinLead } from "@/lib/admin/authorization"; | ||
import { Status } from "@/lib/admin/useApplicant"; | ||
import { Participant } from "@/lib/admin/useParticipants"; | ||
import ParticipantActionPopover from "./ParticipantActionPopover"; | ||
|
||
interface ParticipantActionProps { | ||
participant: Participant; | ||
initiateCheckIn: (participant: Participant) => void; | ||
initiatePromotion: (participant: Participant) => void; | ||
} | ||
|
||
function ParticipantAction({ | ||
participant, | ||
initiateCheckIn, | ||
initiatePromotion, | ||
}: ParticipantActionProps) { | ||
// TODO: waitlist promotion | ||
const { role } = useContext(UserContext); | ||
|
||
const isCheckin = isCheckinLead(role); | ||
const isWaiverSigned = participant.status === Status.signed; | ||
const isAccepted = participant.status === Status.accepted; | ||
|
||
const promoteButton = ( | ||
<Button | ||
variant="inline-link" | ||
ariaLabel={`Promote ${participant._id} off waitlist`} | ||
onClick={() => initiatePromotion(participant)} | ||
disabled={!isCheckin} | ||
> | ||
Promote | ||
</Button> | ||
); | ||
|
||
return ( | ||
const checkinButton = ( | ||
<Button | ||
variant="inline-link" | ||
ariaLabel={`Check in ${participant._id}`} | ||
onClick={() => initiateCheckIn(participant)} | ||
disabled={isWaiverSigned || isAccepted} | ||
> | ||
Check In | ||
</Button> | ||
); | ||
|
||
if (participant.status === Status.waitlisted) { | ||
if (!isCheckin) { | ||
return ( | ||
<ParticipantActionPopover content="Only check-in leads are allowed to promote walk-ins."> | ||
{promoteButton} | ||
</ParticipantActionPopover> | ||
); | ||
} | ||
return promoteButton; | ||
} else if (isWaiverSigned || isAccepted) { | ||
const content = isWaiverSigned | ||
? "Must confirm attendance in portal first" | ||
: "Must sign waiver and confirm attendance in portal"; | ||
return ( | ||
<ParticipantActionPopover content={content}> | ||
{checkinButton} | ||
</ParticipantActionPopover> | ||
); | ||
} | ||
return checkinButton; | ||
} | ||
|
||
export default ParticipantAction; |
25 changes: 25 additions & 0 deletions
25
apps/site/src/app/admin/participants/components/ParticipantActionPopover.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,25 @@ | ||
import Popover from "@cloudscape-design/components/popover"; | ||
import { PropsWithChildren } from "react"; | ||
|
||
interface ParticipantActionPopoverProps { | ||
content: string; | ||
} | ||
|
||
function ParticipantActionPopover({ | ||
content, | ||
children, | ||
}: PropsWithChildren<ParticipantActionPopoverProps>) { | ||
return ( | ||
<Popover | ||
dismissButton={false} | ||
position="top" | ||
size="medium" | ||
triggerType="custom" | ||
content={content} | ||
> | ||
{children} | ||
</Popover> | ||
); | ||
} | ||
|
||
export default ParticipantActionPopover; |
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
50 changes: 50 additions & 0 deletions
50
apps/site/src/app/admin/participants/components/WaitlistPromotionModal.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,50 @@ | ||
import Box from "@cloudscape-design/components/box"; | ||
import Button from "@cloudscape-design/components/button"; | ||
import Modal from "@cloudscape-design/components/modal"; | ||
import SpaceBetween from "@cloudscape-design/components/space-between"; | ||
import TextContent from "@cloudscape-design/components/text-content"; | ||
|
||
import { ActionModalProps } from "./CheckInModal"; | ||
|
||
function WaitlistPromotionModal({ | ||
onDismiss, | ||
onConfirm, | ||
participant, | ||
}: ActionModalProps) { | ||
if (participant === null) { | ||
return <Modal visible={false} />; | ||
} | ||
|
||
return ( | ||
<Modal | ||
onDismiss={onDismiss} | ||
visible={true} | ||
footer={ | ||
<Box float="right"> | ||
<SpaceBetween direction="horizontal" size="xs"> | ||
<Button variant="link" onClick={onDismiss}> | ||
Cancel | ||
</Button> | ||
<Button variant="primary" onClick={() => onConfirm(participant)}> | ||
Promote | ||
</Button> | ||
</SpaceBetween> | ||
</Box> | ||
} | ||
header={`Promote ${participant?.first_name} ${participant?.last_name} Off Waitlist`} | ||
> | ||
<SpaceBetween size="m"> | ||
<TextContent> | ||
<ul> | ||
{/* TODO: actual instructions for check-in leads */} | ||
<li>Log into the portal</li> | ||
<li>Sign waiver</li> | ||
<li>Confirm attendance</li> | ||
</ul> | ||
</TextContent> | ||
{/* TODO: badge barcode input */} | ||
</SpaceBetween> | ||
</Modal> | ||
); | ||
} | ||
export default WaitlistPromotionModal; |
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