Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced the routes in the buttons with modals in ./participants/check-in #628

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
import { useState, useEffect } from 'react';
import { useRouter } from 'next/router';

import { Button, FormControl, FormLabel, Select } from '@chakra-ui/react';
import {
Button,
FormControl,
FormLabel,
Select,
Modal,
ModalBody,
ModalContent,
ModalOverlay,
ModalHeader,
ModalFooter,
ModalCloseButton,
useColorMode,
Box,
} from '@chakra-ui/react';

import DashboardLayout from '@/layouts/DashboardLayout';

import { useAlert } from '@/hooks/useAlert';
import { useFetch } from '@/hooks/useFetch';
import useWrapper from '@/hooks/useWrapper';

export default function CheckInParticipant() {
export default function CheckInParticipant({ isOpen, onClose }) {
const { loading, post, get } = useFetch();
const showAlert = useAlert();

Expand All @@ -18,9 +32,11 @@ export default function CheckInParticipant() {

const { useGetQuery } = useWrapper();

const [checkInKey, setcheckInKey] = useState(null);
const [checkInKey, setCheckInKey] = useState(null);
const [participants, setParticipants] = useState([]);

const { colorMode } = useColorMode();

const handleSubmit = async (e) => {
e.preventDefault();

Expand Down Expand Up @@ -63,114 +79,157 @@ export default function CheckInParticipant() {
}, [checkInKey]);

return (
<DashboardLayout
pageTitle="Check In Participant"
previousPage={`/organizations/${orgId}/events/${eventId}/participants/check-in`}
debugInfo={JSON.stringify(checkInKey)}
>
<form onSubmit={handleSubmit}>
<FormControl my={4}>
<FormLabel>Participant ID</FormLabel>
<Select
placeholder="Select Participant ID"
value={checkInKey}
onChange={(e) => {
setcheckInKey(e.target.value);
}}
>
{participants.map((participant) => (
<option key={participant.id} value={participant.checkInKey}>
{participant.id}
</option>
))}
</Select>
</FormControl>
<FormControl my={4}>
<FormLabel>First Name</FormLabel>
<Select
placeholder="Select First Name"
value={checkInKey}
onChange={(e) => {
setcheckInKey(e.target.value);
}}
>
{participants.map((participant) => (
<option key={participant.id} value={participant.checkInKey}>
{participant.firstName}
</option>
))}
</Select>
</FormControl>
<FormControl my={4}>
<FormLabel>Last Name</FormLabel>
<Select
placeholder="Select Last Name"
value={checkInKey}
onChange={(e) => {
setcheckInKey(e.target.value);
}}
>
{participants.map((participant) => (
<option key={participant.id} value={participant.checkInKey}>
{participant.lastName}
</option>
))}
</Select>
</FormControl>
<Modal isOpen={isOpen} onClose={onClose} size="lg" scrollBehavior="outside" isCentered>
<ModalOverlay />
<ModalContent borderRadius="10px">
<ModalHeader
backgroundColor="#AFB4E9"
p={6}
borderTopLeftRadius="10px"
borderTopRightRadius="10px"
color="black"
>
Check In Participant
<ModalCloseButton color="black" />
</ModalHeader>
<ModalBody backgroundColor={colorMode === 'light' ? '#EEEFFF' : '#101116'}>
<Box pl={4} pr={4} pb={0}>
<form onSubmit={handleSubmit}>
<FormControl my={4}>
<FormLabel>Participant ID</FormLabel>
<Select
backgroundColor={colorMode === 'light' ? '#04050B12' : '#FBFBFE12'}
placeholder="Select Participant ID"
value={checkInKey}
onChange={(e) => {
setCheckInKey(e.target.value);
}}
>
{participants.map((participant) => (
<option key={participant.id} value={participant.checkInKey}>
{participant.id}
</option>
))}
</Select>
</FormControl>
<FormControl my={4}>
<FormLabel>First Name</FormLabel>
<Select
backgroundColor={colorMode === 'light' ? '#04050B12' : '#FBFBFE12'}
placeholder="Select First Name"
value={checkInKey}
onChange={(e) => {
setCheckInKey(e.target.value);
}}
>
{participants.map((participant) => (
<option key={participant.id} value={participant.checkInKey}>
{participant.firstName}
</option>
))}
</Select>
</FormControl>
<FormControl my={4}>
<FormLabel>Last Name</FormLabel>
<Select
backgroundColor={colorMode === 'light' ? '#04050B12' : '#FBFBFE12'}
placeholder="Select Last Name"
value={checkInKey}
onChange={(e) => {
setCheckInKey(e.target.value);
}}
>
{participants.map((participant) => (
<option key={participant.id} value={participant.checkInKey}>
{participant.lastName}
</option>
))}
</Select>
</FormControl>

<FormControl my={4}>
<FormLabel>Phone Number</FormLabel>
<Select
placeholder="Select Phone Number"
value={checkInKey}
onChange={(e) => {
setcheckInKey(e.target.value);
}}
>
{participants.map((participant) => (
<option key={participant.id} value={participant.checkInKey}>
{participant.phone}
</option>
))}
</Select>
</FormControl>
<FormControl my={4}>
<FormLabel>Email</FormLabel>
<Select
placeholder="Select Email"
value={checkInKey}
onChange={(e) => {
setcheckInKey(e.target.value);
}}
>
{participants.map((participant) => (
<option key={participant.id} value={participant.checkInKey}>
{participant.email}
</option>
))}
</Select>
</FormControl>
<FormControl my={4}>
<FormLabel>Check In Key</FormLabel>
<Select
placeholder="Add Check In Key"
value={checkInKey}
onChange={(e) => {
setcheckInKey(e.target.value);
}}
>
{participants.map((participant) => (
<option key={participant.id} value={participant.checkInKey}>
{participant.checkInKey}
</option>
))}
</Select>
</FormControl>
<FormControl my={4}>
<FormLabel>Phone Number</FormLabel>
<Select
backgroundColor={colorMode === 'light' ? '#04050B12' : '#FBFBFE12'}
placeholder="Select Phone Number"
value={checkInKey}
onChange={(e) => {
setCheckInKey(e.target.value);
}}
>
{participants.map((participant) => (
<option key={participant.id} value={participant.checkInKey}>
{participant.phone}
</option>
))}
</Select>
</FormControl>
<FormControl my={4}>
<FormLabel>Email</FormLabel>
<Select
backgroundColor={colorMode === 'light' ? '#04050B12' : '#FBFBFE12'}
placeholder="Select Email"
value={checkInKey}
onChange={(e) => {
setCheckInKey(e.target.value);
}}
>
{participants.map((participant) => (
<option key={participant.id} value={participant.checkInKey}>
{participant.email}
</option>
))}
</Select>
</FormControl>
<FormControl my={4}>
<FormLabel>Check In Key</FormLabel>
<Select
backgroundColor={colorMode === 'light' ? '#04050B12' : '#FBFBFE12'}
placeholder="Add Check In Key"
value={checkInKey}
onChange={(e) => {
setCheckInKey(e.target.value);
}}
>
{participants.map((participant) => (
<option key={participant.id} value={participant.checkInKey}>
{participant.checkInKey}
</option>
))}
</Select>
</FormControl>
</form>
</Box>
</ModalBody>

<Button type="submit" width="100%" my="4" isLoading={loading} loadingText="Please Wait">
Check In
</Button>
</form>
</DashboardLayout>
<ModalFooter
backgroundColor={colorMode === 'light' ? '#EEEFFF' : '#101116'}
borderBottomRadius="10px"
pt={0}
>
<Box flex={1} display="flex" justifyContent="space-around" gap={3} p={3}>
<Button
width="100%"
isLoading={loading}
loadingText="Please Wait"
onClick={handleSubmit}
backgroundColor="#AFB4E9"
color="black"
_hover={{ backgroundColor: '#D0D6F6 ' }}
>
Check In
</Button>
<Button
backgroundColor={colorMode === 'light' ? '#04050B12' : '#FBFBFE1212'}
mr={3}
onClick={onClose}
width={'100%'}
>
Close
</Button>
</Box>
</ModalFooter>
</ModalContent>
</Modal>
);
}
Loading