Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eventyay-tickets Integration #115

Open
wants to merge 9 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
VITE_TEST_API_URL=https://test-api.eventyay.com/v1
VITE_PROD_API_URL=https://api.eventyay.com/v1
VITE_PROD_API_URL=https://api.eventyay.com/v1
VITE_LOCAL_PORT=8000
9 changes: 9 additions & 0 deletions src/components/Common/QRCamera.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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
Expand All @@ -37,6 +39,13 @@ async function processQR() {
if (props.qrType === 'checkIn') {
await processCheckInStore.checkInAttendeeScannerToRoom(stationId, scannerType)
}
if (props.qrType === 'device') {
await processDeviceStore.authDevice(cameraStore.qrCodeValue)
Sak1012 marked this conversation as resolved.
Show resolved Hide resolved
}
if (props.qrType === 'eventyaycheckin') {
console.log(cameraStore.qrCodeValue)
console.log('Check-in')
}
cameraStore.paused = false
}
</script>
Expand Down
14 changes: 14 additions & 0 deletions src/components/Eventyay/EventyayEventCheckIn.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script setup>
import QRCamera from '@/components/Common/QRCamera.vue'
import { useLoadingStore } from '@/stores/loading'
const loadingStore = useLoadingStore()
loadingStore.contentLoaded()
</script>

<template>
<div
class="-mt-16 grid h-screen w-full grid-cols-1 place-items-center items-center justify-center align-middle"
>
<QRCamera :qr-type="'eventyaycheckin'" :scan-type="'Check-In'" />
</div>
</template>
27 changes: 27 additions & 0 deletions src/components/Eventyay/EventyayEventSelection.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<script setup>
import { useLoadingStore } from '@/stores/loading'
import StandardButton from '@/components/Common/StandardButton.vue'
import { useRouter } from 'vue-router'

const loadingStore = useLoadingStore()
loadingStore.contentLoaded()

const router = useRouter()
function checkIn() {
router.push({ name: 'eventyayevents' })
}
</script>

<template>
<div
class="-mt-16 grid h-screen w-full grid-cols-1 place-items-center items-center justify-center align-middle"
>
<StandardButton :text="'Lead Scanning'" class="btn-primary mt-6 w-full justify-center" />
<p class="text-xl">OR</p>
<StandardButton
:text="'Check-In'"
class="btn-primary mt-6 w-full justify-center"
@click="checkIn()"
/>
</div>
</template>
65 changes: 65 additions & 0 deletions src/components/Eventyay/EventyayEvents.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<script setup>
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('')
const organiser = ref('')
const url = ref('')
const eventyayEventStore = useEventyayEventStore()
const selectedEvent = ref(null)
const router = useRouter()
const { events, loading, error, fetchEvents } = eventyayEventStore

watchEffect(() => {
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()
}
})

const submitForm = () => {
if (selectedEvent.value) {
localStorage.setItem('selectedEvent', selectedEvent.value)
router.push({ name: 'eventyaycheckin' })
} else {
console.error('Please select an event.')
Sak1012 marked this conversation as resolved.
Show resolved Hide resolved
}
}
</script>
<template>
<div class="-mt-16 flex h-screen flex-col justify-center">
<div v-if="loading">Loading events...</div>
<div v-if="error" class="text-danger">{{ error }}</div>
<form v-if="events.length" @submit.prevent="submitForm">
Sak1012 marked this conversation as resolved.
Show resolved Hide resolved
<div v-for="event in events" :key="event.slug" class="mb-2">
<label>
<input type="radio" :value="event.slug" v-model="selectedEvent" />
{{ event.name.en }}
</label>
</div>
<div>
<StandardButton
:type="'submit'"
:text="'Select Event'"
class="btn-primary mt-6 w-full justify-center"
/>
</div>
</form>
<div v-if="!loading && !events.length && !error">
No events available
<StandardButton
:text="'Refresh'"
class="btn-primary mt-6 w-full justify-center"
@click="fetchEvents(url.value, apiToken.value, organiser.value)"
/>
</div>
</div>
</template>
55 changes: 53 additions & 2 deletions src/components/LoginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,25 @@ const userStore = useUserStore()

const email = ref('')
const password = ref('')
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() {
if (server.value === '' || server.value === DEFAULT_SERVER_VALUE) {
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

Expand All @@ -42,6 +55,24 @@ async function submitLogin() {
loadingStore.contentLoaded()
}

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
}
showServerError.value = false
router.push({
name: 'device'
})
}

onMounted(() => {
if (authStore.isAuthenticated) {
router.push({
Expand Down Expand Up @@ -88,6 +119,15 @@ onMounted(() => {
</div>
</div>

<div>
<label for="select">Select a Server</label>
<select id="select" v-model="server" class="mt-2 block w-full">
<option>Open-Event</option>
<option>Eventyay</option>
<option>Testing</option>
</select>
</div>

<div>
<StandardButton
:type="'submit'"
Expand All @@ -101,13 +141,24 @@ onMounted(() => {
</div>
</form>

<p class="mt-10 text-center text-sm">
<p class="mt-5 text-center text-sm">
<span>Forgot password?</span>
{{ ' ' }}
<a href="https://eventyay.com/reset-password" class="font-medium leading-6 text-primary"
>Click here to reset password</a
>
</p>
<StandardButton
:type="'button'"
:text="'Register-Device'"
:disabled="false"
class="btn-primary mt-6 w-full justify-center"
@click="registerDevice"
>
</StandardButton>
Sak1012 marked this conversation as resolved.
Show resolved Hide resolved
Comment on lines +151 to +158
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Button text should be a prop

Consider passing the button text as a prop to the StandardButton component for better reusability and consistency.

Suggested change
<StandardButton
:type="'button'"
:text="'Register-Device'"
:disabled="false"
class="btn-primary mt-6 w-full justify-center"
@click="registerDevice"
>
</StandardButton>
<StandardButton
:type="'button'"
:text="buttonText"
:disabled="false"
class="btn-primary mt-6 w-full justify-center"
@click="registerDevice"
/>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are passing a static string (Register-Device) to text prop, no point to use bind syntax and JS expression.

Just pass as normal HTML attribute like this:

<StandardButton text='Register-Device' ... />

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point, @hongquan! If the button text is static and won't change, using a regular HTML attribute is indeed more straightforward and cleaner. However, if there's a possibility that the button text might need to be dynamic or localized in the future, passing it as a prop could be beneficial for flexibility. It really depends on the expected use case. If you foresee any changes or need for localization, consider using a prop; otherwise, your suggestion is perfectly valid for a static text.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this was the convention followed everywhere else where StandardButton component was previously being used, I too did the same should I still change it ?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the convention in your codebase is to use the binding syntax for the text prop, even for static strings, it's generally a good idea to maintain consistency with the existing code. This can help with readability and maintainability, especially if there's a chance that the text might become dynamic or require localization in the future.

However, if you and your team decide that using a regular HTML attribute for static text is more appropriate and aligns with your coding standards, you can certainly make that change. Consistency is key, so whichever approach you choose, it would be beneficial to apply it uniformly across your project.

If you're unsure, it might be worth discussing with your team to see if there's a preference or if there's a plan to make the button text dynamic in the future.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is not convention, previous people simply don't understand VueJS well enough.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds like there's a bit of a misunderstanding about the use of VueJS syntax in your codebase. If the current practice is to use the binding syntax for static strings, it might be due to a lack of understanding rather than a deliberate convention.

Given this, it could be a good opportunity to align on best practices with your team. Using a regular HTML attribute for static text is more straightforward and should be preferred unless there's a specific reason to use the binding syntax, such as future plans for dynamic content or localization.

If you decide to switch to using regular HTML attributes for static text, it might be helpful to update the existing code for consistency. This could also be a chance to document this as a coding standard for your team to follow moving forward. If you need further guidance, consider discussing this with your team or a lead developer to ensure everyone is on the same page.

<div v-if="showServerError" class="mt-5">
<p class="text-center text-sm text-danger">{{ errmessage }}</p>
</div>
</div>
</div>
</template>
41 changes: 41 additions & 0 deletions src/components/Registration/Device/Device.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<script setup>
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 }
try {
const resp = await processDeviceStore.authDevice(JSON.stringify(payload))
} catch (error) {
showError.value = true
console.error('Error registering device:', error)
}
}
</script>

<template>
<div
class="-mt-16 grid h-screen w-full grid-cols-1 place-items-center items-center justify-center align-middle"
>
<QRCamera :qr-type="'device'" :scan-type="'Device Registration'" />
<div v-if="showError">
<p class="text-sm text-danger">Oops! something went wrong</p>
</div>
<div>
<input type="text" id="auth_token" placeholder="Device Key" class="input" />
<StandardButton
:text="'Register Device'"
class="btn-primary mt-6 w-full justify-center"
@click="registerDevice()"
/>
</div>
</div>
</template>
24 changes: 24 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
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 EventyayEventSelection from '@/components/Eventyay/EventyayEventSelection.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'
Expand All @@ -20,6 +24,26 @@ const router = createRouter({
name: 'userAuth',
component: UserAuth
},
{
path: '/device',
name: 'device',
component: Device
},
hongquan marked this conversation as resolved.
Show resolved Hide resolved
{
path: '/eventyayevents',
name: 'eventyayevents',
component: EventyayEvents
},
{
path: '/eventyaycheckin',
name: 'eventyaycheckin',
component: EventyayEventCheckIn
},
{
path: '/eventyayselect',
name: 'eventyayselect',
component: EventyayEventSelection
},
{
path: '/panel',
name: 'auth',
Expand Down
2 changes: 1 addition & 1 deletion src/stores/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
5 changes: 4 additions & 1 deletion src/stores/attendees.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export const useAttendeesStore = defineStore('attendees', () => {
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,
Expand Down
31 changes: 31 additions & 0 deletions src/stores/eventyayEvent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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}` } })
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
}
})
Loading