generalDataStore.ts
4 months ago
index.ts
1 year ago
integrationsStore.ts
4 months ago
modalStore.ts
1 year ago
pagesStore.ts
5 months ago
generalDataStore.ts
47 lines
| 1 | import { defineStore } from 'pinia'; |
| 2 | import { computed, ref } from 'vue'; |
| 3 | |
| 4 | import { STORE_PERSISTENT_KEYS } from '@/types/enums'; |
| 5 | import type { ReachData } from '@/types/models'; |
| 6 | import { snakeToCamelObj } from '@/utils/caseConversion'; |
| 7 | |
| 8 | export const useGeneralDataStore = defineStore( |
| 9 | 'generalDataStore', |
| 10 | () => { |
| 11 | const data = ref<ReachData>(snakeToCamelObj(hostinger_reach_reach_data) as ReachData); |
| 12 | const totalFormPages = computed(() => data.value.totalFormPages); |
| 13 | const siteUrl = computed(() => data.value.siteUrl); |
| 14 | const isHostingerUser = computed(() => data.value.isHostingerUser); |
| 15 | const ajaxUrl = computed(() => data.value.ajaxUrl); |
| 16 | const nonce = computed(() => data.value.nonce); |
| 17 | const pluginUrl = computed(() => data.value.pluginUrl); |
| 18 | const translations = computed(() => data.value.translations); |
| 19 | const isConnected = computed(() => data.value.isConnected); |
| 20 | const isStaging = computed(() => data.value.isStaging); |
| 21 | const domain = computed(() => data.value.domain); |
| 22 | const rawDomain = computed(() => data.value.rawDomain.replace(/\s+/g, '')); |
| 23 | const hasValidResourceId = computed(() => data.value.hasValidResourceId); |
| 24 | const resourceId = computed(() => data.value.resourceId); |
| 25 | |
| 26 | return { |
| 27 | data, |
| 28 | siteUrl, |
| 29 | ajaxUrl, |
| 30 | nonce, |
| 31 | isConnected, |
| 32 | isHostingerUser, |
| 33 | totalFormPages, |
| 34 | isStaging, |
| 35 | pluginUrl, |
| 36 | translations, |
| 37 | domain, |
| 38 | hasValidResourceId, |
| 39 | resourceId, |
| 40 | rawDomain |
| 41 | }; |
| 42 | }, |
| 43 | { |
| 44 | persist: { key: STORE_PERSISTENT_KEYS.GENERAL_DATA_STORE } |
| 45 | } |
| 46 | ); |
| 47 |