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

Allow Open-Event Ticket #22

Merged
merged 2 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 1 addition & 5 deletions src/components/LoginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ function registerDevice() {
showServerError.value = true
return
}
if (server.value === 'Open-Event') {
errmessage.value = 'Please Login with credentials for Open-Event'
showServerError.value = true
return
}
processApi.setServer(server.value)
showServerError.value = false
router.push({
name: 'device'
Expand Down
9 changes: 8 additions & 1 deletion src/stores/eventyayapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const useEventyayApi = defineStore(
const exhiname = ref('')
const boothname = ref('')
const boothid = ref('')
const servername = ref('')

function $reset() {
apitoken.value = ''
Expand Down Expand Up @@ -50,13 +51,18 @@ export const useEventyayApi = defineStore(
selectedRole.value = role
}

function setServer(server) {
servername.value = server
}

return {
$reset,
setApiCred,
setEvent,
setExhibitor,
selectedRole,
setRole,
setServer,
apitoken,
url,
organizer,
Expand All @@ -65,7 +71,8 @@ export const useEventyayApi = defineStore(
exikey,
exhiname,
boothname,
boothid
boothid,
servername
}
},
{
Expand Down
11 changes: 9 additions & 2 deletions src/stores/leadscan.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,16 @@ export const useLeadScanStore = defineStore('processLeadScan', () => {
}

async function scanLead() {
const qrData = JSON.parse(cameraStore.qrCodeValue)
const processApi = useEventyayApi()
const { apitoken, url, organizer, eventSlug, exikey, exhiname, boothid, boothname } = processApi
const { apitoken, url, organizer, eventSlug, exikey, exhiname, boothid, boothname, servername } = processApi
let qrData = {}
if (servername === 'Open-Event') {
qrData = {
lead: cameraStore.qrCodeValue
}
} else {
qrData = JSON.parse(cameraStore.qrCodeValue)
}
const requestBody = {
lead: qrData.lead,
scanned: 'null',
Expand Down
15 changes: 12 additions & 3 deletions src/stores/processEventyayCheckIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const useProcessEventyayCheckInStore = defineStore('processEventyayCheckI

const printWindow = window.open(blobUrl, '_blank')
if (printWindow) {
printWindow.onload = function () {
printWindow.onload = function() {
printWindow.print()
URL.revokeObjectURL(blobUrl)
}
Comment on lines 99 to 104
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider adding error handling for the print window to ensure blobUrl is always cleaned up

Add an onerror handler to clean up the blobUrl if the window fails to load, preventing potential memory leaks.

Suggested change
const printWindow = window.open(blobUrl, '_blank')
if (printWindow) {
printWindow.onload = function () {
printWindow.onload = function() {
printWindow.print()
URL.revokeObjectURL(blobUrl)
}
const printWindow = window.open(blobUrl, '_blank')
if (printWindow) {
printWindow.onload = function() {
printWindow.print()
URL.revokeObjectURL(blobUrl)
}
printWindow.onerror = function() {
URL.revokeObjectURL(blobUrl)
}
} else {
// Clean up if window failed to open
URL.revokeObjectURL(blobUrl)
}

Expand All @@ -117,13 +117,22 @@ export const useProcessEventyayCheckInStore = defineStore('processEventyayCheckI

async function checkIn() {
console.log('Check-in')
const qrData = JSON.parse(cameraStore.qrCodeValue)
const processApi = useEventyayApi()
const { apitoken, url, organizer, eventSlug } = processApi
const { apitoken, url, organizer, servername, eventSlug } = processApi

let qrData = {}
if (servername === 'Open-Event') {
qrData = {
ticket: cameraStore.qrCodeValue
}
} else {
qrData = JSON.parse(cameraStore.qrCodeValue)
Copy link

Choose a reason for hiding this comment

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

issue: Consider adding error handling for JSON.parse to gracefully handle invalid QR codes

Wrap the JSON.parse in a try-catch block and provide appropriate error feedback to the user when an invalid QR code is scanned.

}

const checkInList = await getlist()
const nonce = generateNonce()


const requestBody = {
secret: qrData.ticket,
source_type: 'barcode',
Expand Down