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

add comments about qr code scanner #418

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
8 changes: 7 additions & 1 deletion src/pages/admin/Event/EventStats/EventStatsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,7 @@ const QrCheckIn = (props) => {
// when wanting to re-scan (requires a manual reset)
// if (data.data !== qrCode.data) setQrCode(data);

// sets the Qrcode to the data prop from the QRReader component
setQrCode(data);
};

Expand All @@ -813,8 +814,9 @@ const QrCheckIn = (props) => {
return /(.+)@(.+){2,}\.(.+){2,}/.test(email);
}

// checks if the QR code is valid whenever the QR code is changed
// checks if the QR code is valid whenever the QR code is changed (qr code is a dependancy of this useEffect)
useEffect(() => {
// function that sets the user's registration status to checked in and resets ths QRcode reader after 10s
const checkInUser = (id, fname) => {
const body = {
eventID: props.event.id,
Expand Down Expand Up @@ -857,8 +859,10 @@ const QrCheckIn = (props) => {
return;
}

// retrieves user that matches the userID from the QrCode
const user = props.rows?.filter((row) => row.id === userID)[0];

// if user doesn't exist then fail QR scan
if (!user) {
cycleQrScanStage(QR_SCAN_STAGE.FAILED, 6000);
setError("Person is not registered for this event.");
Expand Down Expand Up @@ -896,6 +900,7 @@ const QrCheckIn = (props) => {
return;
}

// if non of the previous checks failed, checkin user and reset qr scanner
checkInUser(userID, userFName);

// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down Expand Up @@ -942,6 +947,7 @@ const QrCheckIn = (props) => {
alignItems: "center"
}}
>
{/* Uses public react package qr-reader */}
<QrReader
style={styles.qrCodeVideo}
onScan={handleScanQR}
Expand Down