Merge branch 'develop' of https://github.com/Frappet/bma-ehr-checkin into develop
All checks were successful
Build & Deploy on Dev / build (push) Successful in 3m3s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 3m3s
This commit is contained in:
commit
a45c1cae90
8 changed files with 2028 additions and 333 deletions
|
|
@ -5,19 +5,14 @@ import axios from 'axios'
|
|||
import { useCounterMixin } from '@/stores/mixin'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { usePrivacyStore } from '@/stores/privacy'
|
||||
import { useLocationValidation } from '@/composables/useLocationValidation'
|
||||
|
||||
const mixin = useCounterMixin()
|
||||
const { messageError } = mixin
|
||||
const privacyStore = usePrivacyStore()
|
||||
|
||||
// import type { LocationObject } from '@/interface/index/Main'
|
||||
const mapElement = ref<HTMLElement | null>(null)
|
||||
const emit = defineEmits(['update:location', 'locationStatus', 'mockDetected'])
|
||||
const emit = defineEmits(['update:location'])
|
||||
const $q = useQuasar()
|
||||
|
||||
const { validateLocation, showMockWarning } = useLocationValidation()
|
||||
|
||||
function updateLocation(latitude: number, longitude: number, namePOI: string) {
|
||||
// ส่ง event ไปยัง parent component เพื่ออัพเดทค่า props
|
||||
emit('update:location', latitude, longitude, namePOI)
|
||||
|
|
@ -226,30 +221,8 @@ const requestLocationPermission = () => {
|
|||
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
async (position) => {
|
||||
// Validate location first
|
||||
const validationResult = validateLocation(position)
|
||||
|
||||
// Always emit mockDetected event (regardless of result)
|
||||
if (validationResult.isMockDetected) {
|
||||
showMockWarning(validationResult)
|
||||
emit('mockDetected', validationResult)
|
||||
}
|
||||
|
||||
// Check for critical errors (invalid coordinates) that prevent showing location
|
||||
const hasCriticalErrors = validationResult.errors.some(error =>
|
||||
error.includes('พิกัดตำแหน่งไม่ถูกต้อง')
|
||||
)
|
||||
|
||||
if (hasCriticalErrors) {
|
||||
locationGranted.value = false
|
||||
emit('locationStatus', false)
|
||||
messageError($q, '', validationResult.errors[0])
|
||||
return
|
||||
}
|
||||
|
||||
// Permission granted based on mock detection
|
||||
locationGranted.value = !validationResult.isMockDetected
|
||||
emit('locationStatus', !validationResult.isMockDetected)
|
||||
// Permission granted
|
||||
locationGranted.value = true
|
||||
|
||||
const { latitude, longitude } = position.coords
|
||||
// console.log('Current position:', latitude, longitude)
|
||||
|
|
@ -267,7 +240,6 @@ const requestLocationPermission = () => {
|
|||
(error) => {
|
||||
// Permission denied
|
||||
locationGranted.value = false
|
||||
emit('locationStatus', false)
|
||||
|
||||
switch (error.code) {
|
||||
case error.PERMISSION_DENIED:
|
||||
|
|
@ -298,7 +270,6 @@ const requestLocationPermission = () => {
|
|||
|
||||
defineExpose({
|
||||
requestLocationPermission,
|
||||
locationGranted,
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ function onClose() {
|
|||
|
||||
<template>
|
||||
<q-dialog v-model="modal" persistent>
|
||||
<q-card style="width: 700px; max-width: 80vw">
|
||||
<q-card style="width: 700px; max-width: 90vw">
|
||||
<q-form greedy @submit.prevent @validation-success="onSubmit">
|
||||
<DialogHeader :tittle="title" :close="onClose" />
|
||||
<q-separator />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue