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

Graphical QR Code Scan Response Improvements #269

Merged
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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
position: absolute;
animation: colorfulBorder 10s infinite;
border-radius: 10px;
outline: solid 50vmax #472e7840;
outline: solid 50vmax rgb(71 46 120 / 50%);
transition: outline-color .2s ease-out;
min-width: 200px;
min-height: 200px;

Expand All @@ -72,6 +73,18 @@
}
}

.scannerOverlay.success {
outline: solid 50vmax rgb(80 148 80 / 75%);
}

.scannerOverlay.failure {
outline: solid 50vmax rgb(193 72 72 / 75%);
}

.scannerOverlay.checkingIn {
outline: solid 50vmax rgb(172 158 85 / 60%);
}

video {
width: 100vw !important;
height: 100vh !important;
Expand Down
32 changes: 28 additions & 4 deletions frontend/src/components/common/AttendeeCheckInTable/QrScanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {showError} from "../../../utilites/notifications.tsx";
import {t, Trans} from "@lingui/macro";

interface QRScannerComponentProps {
onCheckIn: (attendeePublicId: string, onRequestComplete: () => void, onFailure: () => void) => void;
onCheckIn: (attendeePublicId: string, onRequestComplete: (didSucceed: boolean) => void, onFailure: () => void) => void;
onClose: () => void;
}

Expand All @@ -25,7 +25,9 @@ export const QRScannerComponent = (props: QRScannerComponentProps) => {
const latestProcessedAttendeeIdsRef = useRef<string[]>([]);

const [currentAttendeeId, setCurrentAttendeeId] = useState<string | null>(null);
const [debouncedAttendeeId] = useDebouncedValue(currentAttendeeId, 500);
const [debouncedAttendeeId] = useDebouncedValue(currentAttendeeId, 1000);
const [isScanFailed, setIsScanFailed] = useState(false);
const [isScanSucceeded, setIsScanSucceeded] = useState(false);

useEffect(() => {
latestProcessedAttendeeIdsRef.current = processedAttendeeIds;
Expand Down Expand Up @@ -54,17 +56,39 @@ export const QRScannerComponent = (props: QRScannerComponentProps) => {
const latestProcessedAttendeeIds = latestProcessedAttendeeIdsRef.current;
const alreadyScanned = latestProcessedAttendeeIds.includes(debouncedAttendeeId);

if (isScanSucceeded || isScanFailed) {
return;
}

if (alreadyScanned) {
showError(t`You already scanned this ticket`);

setIsScanFailed(true);
setInterval(function() {
setIsScanFailed(false);
}, 500);

return;
}

if (!isCheckingIn && !alreadyScanned) {
setIsCheckingIn(true);
props.onCheckIn(debouncedAttendeeId, () => {
props.onCheckIn(debouncedAttendeeId, (didSucceed) => {
setIsCheckingIn(false);
setProcessedAttendeeIds(prevIds => [...prevIds, debouncedAttendeeId]);
setCurrentAttendeeId(null);

if (didSucceed) {
setIsScanSucceeded(true);
setInterval(function() {
setIsScanSucceeded(false);
}, 500);
} else {
setIsScanFailed(true);
setInterval(function() {
setIsScanFailed(false);
}, 500);
}
}, () => {
setIsCheckingIn(false);
setCurrentAttendeeId(null);
Expand Down Expand Up @@ -178,7 +202,7 @@ export const QRScannerComponent = (props: QRScannerComponentProps) => {
</Menu.Dropdown>
</Menu>
</Button>
<div className={classes.scannerOverlay}/>
<div className={`${classes.scannerOverlay} ${isScanSucceeded ? classes.success : ""} ${isScanFailed ? classes.failure : ""} ${isCheckingIn ? classes.checkingIn : ""}`}/>
</div>
);
};
204 changes: 0 additions & 204 deletions frontend/src/components/common/AttendeeCheckInTable/index.tsx

This file was deleted.

5 changes: 2 additions & 3 deletions frontend/src/components/layouts/CheckIn/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ const CheckIn = () => {
)
}

const handleQrCheckIn = (attendeePublicId: string, onRequestComplete: () => void, onFailure: () => void) => {
const handleQrCheckIn = (attendeePublicId: string, onRequestComplete: (didSucceed: boolean) => void, onFailure: () => void) => {
checkInMutation.mutate({
checkInListShortId: checkInListShortId,
attendeePublicId: attendeePublicId,
}, {
onSuccess: ({errors}) => {
if (onRequestComplete) {
onRequestComplete()
onRequestComplete(!(errors && errors[attendeePublicId]))
}
// Show error if there is an error for this specific attendee
// It's a bulk endpoint, so even if there's an error it returns a 200
Expand Down Expand Up @@ -211,7 +211,6 @@ const CheckIn = () => {
/>)
}


if (checkInList?.is_expired) {
return (
<NoResultsSplash
Expand Down
Loading