Skip to content

Commit

Permalink
fix: qrscanner send duplicate request
Browse files Browse the repository at this point in the history
  • Loading branch information
TeeGoood committed Aug 3, 2024
1 parent cdba5cc commit 83d4850
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/components/rpkm/staff/home/qrscanner/QRScanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import FailureModal from './failureModal';
import { createCheckIn } from '@/utils/checkin';
import { CheckIn } from '@/types/checkIn';
import { getCurrentTime } from '@/utils/time';
import dayjs from 'dayjs';

const Scan: React.FC = () => {
const [checkInData, setCheckInData] = useState<CheckIn | null>(null);
Expand Down Expand Up @@ -49,6 +50,7 @@ const Scan: React.FC = () => {
//i don't useState because it not work with qrscanner
const enable = localStorage.getItem('enable') === 'true';
if (!enable) return;
localStorage.setItem('enable', 'false');

const userId = scanRawData.text;
const newCheckInData: CheckIn | null = await createCheckIn(
Expand All @@ -57,10 +59,8 @@ const Scan: React.FC = () => {
event
);

localStorage.setItem('enable', 'false');

if (newCheckInData) {
/* if (newCheckInData.checkIn.isDuplicate) {
if (newCheckInData.checkIn.isDuplicate) {
const date = dayjs(newCheckInData.checkIn.timestamp);
setStatus('error');
setError(
Expand All @@ -73,7 +73,7 @@ const Scan: React.FC = () => {
setErrorTopic('Already taken!');
setTaken(true);
return;
} */
}

setCheckInData(newCheckInData);
setStatus('success');
Expand Down

0 comments on commit 83d4850

Please sign in to comment.