@ozdao/prometheus-framework 0.2.229 → 0.2.230
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/prometheus-framework/src/modules/events/components/elements/ButtonCheck.vue.cjs +57 -38
- package/dist/prometheus-framework/src/modules/events/components/elements/ButtonCheck.vue.cjs.map +1 -1
- package/dist/prometheus-framework/src/modules/events/components/elements/ButtonCheck.vue.js +58 -39
- package/dist/prometheus-framework/src/modules/events/components/elements/ButtonCheck.vue.js.map +1 -1
- package/dist/prometheus-framework/src/modules/globals/views/components/partials/NavigationBar.vue.cjs.map +1 -1
- package/dist/prometheus-framework/src/modules/globals/views/components/partials/NavigationBar.vue.js.map +1 -1
- package/dist/prometheus-framework/src/modules/pages/pages.client.cjs +456 -438
- package/dist/prometheus-framework/src/modules/pages/pages.client.js +456 -438
- package/package.json +1 -1
- package/src/modules/events/components/elements/ButtonCheck.vue +67 -36
- package/src/modules/globals/views/components/partials/NavigationBar.vue +6 -0
package/package.json
CHANGED
@@ -1,76 +1,107 @@
|
|
1
1
|
<template>
|
2
2
|
<div>
|
3
|
-
<Button
|
3
|
+
<Button @click="startScan" class="bg-main button-small radius-extra button">
|
4
4
|
Check Tickets
|
5
5
|
</Button>
|
6
|
-
<
|
7
|
-
|
8
|
-
@
|
9
|
-
|
10
|
-
class="w-max-30r h-max-30r t-left pd-big bg-white radius-big"
|
11
|
-
>
|
12
|
-
<h3 class="mn-b-small">Scan QR Code</h3>
|
13
|
-
<div class="h-max">
|
14
|
-
<!-- Scanning will be handled by Capacitor, so we don't need a visual component here -->
|
15
|
-
</div>
|
16
|
-
</Popup>
|
6
|
+
<div v-if="isScanning" class="barcode-scanner-modal">
|
7
|
+
<!-- Add any UI elements for the scanner here -->
|
8
|
+
<Button @click="stopScan" class="stop-scan-button">Stop Scan</Button>
|
9
|
+
</div>
|
17
10
|
</div>
|
18
11
|
</template>
|
19
12
|
|
20
13
|
<script setup>
|
21
|
-
import { ref } from 'vue'
|
14
|
+
import { ref, onMounted, onUnmounted } from 'vue'
|
22
15
|
import { BarcodeScanner } from '@capacitor-mlkit/barcode-scanning'
|
23
|
-
import Popup from '@pf/src/components/Popup/Popup.vue'
|
24
16
|
import Button from '@pf/src/components/Button/Button.vue'
|
25
17
|
import * as tickets from '@pf/src/modules/events/store/tickets'
|
26
18
|
|
27
19
|
const emits = defineEmits(['qrcodecheck'])
|
28
|
-
const isPublicationPopup = ref(false)
|
29
20
|
const error = ref('')
|
21
|
+
const isScanning = ref(false)
|
30
22
|
|
31
|
-
|
32
|
-
|
33
|
-
|
23
|
+
onMounted(async () => {
|
24
|
+
const { supported } = await BarcodeScanner.isSupported()
|
25
|
+
if (!supported) {
|
26
|
+
error.value = 'Barcode scanning is not supported on this device'
|
27
|
+
}
|
28
|
+
})
|
34
29
|
|
35
|
-
|
36
|
-
|
37
|
-
}
|
30
|
+
onUnmounted(async () => {
|
31
|
+
await BarcodeScanner.removeAllListeners()
|
32
|
+
})
|
38
33
|
|
39
34
|
async function startScan() {
|
40
|
-
openPublicationPopup()
|
41
|
-
|
42
35
|
try {
|
43
|
-
await BarcodeScanner.
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
throw new Error('No barcode detected')
|
36
|
+
const { camera } = await BarcodeScanner.checkPermissions()
|
37
|
+
if (camera !== 'granted') {
|
38
|
+
const { camera: newStatus } = await BarcodeScanner.requestPermissions()
|
39
|
+
if (newStatus !== 'granted') {
|
40
|
+
throw new Error('Camera permission is required to scan barcodes')
|
41
|
+
}
|
50
42
|
}
|
43
|
+
|
44
|
+
document.querySelector('body')?.classList.add('barcode-scanner-active')
|
45
|
+
isScanning.value = true
|
46
|
+
|
47
|
+
await BarcodeScanner.addListener('barcodeScanned', async (result) => {
|
48
|
+
await processBarcode(result.barcode)
|
49
|
+
})
|
50
|
+
|
51
|
+
await BarcodeScanner.startScan()
|
51
52
|
} catch (e) {
|
52
53
|
error.value = e.message
|
53
54
|
alert(`Error: ${error.value}`)
|
54
|
-
} finally {
|
55
|
-
closePublicationPopup()
|
56
55
|
}
|
57
56
|
}
|
58
57
|
|
59
|
-
async function
|
58
|
+
async function stopScan() {
|
60
59
|
try {
|
61
|
-
|
62
|
-
|
60
|
+
document.querySelector('body')?.classList.remove('barcode-scanner-active')
|
61
|
+
isScanning.value = false
|
62
|
+
await BarcodeScanner.stopScan()
|
63
|
+
await BarcodeScanner.removeAllListeners()
|
64
|
+
} catch (e) {
|
65
|
+
error.value = e.message
|
66
|
+
alert(`Error stopping scan: ${error.value}`)
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
async function processBarcode(barcode) {
|
71
|
+
try {
|
72
|
+
if (!barcode) {
|
73
|
+
throw new Error('Troubles with barcode reading')
|
63
74
|
}
|
64
|
-
const response = await tickets.actions.update({ _id:
|
75
|
+
const response = await tickets.actions.update({ _id: barcode, status: 'used', check: true })
|
65
76
|
alert("Ticket checked. And it's all right!")
|
66
77
|
} catch (e) {
|
67
78
|
alert(`Ticket is not found, already used or deactivated!`)
|
68
79
|
} finally {
|
69
80
|
emits('qrcodecheck')
|
81
|
+
await stopScan()
|
70
82
|
}
|
71
83
|
}
|
72
84
|
</script>
|
73
85
|
|
74
86
|
<style scoped>
|
87
|
+
.barcode-scanner-modal {
|
88
|
+
position: fixed;
|
89
|
+
top: 0;
|
90
|
+
left: 0;
|
91
|
+
right: 0;
|
92
|
+
bottom: 0;
|
93
|
+
background: rgba(0, 0, 0, 0.8);
|
94
|
+
display: flex;
|
95
|
+
justify-content: center;
|
96
|
+
align-items: center;
|
97
|
+
}
|
98
|
+
|
99
|
+
.stop-scan-button {
|
100
|
+
position: absolute;
|
101
|
+
bottom: 20px;
|
102
|
+
left: 50%;
|
103
|
+
transform: translateX(-50%);
|
104
|
+
}
|
105
|
+
|
75
106
|
/* Existing styles can stay unchanged */
|
76
107
|
</style>
|