Skip to content

Commit 67ee3dd

Browse files
committed
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
1 parent 4f382e0 commit 67ee3dd

File tree

11 files changed

+59
-25
lines changed

11 files changed

+59
-25
lines changed

.env

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
VITE_TEST_API_URL=https://test-api.eventyay.com/v1
2-
VITE_PROD_API_URL=https://api.eventyay.com/v1
2+
VITE_PROD_API_URL=https://api.eventyay.com/v1
3+
VITE_LOCAL_PORT=8000

hs

-1
This file was deleted.

src/components/Common/QRCamera.vue

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ const stationId = route.params.stationId
3131
const scannerType = route.params.scannerType
3232
3333
async function processQR() {
34-
console.log('Processing QR')
3534
cameraStore.paused = true
3635
if (props.qrType === 'registration') {
3736
await processRegistrationStore.registerAttendeeScanner(stationId)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<script setup>
2+
import { useLoadingStore } from '@/stores/loading'
3+
import StandardButton from '@/components/Common/StandardButton.vue'
4+
import { useRouter } from 'vue-router'
5+
6+
const loadingStore = useLoadingStore()
7+
loadingStore.contentLoaded()
8+
9+
const router = useRouter()
10+
function checkIn() {
11+
router.push({ name: 'eventyayevents' })
12+
}
13+
</script>
14+
15+
<template>
16+
<div
17+
class="-mt-16 grid h-screen w-full grid-cols-1 place-items-center items-center justify-center align-middle"
18+
>
19+
<StandardButton :text="'Lead Scanning'" class="btn-primary mt-6 w-full justify-center" />
20+
<p class="text-xl">OR</p>
21+
<StandardButton
22+
:text="'Check-In'"
23+
class="btn-primary mt-6 w-full justify-center"
24+
@click="checkIn()"
25+
/>
26+
</div>
27+
</template>

src/components/Eventyay/EventyayEvents.vue

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ const submitForm = () => {
2929
if (selectedEvent.value) {
3030
localStorage.setItem('selectedEvent', selectedEvent.value)
3131
router.push({ name: 'eventyaycheckin' })
32-
console.log('Selected event:', selectedEvent.value)
3332
} else {
3433
console.error('Please select an event.')
3534
}

src/components/LoginForm.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ const server = ref('')
1717
const showError = ref(false)
1818
const showServerError = ref(false)
1919
const errmessage = ref('')
20+
const DEFAULT_SERVER_VALUE = 'Select a Server'
2021
// router
2122
const router = useRouter()
2223
2324
async function submitLogin() {
24-
console.log(server.value)
25-
if (server.value === '' || server.value === 'Select a Server') {
25+
if (server.value === '' || server.value === DEFAULT_SERVER_VALUE) {
2626
showServerError.value = true
2727
return
2828
}

src/components/Registration/Device/Device.vue

+11-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,21 @@ import QRCamera from '@/components/Common/QRCamera.vue'
33
import { useLoadingStore } from '@/stores/loading'
44
import StandardButton from '@/components/Common/StandardButton.vue'
55
import { useProcessDeviceStore } from '@/stores/processDevice'
6+
import { ref } from 'vue'
67
const loadingStore = useLoadingStore()
78
loadingStore.contentLoaded()
89
910
const processDeviceStore = useProcessDeviceStore()
10-
11+
const showError = ref(false)
1112
async function registerDevice() {
1213
const auth_token = document.getElementById('auth_token').value
1314
const payload = { handshake_version: 1, url: 'http://localhost', token: auth_token }
14-
await processDeviceStore.authDevice(JSON.stringify(payload))
15+
try {
16+
const resp = await processDeviceStore.authDevice(JSON.stringify(payload))
17+
} catch (error) {
18+
showError.value = true
19+
console.error('Error registering device:', error)
20+
}
1521
}
1622
</script>
1723

@@ -20,6 +26,9 @@ async function registerDevice() {
2026
class="-mt-16 grid h-screen w-full grid-cols-1 place-items-center items-center justify-center align-middle"
2127
>
2228
<QRCamera :qr-type="'device'" :scan-type="'Device Registration'" />
29+
<div v-if="showError">
30+
<p class="text-sm text-danger">Oops! something went wrong</p>
31+
</div>
2332
<div>
2433
<input type="text" id="auth_token" placeholder="Device Key" class="input" />
2534
<StandardButton

src/router/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import CheckInCamera from '@/components/CheckIn/CheckInCamera.vue'
33
import CheckInStats from '@/components/CheckIn/CheckInStats.vue'
44
import EventyayEventCheckIn from '@/components/Eventyay/EventyayEventCheckIn.vue'
55
import EventyayEvents from '@/components/Eventyay/EventyayEvents.vue'
6+
import EventyayEventSelection from '@/components/Eventyay/EventyayEventSelection.vue'
67
import Device from '@/components/Registration/Device/Device.vue'
78
import RegistrationKiosk from '@/components/Registration/Kiosk/KioskOverview.vue'
89
import RegistrationStats from '@/components/Registration/Station/RegistrationStats.vue'
@@ -38,6 +39,11 @@ const router = createRouter({
3839
name: 'eventyaycheckin',
3940
component: EventyayEventCheckIn
4041
},
42+
{
43+
path: '/eventyayselect',
44+
name: 'eventyayselect',
45+
component: EventyayEventSelection
46+
},
4147
{
4248
path: '/panel',
4349
name: 'auth',

src/stores/attendees.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ export const useAttendeesStore = defineStore('attendees', () => {
2424
route += `email=${value}`
2525
}
2626
try {
27-
const res = await apiStore.get(true, `events/${eventId}/attendees/search?sort=firstname&${route}`)
27+
const res = await apiStore.get(
28+
true,
29+
`events/${eventId}/attendees/search?sort=firstname&${route}`
30+
)
2831
attendees.value = res.attendees.map((attendee) => ({
2932
id: attendee.id,
3033
name: attendee.firstname + ' ' + attendee.lastname,

src/stores/eventyayEvent.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,13 @@ export const useEventyayEventStore = defineStore('eventyayEvent', () => {
88
const error = ref(null)
99

1010
async function fetchEvents(url, apiToken, organizer) {
11-
loading.value = false
11+
loading.value = true
1212
error.value = null
1313

1414
try {
1515
const api = mande(url, { headers: { Authorization: `Device ${apiToken}` } })
16-
console.log(`/api/v1/organizers/${organizer}/events/`)
1716
const response = await api.get(`/api/v1/organizers/${organizer}/events/`)
18-
console.log('Hello', response)
1917
events.value = response.results
20-
loading.value = true
2118
} catch (err) {
2219
error.value = err.message
2320
} finally {

src/stores/processDevice.js

+6-12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useApiStore } from '@/stores/api'
12
import { useCameraStore } from '@/stores/camera'
23
import { mande } from 'mande'
34
import { defineStore } from 'pinia'
@@ -9,7 +10,7 @@ export const useProcessDeviceStore = defineStore('processDevice', () => {
910
const message = ref('')
1011
const showSuccess = ref(false)
1112
const showError = ref(false)
12-
13+
const apiStore = useApiStore()
1314
function $reset() {
1415
message.value = ''
1516
showSuccess.value = false
@@ -43,13 +44,10 @@ export const useProcessDeviceStore = defineStore('processDevice', () => {
4344
async function authDevice(val) {
4445
try {
4546
const qrData = JSON.parse(val)
46-
console.log(qrData)
4747
if (qrData.handshake_version > 1) {
4848
message.value = 'Unsupported handshake version'
4949
showErrorMsg()
5050
return
51-
} else {
52-
console.log('Handshake version is 1')
5351
}
5452

5553
const payload = {
@@ -62,28 +60,24 @@ export const useProcessDeviceStore = defineStore('processDevice', () => {
6260
software_version: 'x.x'
6361
}
6462
let url = qrData.url
63+
const port = import.meta.env.VITE_LOCAL_PORT || 3000
6564
if (url.includes('localhost')) {
66-
url = `${url}:8000` // Add your desired port number here
65+
url = `${url}:${port}` // Add your desired port number here
6766
}
68-
console.log(url)
6967
const api = mande(url, { headers: { 'Content-Type': 'application/json' } })
7068
const response = await api.post('/api/v1/device/initialize', payload)
71-
console.log(response)
7269
if (response) {
70+
apiStore.newSession(true)
7371
const data = response
74-
console.log(data.api_token)
7572
localStorage.setItem('api_token', data.api_token)
7673
localStorage.setItem('organizer', data.organizer)
7774
localStorage.setItem('url', url)
78-
router.push({ name: 'eventyayevents' })
75+
router.push({ name: 'eventyayselect' })
7976
showSuccessMsg()
8077
} else {
81-
console.log('Something happend')
8278
showErrorMsg()
8379
}
8480
} catch (error) {
85-
console.log(error)
86-
console.log('Error in catch')
8781
showErrorMsg()
8882
}
8983
}

0 commit comments

Comments
 (0)