From 0771e6208d02eb2584e2af466b99611822c9052a Mon Sep 17 00:00:00 2001 From: Sak1012 <1012srivatsavas@gmail.com> Date: Thu, 27 Jun 2024 00:27:47 +0530 Subject: [PATCH 01/23] Add Device Registration button and route --- src/components/Common/QRCamera.vue | 3 +++ src/components/LoginForm.vue | 14 ++++++++++++++ src/components/Registration/Device/Device.vue | 15 +++++++++++++++ src/router/index.js | 6 ++++++ 4 files changed, 38 insertions(+) create mode 100644 src/components/Registration/Device/Device.vue diff --git a/src/components/Common/QRCamera.vue b/src/components/Common/QRCamera.vue index ddc1ea6..0b446b8 100644 --- a/src/components/Common/QRCamera.vue +++ b/src/components/Common/QRCamera.vue @@ -37,6 +37,9 @@ async function processQR() { if (props.qrType === 'checkIn') { await processCheckInStore.checkInAttendeeScannerToRoom(stationId, scannerType) } + if (props.qrType === 'device') { + //device registration + } cameraStore.paused = false } diff --git a/src/components/LoginForm.vue b/src/components/LoginForm.vue index 2a30444..f4aa105 100644 --- a/src/components/LoginForm.vue +++ b/src/components/LoginForm.vue @@ -42,6 +42,12 @@ async function submitLogin() { loadingStore.contentLoaded() } +function registerDevice() { + router.push({ + name: 'device' + }) +} + onMounted(() => { if (authStore.isAuthenticated) { router.push({ @@ -108,6 +114,14 @@ onMounted(() => { >Click here to reset password

+ + diff --git a/src/components/Registration/Device/Device.vue b/src/components/Registration/Device/Device.vue new file mode 100644 index 0000000..03f2ef8 --- /dev/null +++ b/src/components/Registration/Device/Device.vue @@ -0,0 +1,15 @@ + + + diff --git a/src/router/index.js b/src/router/index.js index b3ac7d6..0c0e1d8 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,6 +1,7 @@ import AuthTemplate from '@/AuthTemplate.vue' import CheckInCamera from '@/components/CheckIn/CheckInCamera.vue' import CheckInStats from '@/components/CheckIn/CheckInStats.vue' +import Device from '@/components/Registration/Device/Device.vue' import RegistrationKiosk from '@/components/Registration/Kiosk/KioskOverview.vue' import RegistrationStats from '@/components/Registration/Station/RegistrationStats.vue' import RegistrationStation from '@/components/Registration/Station/StationOverview.vue' @@ -20,6 +21,11 @@ const router = createRouter({ name: 'userAuth', component: UserAuth }, + { + path: '/device', + name: 'device', + component: Device + }, { path: '/panel', name: 'auth', From 077215be3269eb010a50a1fd920059e532fc2e92 Mon Sep 17 00:00:00 2001 From: Sak1012 <1012srivatsavas@gmail.com> Date: Tue, 2 Jul 2024 10:06:43 +0530 Subject: [PATCH 02/23] Added Select Server option in LoginForm --- src/components/LoginForm.vue | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/components/LoginForm.vue b/src/components/LoginForm.vue index f4aa105..00ce47a 100644 --- a/src/components/LoginForm.vue +++ b/src/components/LoginForm.vue @@ -13,12 +13,20 @@ const userStore = useUserStore() const email = ref('') const password = ref('') +const server = ref('') const showError = ref(false) +const showServerError = ref(false) // router const router = useRouter() async function submitLogin() { + console.log(server.value) + if (server.value === '' || server.value === 'Select a Server') { + showServerError.value = true + return + } + showServerError.value = false loadingStore.contentLoading() showError.value = false @@ -43,6 +51,12 @@ async function submitLogin() { } function registerDevice() { + console.log(server.value) + if (server.value === '' || server.value === 'Select a Server') { + showServerError.value = true + return + } + showServerError.value = false router.push({ name: 'device' }) @@ -94,6 +108,15 @@ onMounted(() => { +
+ + +
+
{
-

+

Forgot password? {{ ' ' }} { @click="registerDevice" > +

+

Please select a server first

+
From 4c8f4da594b24710c50dd5a8202719e493ca118b Mon Sep 17 00:00:00 2001 From: Sak1012 <1012srivatsavas@gmail.com> Date: Mon, 8 Jul 2024 16:26:20 +0530 Subject: [PATCH 03/23] Added basic QR handling logic --- src/components/Common/QRCamera.vue | 4 +- src/stores/processDevice.js | 90 ++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 src/stores/processDevice.js diff --git a/src/components/Common/QRCamera.vue b/src/components/Common/QRCamera.vue index 0b446b8..e4d58a9 100644 --- a/src/components/Common/QRCamera.vue +++ b/src/components/Common/QRCamera.vue @@ -4,6 +4,7 @@ import QRCamera from '@/components/Utilities/QRCamera.vue' import { useCameraStore } from '@/stores/camera' import { useProcessRegistrationStore } from '@/stores/processRegistration' import { useProcessCheckInStore } from '@/stores/processCheckIn' +import { useProcessDeviceStore } from '@/stores/processDevice' const props = defineProps({ qrType: { @@ -23,6 +24,7 @@ const props = defineProps({ const cameraStore = useCameraStore() const processRegistrationStore = useProcessRegistrationStore() const processCheckInStore = useProcessCheckInStore() +const processDeviceStore = useProcessDeviceStore() const route = useRoute() const stationId = route.params.stationId @@ -38,7 +40,7 @@ async function processQR() { await processCheckInStore.checkInAttendeeScannerToRoom(stationId, scannerType) } if (props.qrType === 'device') { - //device registration + await processDeviceStore.authDevice(cameraStore.qrCodeValue) } cameraStore.paused = false } diff --git a/src/stores/processDevice.js b/src/stores/processDevice.js new file mode 100644 index 0000000..f2ea544 --- /dev/null +++ b/src/stores/processDevice.js @@ -0,0 +1,90 @@ +import { useCameraStore } from '@/stores/camera' +import { defineStore } from 'pinia' +import { computed, ref } from 'vue' + +export const useProcessDeviceStore = defineStore('processDevice', () => { + const cameraStore = useCameraStore() + + const message = ref('') + const showSuccess = ref(false) + const showError = ref(false) + + function $reset() { + message.value = '' + showSuccess.value = false + showError.value = false + } + + const response = computed(() => { + let classType = '' + if (showSuccess.value) { + classType = 'text-success' + } + if (showError.value) { + classType = 'text-danger' + } + return { + message: message.value, + class: classType + } + }) + + function showErrorMsg() { + showSuccess.value = false + showError.value = true + } + + function showSuccessMsg() { + showSuccess.value = true + showError.value = false + } + + async function authDevice(val) { + try { + const qrData = JSON.parse(val) + console.log(qrData) + if (qrData.handshake_version > 1) { + message.value = 'Unsupported handshake version' + showErrorMsg() + return + } else { + console.log('Handshake version is 1') + } + + const payload = { + token: qrData.token, + hardware_brand: 'Test', + hardware_model: 'test', + os_name: 'Test', + os_version: '2.3.6', + software_brand: 'check-in', + software_version: 'x.x' + } + let url = qrData.url + if (url.includes('localhost')) { + url = `${url}:8000` // Add your desired port number here + } + console.log(url) + const api = mande(url, { headers: { 'Content-Type': 'application/json' } }) + const response = await api.post('/api/v1/device/initialize', payload) + console.log(response) + if (response) { + const data = response + console.log(data.api_token) + showSuccessMsg() + } else { + console.log('Something happend') + showErrorMsg() + } + } catch (error) { + console.log('Error in catch') + showErrorMsg() + } + } + + return { + response, + $reset, + authDevice + } +}) From 57f721b4819cf430edb621b94b1a540accf178a4 Mon Sep 17 00:00:00 2001 From: Sak1012 <1012srivatsavas@gmail.com> Date: Sat, 20 Jul 2024 06:02:50 +0530 Subject: [PATCH 04/23] Device auth and event list selection --- hs | 1 + src/components/Eventyay/EventyayEvents.vue | 56 +++++++++++++++++++ src/components/Registration/Device/Device.vue | 4 ++ src/router/index.js | 6 ++ src/stores/eventyayEvent.js | 33 +++++++++++ src/stores/processDevice.js | 10 +++- 6 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 hs create mode 100644 src/components/Eventyay/EventyayEvents.vue create mode 100644 src/stores/eventyayEvent.js diff --git a/hs b/hs new file mode 100644 index 0000000..1f2d2a0 --- /dev/null +++ b/hs @@ -0,0 +1 @@ +sak:3670 \ No newline at end of file diff --git a/src/components/Eventyay/EventyayEvents.vue b/src/components/Eventyay/EventyayEvents.vue new file mode 100644 index 0000000..4bdb844 --- /dev/null +++ b/src/components/Eventyay/EventyayEvents.vue @@ -0,0 +1,56 @@ + + diff --git a/src/components/Registration/Device/Device.vue b/src/components/Registration/Device/Device.vue index 03f2ef8..b7a88a5 100644 --- a/src/components/Registration/Device/Device.vue +++ b/src/components/Registration/Device/Device.vue @@ -11,5 +11,9 @@ loadingStore.contentLoaded() class="-mt-16 grid h-screen w-full grid-cols-1 place-items-center items-center justify-center align-middle" > +
+ + +
diff --git a/src/router/index.js b/src/router/index.js index 0c0e1d8..e12b1df 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,6 +1,7 @@ import AuthTemplate from '@/AuthTemplate.vue' import CheckInCamera from '@/components/CheckIn/CheckInCamera.vue' import CheckInStats from '@/components/CheckIn/CheckInStats.vue' +import EventyayEvents from '@/components/Eventyay/EventyayEvents.vue' import Device from '@/components/Registration/Device/Device.vue' import RegistrationKiosk from '@/components/Registration/Kiosk/KioskOverview.vue' import RegistrationStats from '@/components/Registration/Station/RegistrationStats.vue' @@ -26,6 +27,11 @@ const router = createRouter({ name: 'device', component: Device }, + { + path: '/eventyayevents', + name: 'eventyayevents', + component: EventyayEvents + }, { path: '/panel', name: 'auth', diff --git a/src/stores/eventyayEvent.js b/src/stores/eventyayEvent.js new file mode 100644 index 0000000..6b3b9d3 --- /dev/null +++ b/src/stores/eventyayEvent.js @@ -0,0 +1,33 @@ +import { mande } from 'mande' +import { defineStore } from 'pinia' +import { ref } from 'vue' + +export const useEventyayEventStore = defineStore('eventyayEvent', () => { + const events = ref([]) + const loading = ref(false) + const error = ref(null) + + async function fetchEvents(url, apiToken, organizer) { + loading.value = true + error.value = null + + try { + const api = mande(url, { headers: { Authorization: `Device ${apiToken}` } }) + console.log(`/api/v1/organizers/${organizer}/events/`) + const response = await api.get(`/api/v1/organizers/${organizer}/events/`) + console.log('Hello', response) + events.value = response.results + } catch (err) { + error.value = err.message + } finally { + loading.value = false + } + } + + return { + events, + loading, + error, + fetchEvents + } +}) diff --git a/src/stores/processDevice.js b/src/stores/processDevice.js index f2ea544..6fbba7c 100644 --- a/src/stores/processDevice.js +++ b/src/stores/processDevice.js @@ -1,10 +1,11 @@ import { useCameraStore } from '@/stores/camera' +import { mande } from 'mande' import { defineStore } from 'pinia' import { computed, ref } from 'vue' - +import { useRouter } from 'vue-router' export const useProcessDeviceStore = defineStore('processDevice', () => { const cameraStore = useCameraStore() - + const router = useRouter() const message = ref('') const showSuccess = ref(false) const showError = ref(false) @@ -71,12 +72,17 @@ export const useProcessDeviceStore = defineStore('processDevice', () => { if (response) { const data = response console.log(data.api_token) + localStorage.setItem('api_token', data.api_token) + localStorage.setItem('organizer', data.organizer) + localStorage.setItem('url', url) + router.push({ name: 'eventyayevents' }) showSuccessMsg() } else { console.log('Something happend') showErrorMsg() } } catch (error) { + console.log(error) console.log('Error in catch') showErrorMsg() } From cbc8b3917d960652900c266163e9cb0ea151d8c2 Mon Sep 17 00:00:00 2001 From: Sak1012 <1012srivatsavas@gmail.com> Date: Wed, 24 Jul 2024 11:01:26 +0530 Subject: [PATCH 05/23] Added Field to enter Device Auth Token manually --- src/components/Eventyay/EventyayEvents.vue | 8 +++++++- src/components/Registration/Device/Device.vue | 19 ++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/components/Eventyay/EventyayEvents.vue b/src/components/Eventyay/EventyayEvents.vue index 4bdb844..2681725 100644 --- a/src/components/Eventyay/EventyayEvents.vue +++ b/src/components/Eventyay/EventyayEvents.vue @@ -51,6 +51,12 @@ const submitForm = () => { /> -
No events available
+
No events available + +
diff --git a/src/components/Registration/Device/Device.vue b/src/components/Registration/Device/Device.vue index b7a88a5..8ffa1e6 100644 --- a/src/components/Registration/Device/Device.vue +++ b/src/components/Registration/Device/Device.vue @@ -1,9 +1,18 @@ From 3405c893bb654b1ad47901467c5a88d753c1abc3 Mon Sep 17 00:00:00 2001 From: Sak1012 <1012srivatsavas@gmail.com> Date: Mon, 29 Jul 2024 16:15:03 +0530 Subject: [PATCH 06/23] Added Ticket QR scanning Page --- .../Eventyay/EventyayEventCheckIn.vue | 14 +++++++++++++ src/components/Eventyay/EventyayEvents.vue | 20 +++++++++++-------- src/router/index.js | 6 ++++++ src/stores/api.js | 2 +- 4 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 src/components/Eventyay/EventyayEventCheckIn.vue diff --git a/src/components/Eventyay/EventyayEventCheckIn.vue b/src/components/Eventyay/EventyayEventCheckIn.vue new file mode 100644 index 0000000..4b16289 --- /dev/null +++ b/src/components/Eventyay/EventyayEventCheckIn.vue @@ -0,0 +1,14 @@ + + + diff --git a/src/components/Eventyay/EventyayEvents.vue b/src/components/Eventyay/EventyayEvents.vue index 2681725..b2c9d0d 100644 --- a/src/components/Eventyay/EventyayEvents.vue +++ b/src/components/Eventyay/EventyayEvents.vue @@ -3,6 +3,7 @@ import { useLoadingStore } from '@/stores/loading' import { ref, onMounted, watchEffect } from 'vue' import { useEventyayEventStore } from '@/stores/eventyayEvent' import StandardButton from '@/components/Common/StandardButton.vue' +import { useRouter } from 'vue-router' const loadingStore = useLoadingStore() const apiToken = ref('') @@ -10,7 +11,7 @@ const organiser = ref('') const url = ref('') const eventyayEventStore = useEventyayEventStore() const selectedEvent = ref(null) - +const router = useRouter() const { events, loading, error, fetchEvents } = eventyayEventStore watchEffect(() => { @@ -26,6 +27,8 @@ watchEffect(() => { const submitForm = () => { if (selectedEvent.value) { + localStorage.setItem('selectedEvent', selectedEvent.value) + router.push({ name: 'eventyaycheckin' }) console.log('Selected event:', selectedEvent.value) } else { console.error('Please select an event.') @@ -51,12 +54,13 @@ const submitForm = () => { /> -
No events available - -
+
+ No events available + +
diff --git a/src/router/index.js b/src/router/index.js index e12b1df..5e777f1 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,6 +1,7 @@ import AuthTemplate from '@/AuthTemplate.vue' import CheckInCamera from '@/components/CheckIn/CheckInCamera.vue' import CheckInStats from '@/components/CheckIn/CheckInStats.vue' +import EventyayEventCheckIn from '@/components/Eventyay/EventyayEventCheckIn.vue' import EventyayEvents from '@/components/Eventyay/EventyayEvents.vue' import Device from '@/components/Registration/Device/Device.vue' import RegistrationKiosk from '@/components/Registration/Kiosk/KioskOverview.vue' @@ -32,6 +33,11 @@ const router = createRouter({ name: 'eventyayevents', component: EventyayEvents }, + { + path: '/eventyaycheckin', + name: 'eventyaycheckin', + component: EventyayEventCheckIn + }, { path: '/panel', name: 'auth', diff --git a/src/stores/api.js b/src/stores/api.js index 5b30146..e48c933 100644 --- a/src/stores/api.js +++ b/src/stores/api.js @@ -6,7 +6,7 @@ export const useApiStore = defineStore('api', () => { import.meta.env.MODE === 'production' ? import.meta.env.VITE_PROD_API_URL : import.meta.env.VITE_TEST_API_URL - + let instance = mande(apiUrl) function setToken() { From 4f382e0d17416f9641aa0fc0cd3df64340dfddae Mon Sep 17 00:00:00 2001 From: Sak1012 <1012srivatsavas@gmail.com> Date: Tue, 6 Aug 2024 09:22:12 +0530 Subject: [PATCH 07/23] Fixes --- src/components/Common/QRCamera.vue | 5 +++++ src/components/Eventyay/EventyayEventCheckIn.vue | 2 +- src/components/LoginForm.vue | 15 +++++++++++++-- src/stores/eventyayEvent.js | 3 ++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/components/Common/QRCamera.vue b/src/components/Common/QRCamera.vue index e4d58a9..38a4733 100644 --- a/src/components/Common/QRCamera.vue +++ b/src/components/Common/QRCamera.vue @@ -31,6 +31,7 @@ const stationId = route.params.stationId const scannerType = route.params.scannerType async function processQR() { + console.log('Processing QR') cameraStore.paused = true if (props.qrType === 'registration') { await processRegistrationStore.registerAttendeeScanner(stationId) @@ -42,6 +43,10 @@ async function processQR() { if (props.qrType === 'device') { await processDeviceStore.authDevice(cameraStore.qrCodeValue) } + if (props.qrType === 'eventyaycheckin') { + console.log(cameraStore.qrCodeValue) + console.log('Check-in') + } cameraStore.paused = false } diff --git a/src/components/Eventyay/EventyayEventCheckIn.vue b/src/components/Eventyay/EventyayEventCheckIn.vue index 4b16289..33bbf30 100644 --- a/src/components/Eventyay/EventyayEventCheckIn.vue +++ b/src/components/Eventyay/EventyayEventCheckIn.vue @@ -9,6 +9,6 @@ loadingStore.contentLoaded()
- +
diff --git a/src/components/LoginForm.vue b/src/components/LoginForm.vue index 00ce47a..db3890a 100644 --- a/src/components/LoginForm.vue +++ b/src/components/LoginForm.vue @@ -16,7 +16,7 @@ const password = ref('') const server = ref('') const showError = ref(false) const showServerError = ref(false) - +const errmessage = ref('') // router const router = useRouter() @@ -26,6 +26,11 @@ async function submitLogin() { showServerError.value = true return } + if (server.value === 'Eventyay') { + errmessage.value = 'Please Register a Device for Eventyay' + showServerError.value = true + return + } showServerError.value = false loadingStore.contentLoading() showError.value = false @@ -53,6 +58,12 @@ async function submitLogin() { function registerDevice() { console.log(server.value) if (server.value === '' || server.value === 'Select a Server') { + errmessage.value = 'Please select a server first' + showServerError.value = true + return + } + if (server.value === 'Open-Event') { + errmessage.value = 'Please Login with credentials for Open-Event' showServerError.value = true return } @@ -146,7 +157,7 @@ onMounted(() => { >
-

Please select a server first

+

{{ errmessage }}

diff --git a/src/stores/eventyayEvent.js b/src/stores/eventyayEvent.js index 6b3b9d3..8d180a1 100644 --- a/src/stores/eventyayEvent.js +++ b/src/stores/eventyayEvent.js @@ -8,7 +8,7 @@ export const useEventyayEventStore = defineStore('eventyayEvent', () => { const error = ref(null) async function fetchEvents(url, apiToken, organizer) { - loading.value = true + loading.value = false error.value = null try { @@ -17,6 +17,7 @@ export const useEventyayEventStore = defineStore('eventyayEvent', () => { const response = await api.get(`/api/v1/organizers/${organizer}/events/`) console.log('Hello', response) events.value = response.results + loading.value = true } catch (err) { error.value = err.message } finally { From 67ee3ddf92ee2d949d1c3216b89dcb8a876f0660 Mon Sep 17 00:00:00 2001 From: Sak1012 <1012srivatsavas@gmail.com> Date: Sun, 18 Aug 2024 19:10:01 +0530 Subject: [PATCH 08/23] Add Eventyay route Selection Page This also has minor fixes and removal of some `console.log()` statements and added env variable for local host testing --- .env | 3 ++- hs | 1 - src/components/Common/QRCamera.vue | 1 - .../Eventyay/EventyayEventSelection.vue | 27 +++++++++++++++++++ src/components/Eventyay/EventyayEvents.vue | 1 - src/components/LoginForm.vue | 4 +-- src/components/Registration/Device/Device.vue | 13 +++++++-- src/router/index.js | 6 +++++ src/stores/attendees.js | 5 +++- src/stores/eventyayEvent.js | 5 +--- src/stores/processDevice.js | 18 +++++-------- 11 files changed, 59 insertions(+), 25 deletions(-) delete mode 100644 hs create mode 100644 src/components/Eventyay/EventyayEventSelection.vue diff --git a/.env b/.env index b6fcdf6..c5a6df4 100644 --- a/.env +++ b/.env @@ -1,2 +1,3 @@ VITE_TEST_API_URL=https://test-api.eventyay.com/v1 -VITE_PROD_API_URL=https://api.eventyay.com/v1 \ No newline at end of file +VITE_PROD_API_URL=https://api.eventyay.com/v1 +VITE_LOCAL_PORT=8000 diff --git a/hs b/hs deleted file mode 100644 index 1f2d2a0..0000000 --- a/hs +++ /dev/null @@ -1 +0,0 @@ -sak:3670 \ No newline at end of file diff --git a/src/components/Common/QRCamera.vue b/src/components/Common/QRCamera.vue index 38a4733..4753d12 100644 --- a/src/components/Common/QRCamera.vue +++ b/src/components/Common/QRCamera.vue @@ -31,7 +31,6 @@ const stationId = route.params.stationId const scannerType = route.params.scannerType async function processQR() { - console.log('Processing QR') cameraStore.paused = true if (props.qrType === 'registration') { await processRegistrationStore.registerAttendeeScanner(stationId) diff --git a/src/components/Eventyay/EventyayEventSelection.vue b/src/components/Eventyay/EventyayEventSelection.vue new file mode 100644 index 0000000..b21fd2c --- /dev/null +++ b/src/components/Eventyay/EventyayEventSelection.vue @@ -0,0 +1,27 @@ + + + diff --git a/src/components/Eventyay/EventyayEvents.vue b/src/components/Eventyay/EventyayEvents.vue index b2c9d0d..28ec130 100644 --- a/src/components/Eventyay/EventyayEvents.vue +++ b/src/components/Eventyay/EventyayEvents.vue @@ -29,7 +29,6 @@ const submitForm = () => { if (selectedEvent.value) { localStorage.setItem('selectedEvent', selectedEvent.value) router.push({ name: 'eventyaycheckin' }) - console.log('Selected event:', selectedEvent.value) } else { console.error('Please select an event.') } diff --git a/src/components/LoginForm.vue b/src/components/LoginForm.vue index db3890a..64195c5 100644 --- a/src/components/LoginForm.vue +++ b/src/components/LoginForm.vue @@ -17,12 +17,12 @@ const server = ref('') const showError = ref(false) const showServerError = ref(false) const errmessage = ref('') +const DEFAULT_SERVER_VALUE = 'Select a Server' // router const router = useRouter() async function submitLogin() { - console.log(server.value) - if (server.value === '' || server.value === 'Select a Server') { + if (server.value === '' || server.value === DEFAULT_SERVER_VALUE) { showServerError.value = true return } diff --git a/src/components/Registration/Device/Device.vue b/src/components/Registration/Device/Device.vue index 8ffa1e6..953ae7c 100644 --- a/src/components/Registration/Device/Device.vue +++ b/src/components/Registration/Device/Device.vue @@ -3,15 +3,21 @@ import QRCamera from '@/components/Common/QRCamera.vue' import { useLoadingStore } from '@/stores/loading' import StandardButton from '@/components/Common/StandardButton.vue' import { useProcessDeviceStore } from '@/stores/processDevice' +import { ref } from 'vue' const loadingStore = useLoadingStore() loadingStore.contentLoaded() const processDeviceStore = useProcessDeviceStore() - +const showError = ref(false) async function registerDevice() { const auth_token = document.getElementById('auth_token').value const payload = { handshake_version: 1, url: 'http://localhost', token: auth_token } - await processDeviceStore.authDevice(JSON.stringify(payload)) + try { + const resp = await processDeviceStore.authDevice(JSON.stringify(payload)) + } catch (error) { + showError.value = true + console.error('Error registering device:', error) + } } @@ -20,6 +26,9 @@ async function registerDevice() { class="-mt-16 grid h-screen w-full grid-cols-1 place-items-center items-center justify-center align-middle" > +
+

Oops! something went wrong

+
{ route += `email=${value}` } try { - const res = await apiStore.get(true, `events/${eventId}/attendees/search?sort=firstname&${route}`) + const res = await apiStore.get( + true, + `events/${eventId}/attendees/search?sort=firstname&${route}` + ) attendees.value = res.attendees.map((attendee) => ({ id: attendee.id, name: attendee.firstname + ' ' + attendee.lastname, diff --git a/src/stores/eventyayEvent.js b/src/stores/eventyayEvent.js index 8d180a1..8e42875 100644 --- a/src/stores/eventyayEvent.js +++ b/src/stores/eventyayEvent.js @@ -8,16 +8,13 @@ export const useEventyayEventStore = defineStore('eventyayEvent', () => { const error = ref(null) async function fetchEvents(url, apiToken, organizer) { - loading.value = false + loading.value = true error.value = null try { const api = mande(url, { headers: { Authorization: `Device ${apiToken}` } }) - console.log(`/api/v1/organizers/${organizer}/events/`) const response = await api.get(`/api/v1/organizers/${organizer}/events/`) - console.log('Hello', response) events.value = response.results - loading.value = true } catch (err) { error.value = err.message } finally { diff --git a/src/stores/processDevice.js b/src/stores/processDevice.js index 6fbba7c..04d0a54 100644 --- a/src/stores/processDevice.js +++ b/src/stores/processDevice.js @@ -1,3 +1,4 @@ +import { useApiStore } from '@/stores/api' import { useCameraStore } from '@/stores/camera' import { mande } from 'mande' import { defineStore } from 'pinia' @@ -9,7 +10,7 @@ export const useProcessDeviceStore = defineStore('processDevice', () => { const message = ref('') const showSuccess = ref(false) const showError = ref(false) - + const apiStore = useApiStore() function $reset() { message.value = '' showSuccess.value = false @@ -43,13 +44,10 @@ export const useProcessDeviceStore = defineStore('processDevice', () => { async function authDevice(val) { try { const qrData = JSON.parse(val) - console.log(qrData) if (qrData.handshake_version > 1) { message.value = 'Unsupported handshake version' showErrorMsg() return - } else { - console.log('Handshake version is 1') } const payload = { @@ -62,28 +60,24 @@ export const useProcessDeviceStore = defineStore('processDevice', () => { software_version: 'x.x' } let url = qrData.url + const port = import.meta.env.VITE_LOCAL_PORT || 3000 if (url.includes('localhost')) { - url = `${url}:8000` // Add your desired port number here + url = `${url}:${port}` // Add your desired port number here } - console.log(url) const api = mande(url, { headers: { 'Content-Type': 'application/json' } }) const response = await api.post('/api/v1/device/initialize', payload) - console.log(response) if (response) { + apiStore.newSession(true) const data = response - console.log(data.api_token) localStorage.setItem('api_token', data.api_token) localStorage.setItem('organizer', data.organizer) localStorage.setItem('url', url) - router.push({ name: 'eventyayevents' }) + router.push({ name: 'eventyayselect' }) showSuccessMsg() } else { - console.log('Something happend') showErrorMsg() } } catch (error) { - console.log(error) - console.log('Error in catch') showErrorMsg() } } From b50511323659b510bc4dcc80a037ef8d44c0ab30 Mon Sep 17 00:00:00 2001 From: Sak1012 <1012srivatsavas@gmail.com> Date: Mon, 9 Sep 2024 15:49:41 +0530 Subject: [PATCH 09/23] Added basic auth logic for leed scanning --- src/components/Common/QRCamera.vue | 8 +- .../Eventyay/EventyayEventSelection.vue | 23 ++++-- src/components/Eventyay/EventyayEvents.vue | 15 +++- src/components/Eventyay/EventyayLeedLogin.vue | 81 +++++++++++++++++++ src/components/Registration/Device/Device.vue | 8 -- src/router/index.js | 6 ++ src/stores/leedauth.js | 29 +++++++ src/stores/processDevice.js | 6 +- src/stores/processEventyayCheckIn.js | 61 ++++++++++++++ 9 files changed, 212 insertions(+), 25 deletions(-) create mode 100644 src/components/Eventyay/EventyayLeedLogin.vue create mode 100644 src/stores/leedauth.js create mode 100644 src/stores/processEventyayCheckIn.js diff --git a/src/components/Common/QRCamera.vue b/src/components/Common/QRCamera.vue index 4753d12..0c00a25 100644 --- a/src/components/Common/QRCamera.vue +++ b/src/components/Common/QRCamera.vue @@ -5,6 +5,7 @@ import { useCameraStore } from '@/stores/camera' import { useProcessRegistrationStore } from '@/stores/processRegistration' import { useProcessCheckInStore } from '@/stores/processCheckIn' import { useProcessDeviceStore } from '@/stores/processDevice' +import { useProcessEventyayCheckInStore } from '@/stores/processEventyayCheckIn' const props = defineProps({ qrType: { @@ -25,7 +26,7 @@ const cameraStore = useCameraStore() const processRegistrationStore = useProcessRegistrationStore() const processCheckInStore = useProcessCheckInStore() const processDeviceStore = useProcessDeviceStore() - +const processEventyayCheckIn = useProcessEventyayCheckInStore() const route = useRoute() const stationId = route.params.stationId const scannerType = route.params.scannerType @@ -40,11 +41,10 @@ async function processQR() { await processCheckInStore.checkInAttendeeScannerToRoom(stationId, scannerType) } if (props.qrType === 'device') { - await processDeviceStore.authDevice(cameraStore.qrCodeValue) + await processDeviceStore.authDevice() } if (props.qrType === 'eventyaycheckin') { - console.log(cameraStore.qrCodeValue) - console.log('Check-in') + await processEventyayCheckIn.checkIn() } cameraStore.paused = false } diff --git a/src/components/Eventyay/EventyayEventSelection.vue b/src/components/Eventyay/EventyayEventSelection.vue index b21fd2c..9fb36a0 100644 --- a/src/components/Eventyay/EventyayEventSelection.vue +++ b/src/components/Eventyay/EventyayEventSelection.vue @@ -10,18 +10,27 @@ const router = useRouter() function checkIn() { router.push({ name: 'eventyayevents' }) } +function leadscan() { + router.push({ name: 'eventyayleedlogin' }) +} diff --git a/src/components/Eventyay/EventyayEvents.vue b/src/components/Eventyay/EventyayEvents.vue index 28ec130..0577401 100644 --- a/src/components/Eventyay/EventyayEvents.vue +++ b/src/components/Eventyay/EventyayEvents.vue @@ -26,9 +26,18 @@ watchEffect(() => { }) const submitForm = () => { + if (localStorage.getItem('selectedEventSlug') || localStorage.getItem('selectedEventName')) { + localStorage.removeItem('selectedEventSlug') + localStorage.removeItem('selectedEventName') + } + if (selectedEvent.value) { - localStorage.setItem('selectedEvent', selectedEvent.value) - router.push({ name: 'eventyaycheckin' }) + const selectedEventData = events.find((event) => event.slug === selectedEvent.value) + if (selectedEventData) { + localStorage.setItem('selectedEventSlug', selectedEventData.slug) + localStorage.setItem('selectedEventName', selectedEventData.name.en) + router.push({ name: 'eventyaycheckin' }) + } } else { console.error('Please select an event.') } @@ -57,7 +66,7 @@ const submitForm = () => { No events available
diff --git a/src/components/Eventyay/EventyayLeedLogin.vue b/src/components/Eventyay/EventyayLeedLogin.vue new file mode 100644 index 0000000..ee014a4 --- /dev/null +++ b/src/components/Eventyay/EventyayLeedLogin.vue @@ -0,0 +1,81 @@ + + + diff --git a/src/components/Registration/Device/Device.vue b/src/components/Registration/Device/Device.vue index 953ae7c..dd6bcb0 100644 --- a/src/components/Registration/Device/Device.vue +++ b/src/components/Registration/Device/Device.vue @@ -29,13 +29,5 @@ async function registerDevice() {

Oops! something went wrong

-
- - -
diff --git a/src/router/index.js b/src/router/index.js index b3aafa1..e5f11e0 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -4,6 +4,7 @@ import CheckInStats from '@/components/CheckIn/CheckInStats.vue' import EventyayEventCheckIn from '@/components/Eventyay/EventyayEventCheckIn.vue' import EventyayEvents from '@/components/Eventyay/EventyayEvents.vue' import EventyayEventSelection from '@/components/Eventyay/EventyayEventSelection.vue' +import EventyayLeedLogin from '@/components/Eventyay/EventyayLeedLogin.vue' import Device from '@/components/Registration/Device/Device.vue' import RegistrationKiosk from '@/components/Registration/Kiosk/KioskOverview.vue' import RegistrationStats from '@/components/Registration/Station/RegistrationStats.vue' @@ -44,6 +45,11 @@ const router = createRouter({ name: 'eventyayselect', component: EventyayEventSelection }, + { + path: '/eventyayleedlogin', + name: 'eventyayleedlogin', + component: EventyayLeedLogin + }, { path: '/panel', name: 'auth', diff --git a/src/stores/leedauth.js b/src/stores/leedauth.js new file mode 100644 index 0000000..116ff71 --- /dev/null +++ b/src/stores/leedauth.js @@ -0,0 +1,29 @@ +import { mande } from 'mande' +import { defineStore } from 'pinia' + +export const useleedauth = defineStore('leedauth', () => { + async function leedlogin(payload) { + try { + console.log('leedlogin') + const url = localStorage.getItem('url') + const organizer = localStorage.getItem('organizer') + const slug = localStorage.getItem('selectedEventSlug') + const apiToken = localStorage.getItem('api_token') + console.log(url, organizer, slug, apiToken, payload) + const headers = { + Authorization: `Device ${apiToken}`, + Accept: 'application/json' + } + const api = mande(url, { headers: headers }) + const response = await api.post(`/api/v1/event/${organizer}/${slug}/exhibitors/auth`, payload) + console.log('here', response) + return response + } catch (error) { + console.log(error) + console.log('error') + return 'wt' + } + } + + return { leedlogin } +}) diff --git a/src/stores/processDevice.js b/src/stores/processDevice.js index 04d0a54..0c8a4ae 100644 --- a/src/stores/processDevice.js +++ b/src/stores/processDevice.js @@ -41,9 +41,9 @@ export const useProcessDeviceStore = defineStore('processDevice', () => { showError.value = false } - async function authDevice(val) { + async function authDevice() { try { - const qrData = JSON.parse(val) + const qrData = JSON.parse(cameraStore.qrCodeValue) if (qrData.handshake_version > 1) { message.value = 'Unsupported handshake version' showErrorMsg() @@ -60,7 +60,7 @@ export const useProcessDeviceStore = defineStore('processDevice', () => { software_version: 'x.x' } let url = qrData.url - const port = import.meta.env.VITE_LOCAL_PORT || 3000 + const port = import.meta.env.VITE_LOCAL_PORT || 8000 if (url.includes('localhost')) { url = `${url}:${port}` // Add your desired port number here } diff --git a/src/stores/processEventyayCheckIn.js b/src/stores/processEventyayCheckIn.js new file mode 100644 index 0000000..3d73cff --- /dev/null +++ b/src/stores/processEventyayCheckIn.js @@ -0,0 +1,61 @@ +import { useCameraStore } from '@/stores/camera' +import { defineStore } from 'pinia' +import { computed, ref } from 'vue' + +export const useProcessEventyayCheckInStore = defineStore('processEventyayCheckIn', () => { + const cameraStore = useCameraStore() + const message = ref('') + const showSuccess = ref(false) + const showError = ref(false) + function $reset() { + message.value = '' + showSuccess.value = false + showError.value = false + } + + const response = computed(() => { + let classType = '' + if (showSuccess.value) { + classType = 'text-success' + } + if (showError.value) { + classType = 'text-danger' + } + return { + message: message.value, + class: classType + } + }) + + function showErrorMsg() { + showSuccess.value = false + showError.value = true + } + + function showSuccessMsg() { + showSuccess.value = true + showError.value = false + } + + async function checkIn() { + const qrData = JSON.parse(cameraStore.qrCodeValue) + const event = localStorage.getItem('selectedEventName') + + if (qrData.event === event) { + console.log(cameraStore.qrCodeValue) + message.value = 'Check in successful' + showSuccessMsg() + } else { + console.log(qrData.event) + console.log(event) + message.value = 'Invalid Event' + showErrorMsg() + } + } + + return { + response, + checkIn, + $reset + } +}) From 67e1679b0716aa576c586d7c9c86cbd6da7d0188 Mon Sep 17 00:00:00 2001 From: Sak1012 <1012srivatsavas@gmail.com> Date: Fri, 18 Oct 2024 11:49:38 +0530 Subject: [PATCH 10/23] Add Lead API and Check-in API --- src/components/Common/QRCamera.vue | 11 ++ .../Eventyay/EventyayEventSelection.vue | 2 +- src/components/Eventyay/EventyayEvents.vue | 22 ++-- src/components/Eventyay/EventyayLeedLogin.vue | 5 +- src/components/Eventyay/LeadScanning.vue | 14 ++ src/components/LoginForm.vue | 3 +- src/router/index.js | 6 + src/stores/eventyayEvent.js | 7 +- src/stores/leadscan.js | 69 ++++++++++ src/stores/leedauth.js | 12 +- src/stores/processDevice.js | 2 +- src/stores/processEventyayCheckIn.js | 124 ++++++++++++++---- 12 files changed, 219 insertions(+), 58 deletions(-) create mode 100644 src/components/Eventyay/LeadScanning.vue create mode 100644 src/stores/leadscan.js diff --git a/src/components/Common/QRCamera.vue b/src/components/Common/QRCamera.vue index 0c00a25..ccbbf4d 100644 --- a/src/components/Common/QRCamera.vue +++ b/src/components/Common/QRCamera.vue @@ -6,6 +6,8 @@ import { useProcessRegistrationStore } from '@/stores/processRegistration' import { useProcessCheckInStore } from '@/stores/processCheckIn' import { useProcessDeviceStore } from '@/stores/processDevice' import { useProcessEventyayCheckInStore } from '@/stores/processEventyayCheckIn' +import { useLeadScanStore } from '@/stores/leadscan' +import { storeToRefs } from 'pinia' const props = defineProps({ qrType: { @@ -27,6 +29,9 @@ const processRegistrationStore = useProcessRegistrationStore() const processCheckInStore = useProcessCheckInStore() const processDeviceStore = useProcessDeviceStore() const processEventyayCheckIn = useProcessEventyayCheckInStore() +const processLeadScan = useLeadScanStore() +const { message, showSuccess, showError } = storeToRefs(processEventyayCheckIn) + const route = useRoute() const stationId = route.params.stationId const scannerType = route.params.scannerType @@ -46,6 +51,9 @@ async function processQR() { if (props.qrType === 'eventyaycheckin') { await processEventyayCheckIn.checkIn() } + if (props.qrType === 'eventyaylead') { + await processLeadScan.scanLead() + } cameraStore.paused = false } @@ -57,5 +65,8 @@ async function processQR() {

{{ details }}

+

+ {{ message }} +

diff --git a/src/components/Eventyay/EventyayEventSelection.vue b/src/components/Eventyay/EventyayEventSelection.vue index 9fb36a0..d2b86ed 100644 --- a/src/components/Eventyay/EventyayEventSelection.vue +++ b/src/components/Eventyay/EventyayEventSelection.vue @@ -8,7 +8,7 @@ loadingStore.contentLoaded() const router = useRouter() function checkIn() { - router.push({ name: 'eventyayevents' }) + router.push({ name: 'eventyaycheckin' }) } function leadscan() { router.push({ name: 'eventyayleedlogin' }) diff --git a/src/components/Eventyay/EventyayEvents.vue b/src/components/Eventyay/EventyayEvents.vue index 0577401..492c8ca 100644 --- a/src/components/Eventyay/EventyayEvents.vue +++ b/src/components/Eventyay/EventyayEvents.vue @@ -12,18 +12,16 @@ const url = ref('') const eventyayEventStore = useEventyayEventStore() const selectedEvent = ref(null) const router = useRouter() -const { events, loading, error, fetchEvents } = eventyayEventStore +const { events, error, fetchEvents } = eventyayEventStore -watchEffect(() => { - apiToken.value = localStorage.getItem('api_token') - organiser.value = localStorage.getItem('organizer') - url.value = localStorage.getItem('url') +apiToken.value = localStorage.getItem('api_token') +organiser.value = localStorage.getItem('organizer') +url.value = localStorage.getItem('url') - if (apiToken.value && organiser.value && url.value) { - fetchEvents(url.value, apiToken.value, organiser.value) - loadingStore.contentLoaded() - } -}) +if (apiToken.value && organiser.value && url.value) { + fetchEvents(url.value, apiToken.value, organiser.value) + loadingStore.contentLoaded() +} const submitForm = () => { if (localStorage.getItem('selectedEventSlug') || localStorage.getItem('selectedEventName')) { @@ -36,7 +34,7 @@ const submitForm = () => { if (selectedEventData) { localStorage.setItem('selectedEventSlug', selectedEventData.slug) localStorage.setItem('selectedEventName', selectedEventData.name.en) - router.push({ name: 'eventyaycheckin' }) + router.push({ name: 'eventyayselect' }) } } else { console.error('Please select an event.') @@ -62,7 +60,7 @@ const submitForm = () => { /> -
+
No events available diff --git a/src/components/Eventyay/LeadScanning.vue b/src/components/Eventyay/LeadScanning.vue new file mode 100644 index 0000000..772b26a --- /dev/null +++ b/src/components/Eventyay/LeadScanning.vue @@ -0,0 +1,14 @@ + + + diff --git a/src/components/LoginForm.vue b/src/components/LoginForm.vue index 64195c5..c47d7d4 100644 --- a/src/components/LoginForm.vue +++ b/src/components/LoginForm.vue @@ -56,7 +56,6 @@ async function submitLogin() { } function registerDevice() { - console.log(server.value) if (server.value === '' || server.value === 'Select a Server') { errmessage.value = 'Please select a server first' showServerError.value = true @@ -150,7 +149,7 @@ onMounted(() => {

{ const events = ref([]) - const loading = ref(false) const error = ref(null) async function fetchEvents(url, apiToken, organizer) { - loading.value = true error.value = null try { - const api = mande(url, { headers: { Authorization: `Device ${apiToken}` } }) + const api = mande(url, { headers: { authorization: `Device ${apiToken}` } }) const response = await api.get(`/api/v1/organizers/${organizer}/events/`) events.value = response.results } catch (err) { error.value = err.message - } finally { - loading.value = false } } return { events, - loading, error, fetchEvents } diff --git a/src/stores/leadscan.js b/src/stores/leadscan.js new file mode 100644 index 0000000..1cbe609 --- /dev/null +++ b/src/stores/leadscan.js @@ -0,0 +1,69 @@ +import { useCameraStore } from '@/stores/camera' +import { mande } from 'mande' +import { defineStore } from 'pinia' +import { ref } from 'vue' + +export const useLeadScanStore = defineStore('processLeadScan', () => { + const cameraStore = useCameraStore() + const message = ref('') + const showSuccess = ref(false) + const showError = ref(false) + + function $reset() { + message.value = '' + showSuccess.value = false + showError.value = false + } + + function showErrorMsg(msg) { + message.value = msg + showSuccess.value = false + showError.value = true + } + + function showSuccessMsg(msg) { + message.value = msg + showSuccess.value = true + showError.value = false + } + + async function scanLead() { + const qrData = JSON.parse(cameraStore.qrCodeValue) + + const apiToken = localStorage.getItem('api_token') + const url = localStorage.getItem('url') + const key = localStorage.getItem('exhikey') + const slug = localStorage.getItem('selectedEventSlug') + + // Prepare the POST request body + const requestBody = { + lead: qrData.lead, + scanned: 'null', + scan_type: 'lead', + device_name: 'Test' + } + + try { + const headers = { + Authorization: `Device ${apiToken}`, + Accept: 'application/json', + Exhibitor: key + } + + const api = mande(`${url}/api/v1/event/admin/${slug}/exhibitors/lead/create`, { + headers: headers + }) + const response = await api.post(requestBody) + } catch (err) { + showErrorMsg('Check-in failed: ' + err.message) + } + } + + return { + message, + showSuccess, + showError, + scanLead, + $reset + } +}) diff --git a/src/stores/leedauth.js b/src/stores/leedauth.js index 116ff71..4e3887c 100644 --- a/src/stores/leedauth.js +++ b/src/stores/leedauth.js @@ -4,24 +4,26 @@ import { defineStore } from 'pinia' export const useleedauth = defineStore('leedauth', () => { async function leedlogin(payload) { try { - console.log('leedlogin') const url = localStorage.getItem('url') const organizer = localStorage.getItem('organizer') const slug = localStorage.getItem('selectedEventSlug') const apiToken = localStorage.getItem('api_token') - console.log(url, organizer, slug, apiToken, payload) const headers = { Authorization: `Device ${apiToken}`, Accept: 'application/json' } const api = mande(url, { headers: headers }) const response = await api.post(`/api/v1/event/${organizer}/${slug}/exhibitors/auth`, payload) - console.log('here', response) + if (response.success) { + if (localStorage.getItem('exhikey')) { + localStorage.removeItem('exhikey') + } + localStorage.setItem('exhikey', payload.key) + } + return response } catch (error) { - console.log(error) console.log('error') - return 'wt' } } diff --git a/src/stores/processDevice.js b/src/stores/processDevice.js index 0c8a4ae..d21506c 100644 --- a/src/stores/processDevice.js +++ b/src/stores/processDevice.js @@ -72,7 +72,7 @@ export const useProcessDeviceStore = defineStore('processDevice', () => { localStorage.setItem('api_token', data.api_token) localStorage.setItem('organizer', data.organizer) localStorage.setItem('url', url) - router.push({ name: 'eventyayselect' }) + router.push({ name: 'eventyayevents' }) showSuccessMsg() } else { showErrorMsg() diff --git a/src/stores/processEventyayCheckIn.js b/src/stores/processEventyayCheckIn.js index 3d73cff..68b20c0 100644 --- a/src/stores/processEventyayCheckIn.js +++ b/src/stores/processEventyayCheckIn.js @@ -1,60 +1,126 @@ import { useCameraStore } from '@/stores/camera' +import { mande } from 'mande' import { defineStore } from 'pinia' -import { computed, ref } from 'vue' +import { ref } from 'vue' export const useProcessEventyayCheckInStore = defineStore('processEventyayCheckIn', () => { const cameraStore = useCameraStore() const message = ref('') const showSuccess = ref(false) const showError = ref(false) + function $reset() { message.value = '' showSuccess.value = false showError.value = false } - const response = computed(() => { - let classType = '' - if (showSuccess.value) { - classType = 'text-success' - } - if (showError.value) { - classType = 'text-danger' - } - return { - message: message.value, - class: classType - } - }) - - function showErrorMsg() { + function showErrorMsg(msg) { + message.value = msg showSuccess.value = false showError.value = true } - function showSuccessMsg() { + function showSuccessMsg(msg) { + message.value = msg showSuccess.value = true showError.value = false } + // Function to generate a random nonce + function generateNonce(length = 32) { + const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' + let result = '' + for (let i = 0; i < length; i++) { + result += chars.charAt(Math.floor(Math.random() * chars.length)) + } + return result + } + + async function getlist() { + const apiToken = localStorage.getItem('api_token') + const url = localStorage.getItem('url') + const slug = localStorage.getItem('selectedEventSlug') + const org = localStorage.getItem('organizer') + const api = mande(url, { headers: { Authorization: `Device ${apiToken}` } }) + + // Fetch the check-in lists + const response = await api.get(`/api/v1/organizers/${org}/events/${slug}/checkinlists/`) + + // Extract all IDs from the results + const listIds = response.results.map((list) => list.id.toString()) + return listIds + } + async function checkIn() { const qrData = JSON.parse(cameraStore.qrCodeValue) - const event = localStorage.getItem('selectedEventName') - - if (qrData.event === event) { - console.log(cameraStore.qrCodeValue) - message.value = 'Check in successful' - showSuccessMsg() - } else { - console.log(qrData.event) - console.log(event) - message.value = 'Invalid Event' - showErrorMsg() + + const apiToken = localStorage.getItem('api_token') + const url = localStorage.getItem('url') + const org = localStorage.getItem('organizer') + + // Instead of calling getlist(), let's use a hardcoded value for now + const checkInList = ['2'] + + // Generate a random nonce + const nonce = generateNonce() + + // Prepare the POST request body + const requestBody = { + secret: qrData.ticket, + source_type: 'barcode', + lists: checkInList, + force: false, + ignore_unpaid: false, + nonce: nonce, + datetime: null, + questions_supported: false + } + + + try { + const response = await fetch(`${url}/api/v1/organizers/${org}/checkinrpc/redeem/`, { + method: 'POST', + headers: { + Authorization: `Device ${apiToken}`, + Accept: 'application/json', + 'Content-Type': 'application/json' + }, + body: JSON.stringify(requestBody) + }) + + if (!response.ok) { + const errorData = await response.json() + throw new Error(`HTTP error! status: ${response.status}`) + } + + const data = await response.json() + + if (data.status === 'ok') { + const pdfDownload = data.position.downloads.find((download) => download.output === 'pdf') + if (pdfDownload) { + const printWindow = window.open(pdfDownload.url, '_blank') + printWindow.onload = function () { + printWindow.print() + } + } else { + console.warn('PDF download URL not found in the response') + } + + showSuccessMsg(`Check-in successful for ${data.position.attendee_name}`) + } else { + showErrorMsg('Check-in failed: Unexpected response') + } + } catch (error) { + console.error('Fetch error:', error) + showErrorMsg('Check-in failed: ' + error.message) } } return { - response, + message, + showSuccess, + showError, checkIn, $reset } From e168a42da7edf589606ead6274cb508635befed7 Mon Sep 17 00:00:00 2001 From: Sak1012 <1012srivatsavas@gmail.com> Date: Fri, 18 Oct 2024 16:29:26 +0530 Subject: [PATCH 11/23] Fix Syntax --- src/components/Eventyay/EventyayEventCheckIn.vue | 2 +- src/components/Eventyay/EventyayEventSelection.vue | 4 ++-- src/components/Eventyay/EventyayEvents.vue | 6 +++--- src/components/Eventyay/EventyayLeedLogin.vue | 4 ++-- src/components/Eventyay/LeadScanning.vue | 2 +- src/components/LoginForm.vue | 8 ++++---- src/components/Registration/Device/Device.vue | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/components/Eventyay/EventyayEventCheckIn.vue b/src/components/Eventyay/EventyayEventCheckIn.vue index 33bbf30..ff1beb7 100644 --- a/src/components/Eventyay/EventyayEventCheckIn.vue +++ b/src/components/Eventyay/EventyayEventCheckIn.vue @@ -9,6 +9,6 @@ loadingStore.contentLoaded()
- +
diff --git a/src/components/Eventyay/EventyayEventSelection.vue b/src/components/Eventyay/EventyayEventSelection.vue index d2b86ed..4d8d8c7 100644 --- a/src/components/Eventyay/EventyayEventSelection.vue +++ b/src/components/Eventyay/EventyayEventSelection.vue @@ -21,13 +21,13 @@ function leadscan() { >

OR

diff --git a/src/components/Eventyay/EventyayEvents.vue b/src/components/Eventyay/EventyayEvents.vue index 492c8ca..67c0596 100644 --- a/src/components/Eventyay/EventyayEvents.vue +++ b/src/components/Eventyay/EventyayEvents.vue @@ -54,8 +54,8 @@ const submitForm = () => {
@@ -63,7 +63,7 @@ const submitForm = () => {
No events available diff --git a/src/components/Eventyay/EventyayLeedLogin.vue b/src/components/Eventyay/EventyayLeedLogin.vue index 77ae2d7..2a302f0 100644 --- a/src/components/Eventyay/EventyayLeedLogin.vue +++ b/src/components/Eventyay/EventyayLeedLogin.vue @@ -67,8 +67,8 @@ loadingStore.contentLoaded()
diff --git a/src/components/Eventyay/LeadScanning.vue b/src/components/Eventyay/LeadScanning.vue index 772b26a..43a4287 100644 --- a/src/components/Eventyay/LeadScanning.vue +++ b/src/components/Eventyay/LeadScanning.vue @@ -9,6 +9,6 @@ loadingStore.contentLoaded()
- +
diff --git a/src/components/LoginForm.vue b/src/components/LoginForm.vue index c47d7d4..4803e8d 100644 --- a/src/components/LoginForm.vue +++ b/src/components/LoginForm.vue @@ -129,8 +129,8 @@ onMounted(() => {
@@ -148,9 +148,9 @@ onMounted(() => { >

diff --git a/src/components/Registration/Device/Device.vue b/src/components/Registration/Device/Device.vue index dd6bcb0..dc7a9e6 100644 --- a/src/components/Registration/Device/Device.vue +++ b/src/components/Registration/Device/Device.vue @@ -25,7 +25,7 @@ async function registerDevice() {
- +

Oops! something went wrong

From d016d4cc2e93e093a2976ac810ca1c4c38629aa5 Mon Sep 17 00:00:00 2001 From: Sak1012 <1012srivatsavas@gmail.com> Date: Sun, 20 Oct 2024 23:13:05 +0530 Subject: [PATCH 12/23] Changed The Workflow Major Changes Done to the Workflow and the tokens stored Local Storage is now moves to eventyayapi store --- .env | 4 +- package-lock.json | 9 +- .../Eventyay/EventyayEventSelection.vue | 36 -------- src/components/Eventyay/EventyayEvents.vue | 39 ++++----- src/components/Eventyay/EventyayLeedLogin.vue | 6 +- src/components/LoginForm.vue | 87 +++++++------------ src/components/Registration/Device/Device.vue | 25 +++--- src/router/index.js | 6 -- src/stores/eventyayEvent.js | 1 + src/stores/eventyayapi.js | 43 +++++++++ src/stores/leadscan.js | 21 +++-- src/stores/leedauth.js | 20 ++--- src/stores/processDevice.js | 17 ++-- src/stores/processEventyayCheckIn.js | 23 +++-- 14 files changed, 153 insertions(+), 184 deletions(-) delete mode 100644 src/components/Eventyay/EventyayEventSelection.vue create mode 100644 src/stores/eventyayapi.js diff --git a/.env b/.env index c5a6df4..a637d9a 100644 --- a/.env +++ b/.env @@ -1,3 +1,3 @@ -VITE_TEST_API_URL=https://test-api.eventyay.com/v1 -VITE_PROD_API_URL=https://api.eventyay.com/v1 +VITE_TEST_API_URL=https://app.eventyay.com/v1 +VITE_PROD_API_URL=https://app.eventyay.com/v1 VITE_LOCAL_PORT=8000 diff --git a/package-lock.json b/package-lock.json index fb1c401..2a2cbee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1629,9 +1629,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001507", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001507.tgz", - "integrity": "sha512-SFpUDoSLCaE5XYL2jfqe9ova/pbQHEmbheDf5r4diNwbAgR3qxM9NQtfsiSscjqoya5K7kFcHPUQ+VsUkIJR4A==", + "version": "1.0.30001669", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001669.tgz", + "integrity": "sha512-DlWzFDJqstqtIVx1zeSpIMLjunf5SmwOw0N2Ck/QSQdS8PLS4+9HrLaYei4w8BIAL7IB/UEDu889d8vhCTPA0w==", "dev": true, "funding": [ { @@ -1646,7 +1646,8 @@ "type": "github", "url": "https://github.com/sponsors/ai" } - ] + ], + "license": "CC-BY-4.0" }, "node_modules/caseless": { "version": "0.12.0", diff --git a/src/components/Eventyay/EventyayEventSelection.vue b/src/components/Eventyay/EventyayEventSelection.vue deleted file mode 100644 index 4d8d8c7..0000000 --- a/src/components/Eventyay/EventyayEventSelection.vue +++ /dev/null @@ -1,36 +0,0 @@ - - - diff --git a/src/components/Eventyay/EventyayEvents.vue b/src/components/Eventyay/EventyayEvents.vue index 67c0596..b410c5c 100644 --- a/src/components/Eventyay/EventyayEvents.vue +++ b/src/components/Eventyay/EventyayEvents.vue @@ -1,40 +1,32 @@