From 21beebec203ed969dd12367e5752a0dc4e7560c0 Mon Sep 17 00:00:00 2001 From: zuramai Date: Fri, 13 Oct 2023 20:22:01 +0700 Subject: [PATCH] feat(frontend): verify guest --- frontend/pages/verify.vue | 46 ++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/frontend/pages/verify.vue b/frontend/pages/verify.vue index bdff2ca..6ab828d 100644 --- a/frontend/pages/verify.vue +++ b/frontend/pages/verify.vue @@ -6,28 +6,53 @@ useHead({ import {QrcodeStream} from 'vue-qrcode-reader' const detectedUser = ref() const detectedUsers = ref([]) -const onDetect = (a: any) => { - detectedUser.value = { - name: 'Aji', - student: true, - institution: "PT Mencari Cinta Sejati" +const key = ref([]) +const config = useRuntimeConfig(); +const alertClass = ref(null); +const paused = ref(false) +const onDetect = async (a: any) => { + + const response = await useFetch(`${config.public.backendBaseUrl}/scan-tiket`, { + method: "POST", + body: { + code: a[0].rawValue, + key: key.value + } + }); + paused.value = true + + if (response.error.value?.statusCode && [406, 403].includes(response.error.value?.statusCode)) { + alertClass.value = false + } else { + alertClass.value = true + detectedUser.value = { + name: 'Aji', + student: true, + institution: "PT Mencari Cinta Sejati" + } } - // Fetching.. + setTimeout(() => { + paused.value = false + }, 100); } const scanNext = () => { detectedUsers.value.push(detectedUser.value) detectedUser.value = null } + \ No newline at end of file