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