diff --git a/src/components/AscGISMap.vue b/src/components/AscGISMap.vue index b32e32a..c9ab17d 100644 --- a/src/components/AscGISMap.vue +++ b/src/components/AscGISMap.vue @@ -4,9 +4,11 @@ import { loadModules } from 'esri-loader' import axios from 'axios' import { useCounterMixin } from '@/stores/mixin' import { useQuasar } from 'quasar' +import { usePrivacyStore } from '@/stores/privacy' const mixin = useCounterMixin() const { messageError } = mixin +const privacyStore = usePrivacyStore() // import type { LocationObject } from '@/interface/index/Main' const mapElement = ref(null) @@ -200,6 +202,16 @@ async function initializeMap() { const locationGranted = ref(false) // Function to request location permission const requestLocationPermission = () => { + // เช็คสิทธิ์ privacy ก่อนเข้าถึงแผนที่ + if (!privacyStore.isAccepted) { + $q.notify({ + type: 'warning', + message: 'กรุณายอมรับนโยบายคุ้มครองข้อมูลส่วนบุคคลก่อนใช้งานแผนที่', + position: 'top', + }) + return + } + if (!navigator.geolocation) { messageError( $q, @@ -261,7 +273,10 @@ defineExpose({ }) onMounted(async () => { - await initializeMap() + // เรียกแผนที่เฉพาะเมื่อยอมรับ privacy แล้ว + if (privacyStore.isAccepted) { + await initializeMap() + } }) diff --git a/src/components/PopupPrivacy.vue b/src/components/PopupPrivacy.vue index 0109ffd..1a77526 100644 --- a/src/components/PopupPrivacy.vue +++ b/src/components/PopupPrivacy.vue @@ -1,7 +1,12 @@ @@ -103,7 +122,6 @@ const toggleDetails = () => { dense class="absolute-top-right q-ma-sm" v-close-popup - @click="handleDecline" /> @@ -237,7 +255,6 @@ const toggleDetails = () => { unelevated no-caps class="action-btn" - @click="handleDecline" v-close-popup /> @@ -280,7 +297,7 @@ const toggleDetails = () => { } */ .list-style { - list-style-type: decimal; + list-style-type: thai; } .list-style-disc { diff --git a/src/composables/usePermissions.ts b/src/composables/usePermissions.ts new file mode 100644 index 0000000..ecf1ef3 --- /dev/null +++ b/src/composables/usePermissions.ts @@ -0,0 +1,52 @@ +import { useQuasar } from 'quasar' +import { usePrivacyStore } from '@/stores/privacy' + +export function usePermissions() { + const $q = useQuasar() + const privacyStore = usePrivacyStore() + + // const checkCameraPermission = (): boolean => { + // if (!privacyStore.isAccepted) { + // privacyStore.modalPrivacy = true + // $q.notify({ + // type: 'warning', + // message: 'กรุณายอมรับนโยบายคุ้มครองข้อมูลส่วนบุคคลก่อนใช้งานกล้อง', + // position: 'top', + // }) + // return false + // } + // return true + // } + + // const checkLocationPermission = (): boolean => { + // if (!privacyStore.isAccepted) { + // privacyStore.modalPrivacy = true + // $q.notify({ + // type: 'warning', + // message: 'กรุณายอมรับนโยบายคุ้มครองข้อมูลส่วนบุคคลก่อนใช้งานแผนที่', + // position: 'top', + // }) + // return false + // } + // return true + // } + + const checkPrivacyAccepted = (): boolean => { + if (!privacyStore.isAccepted) { + privacyStore.modalPrivacy = true + // $q.notify({ + // type: 'warning', + // message: 'กรุณายอมรับนโยบายคุ้มครองข้อมูลส่วนบุคคลก่อนใช้งาน', + // position: 'center', + // }) + return false + } + return true + } + + return { + // checkCameraPermission, + // checkLocationPermission, + checkPrivacyAccepted, + } +} diff --git a/src/stores/privacy.ts b/src/stores/privacy.ts new file mode 100644 index 0000000..ce2dc83 --- /dev/null +++ b/src/stores/privacy.ts @@ -0,0 +1,22 @@ +import { defineStore } from 'pinia' +import { ref } from 'vue' + +export const usePrivacyStore = defineStore('privacy', () => { + const modalPrivacy = ref(false) + const isAccepted = ref(false) + + const setAccepted = (value: boolean) => { + isAccepted.value = value + } + + const reset = () => { + isAccepted.value = false + } + + return { + modalPrivacy, + isAccepted, + setAccepted, + reset, + } +}) diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index a64742b..ae79034 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -1,5 +1,5 @@