-
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.
Implement temporary badge scanner search feature (#380)
- Add **Scan Badge** button to header actions - Load modal with badge scanner to update participants search filter
- Loading branch information
Showing
2 changed files
with
144 additions
and
70 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
45 changes: 45 additions & 0 deletions
45
apps/site/src/app/admin/participants/components/SearchScannerModal.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,45 @@ | ||
import { useCallback } from "react"; | ||
|
||
import Box from "@cloudscape-design/components/box"; | ||
import Button from "@cloudscape-design/components/button"; | ||
import Modal from "@cloudscape-design/components/modal"; | ||
|
||
import BadgeScanner from "@/lib/admin/BadgeScanner"; | ||
|
||
export interface SearchScannerProps { | ||
onDismiss: () => void; | ||
onConfirm: (value: string) => void; | ||
show: boolean; | ||
} | ||
|
||
function SearchScannerModal({ | ||
onDismiss, | ||
onConfirm, | ||
show, | ||
}: SearchScannerProps) { | ||
const onScanSuccess = useCallback( | ||
(decodedText: string) => { | ||
onConfirm(decodedText); | ||
}, | ||
[onConfirm], | ||
); | ||
|
||
return ( | ||
<Modal | ||
onDismiss={onDismiss} | ||
visible={show} | ||
footer={ | ||
<Box float="right"> | ||
<Button variant="link" onClick={onDismiss}> | ||
Cancel | ||
</Button> | ||
</Box> | ||
} | ||
header="Scan badge" | ||
> | ||
{show && <BadgeScanner onSuccess={onScanSuccess} onError={() => null} />} | ||
</Modal> | ||
); | ||
} | ||
|
||
export default SearchScannerModal; |