Skip to content

Commit

Permalink
Simplify scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniils Petrovs committed Jun 23, 2024
1 parent f17b6c3 commit 4eff95f
Showing 1 changed file with 4 additions and 30 deletions.
34 changes: 4 additions & 30 deletions src/routes/scanner/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
import { tokenHash } from '../../crypto';
import { TOAST_TYPE, SCANNER_STATE, type ScannerState } from '../../custom';
import { Icon } from '@steeze-ui/svelte-icon';
import { Ticket, QrCode, StopCircle } from '@steeze-ui/heroicons';
import { getCollectedCount, getExpectedStampHashes, saveStamp } from '$lib/stores/stamps';
import { setToast } from '$lib/stores/toasts';
import { minStampCountRequired } from '../../const';
import { goto } from '$app/navigation';
let state: ScannerState = 'STOPPED';
Expand Down Expand Up @@ -44,7 +43,6 @@
type: TOAST_TYPE.ERROR,
message: 'Invalid QR code!'
});
return;
}
transitionState();
Expand Down Expand Up @@ -73,6 +71,7 @@
message: 'Invalid Stamp!'
});
}
goto('/');
}
function parseTokenFromScan(data: string): string {
Expand All @@ -95,6 +94,8 @@
videoElem.setAttribute('playsinline', 'true');
videoElem.setAttribute('autoplay', 'true');
videoElem.setAttribute('muted', 'true');
transitionState();
});
onDestroy(() => {
Expand All @@ -107,23 +108,6 @@
<h1 class="text-center font-geologica text-4xl font-bold text-primary">Scanner</h1>
<p class="px-2 text-center text-xl">Press Scan, and scan the QR code of the stamp!</p>

<div class="flex flex-col justify-center space-y-4">
<button
on:click={transitionState}
class="text btn mx-auto w-10/12 max-w-screen-lg gap-2 rounded-full text-white"
class:btn-primary={state === SCANNER_STATE.STOPPED}
class:btn-error={state === SCANNER_STATE.SCANNING}
>
<Icon
src={state === SCANNER_STATE.SCANNING ? StopCircle : QrCode}
theme="solid"
class="color-gray-900"
size="32px"
/>
{state === SCANNER_STATE.SCANNING ? 'Stop' : 'Scan'}</button
>
</div>

<div
id="scanner-preview-area"
class="h-96"
Expand All @@ -132,14 +116,4 @@
<!-- svelte-ignore a11y-media-has-caption -->
<video />
</div>

<div class="flex flex-col justify-center space-y-4">
<a
class="text btn-secondary btn mx-auto mt-2 w-10/12 max-w-screen-lg gap-2 rounded-full text-white"
href="/"
>
<Icon src={Ticket} theme="solid" class="color-gray-900" size="28px" />
View collected stamps</a
>
</div>
</div>

0 comments on commit 4eff95f

Please sign in to comment.