2024-09-20 09:58:53 +02:00
|
|
|
import appSettingService from '@/services/appSettingService'
|
2023-09-22 17:21:18 +02:00
|
|
|
import { defineStore } from 'pinia'
|
2024-09-20 09:58:53 +02:00
|
|
|
import { useNotifyStore } from '@/stores/notify'
|
2023-09-22 17:21:18 +02:00
|
|
|
|
|
|
|
export const useAppSettingsStore = defineStore({
|
2023-10-04 09:30:05 +02:00
|
|
|
id: 'appSettings',
|
2023-09-22 17:21:18 +02:00
|
|
|
|
2023-10-04 09:30:05 +02:00
|
|
|
state: () => {
|
2023-09-22 17:21:18 +02:00
|
|
|
return { ...window.appSettings }
|
|
|
|
},
|
|
|
|
|
2023-10-04 09:30:05 +02:00
|
|
|
actions: {
|
2024-09-20 09:58:53 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Fetches the appSetting collection from the backend
|
|
|
|
*/
|
|
|
|
async fetch() {
|
|
|
|
appSettingService.getAll({ returnError: true })
|
|
|
|
.then(response => {
|
|
|
|
response.data.forEach(setting => {
|
|
|
|
this[setting.key] = setting.value
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
useNotifyStore().alert({ text: trans('errors.data_cannot_be_refreshed_from_server') })
|
|
|
|
})
|
|
|
|
},
|
2023-10-04 09:30:05 +02:00
|
|
|
},
|
2023-09-22 17:21:18 +02:00
|
|
|
})
|