-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* pnpm * feat(web-admin):add slow-scan feature
- Loading branch information
Showing
2 changed files
with
120 additions
and
54 deletions.
There are no files selected for viewing
103 changes: 103 additions & 0 deletions
103
...rganizations/[orgId]/events/[eventId]/participants/check-in/new-in/scanner-slow/index.jsx
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,103 @@ | ||
import { useState, useEffect } from 'react'; | ||
import { useRouter } from 'next/router'; | ||
|
||
import { Button, FormControl, FormLabel, Select, Flex } from '@chakra-ui/react'; | ||
|
||
import DashboardLayout from '@/layouts/DashboardLayout'; | ||
import Scanner from '@/components/Scanner'; | ||
|
||
import { useAlert } from '@/hooks/useAlert'; | ||
import { useFetch } from '@/hooks/useFetch'; | ||
|
||
export default function CheckInParticipantWithScanner() { | ||
const { loading, post, get } = useFetch(); | ||
const showAlert = useAlert(); | ||
|
||
const router = useRouter(); | ||
const { orgId, eventId } = router.query; | ||
|
||
const [participantId, setParticipantId] = useState(null); | ||
const [participantDetails, setParticipantDetails] = useState(null); | ||
|
||
useEffect(() => { | ||
if (participantId) { | ||
const fetchParticipantDetails = async () => { | ||
const { data, status } = await get( | ||
`/core/organizations/${orgId}/events/${eventId}/participants/${participantId}`, | ||
); | ||
if (status === 200) { | ||
setParticipantDetails(data.participant); | ||
console.log(data.participant); | ||
} else { | ||
showAlert({ | ||
title: 'Error', | ||
description: data.error, | ||
status: 'error', | ||
}); | ||
} | ||
}; | ||
fetchParticipantDetails(); | ||
} | ||
}, [orgId, eventId, participantId]); | ||
|
||
const handleCheckIn = async () => { | ||
const { data, status } = await post( | ||
`/core/organizations/${orgId}/events/${eventId}/participants/check-in/${participantId}`, | ||
{}, | ||
{ | ||
checkedInAt: new Date().toISOString(), | ||
}, | ||
); | ||
if (status === 200) { | ||
showAlert({ | ||
title: 'Success', | ||
description: data.message, | ||
status: 'success', | ||
}); | ||
setParticipantId(null); | ||
setParticipantDetails(null); | ||
} else { | ||
showAlert({ | ||
title: 'Error', | ||
description: data.error, | ||
status: 'error', | ||
}); | ||
} | ||
}; | ||
|
||
return ( | ||
<DashboardLayout | ||
pageTitle="Check In Participant" | ||
previousPage={`/organizations/${orgId}/events/${eventId}/participants`} | ||
headerButton={ | ||
<> | ||
<Flex flexDirection="column" gap={4}> | ||
<Button | ||
onClick={() => { | ||
router.push( | ||
`/organizations/${orgId}/events/${eventId}/participants/check-in/new-in/scanner`, | ||
); | ||
}} | ||
isLoading={loading} | ||
> | ||
Quick Scan | ||
</Button> | ||
</Flex> | ||
</> | ||
} | ||
> | ||
<Flex height="100%" width="100%" flexDirection="column" alignItems="center"> | ||
{participantDetails && ( | ||
<div> | ||
<p>Name: {participantDetails.firstName + ' ' + participantDetails.lastName}</p> | ||
<p>Email: {participantDetails.email}</p> | ||
<Button onClick={handleCheckIn} isLoading={loading}> | ||
Check In | ||
</Button> | ||
</div> | ||
)} | ||
<Scanner setResult={setParticipantId} /> | ||
</Flex> | ||
</DashboardLayout> | ||
); | ||
} |
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