2021-08-15 12:30:39 +02:00
|
|
|
import { ActionContext, ActionTree } from 'vuex'
|
|
|
|
|
|
|
|
import { ROOT_STORE } from '@/store/constants'
|
|
|
|
import { IRootActions, IRootState } from '@/store/modules/root/interfaces'
|
|
|
|
import authApi from '@/api/authApi'
|
|
|
|
import { handleError } from '@/utils'
|
|
|
|
|
|
|
|
export const actions: ActionTree<IRootState, IRootState> & IRootActions = {
|
|
|
|
[ROOT_STORE.ACTIONS.GET_APPLICATION_CONFIG](
|
|
|
|
context: ActionContext<IRootState, IRootState>
|
|
|
|
): void {
|
|
|
|
context.commit(ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES)
|
2021-08-15 16:40:11 +02:00
|
|
|
context.commit(ROOT_STORE.MUTATIONS.UPDATE_APPLICATION_LOADING, true)
|
2021-08-15 12:30:39 +02:00
|
|
|
authApi
|
|
|
|
.get('config')
|
|
|
|
.then((res) => {
|
|
|
|
if (res.data.status === 'success') {
|
|
|
|
context.commit(
|
|
|
|
ROOT_STORE.MUTATIONS.UPDATE_APPLICATION_CONFIG,
|
|
|
|
res.data.data
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
handleError(context, null)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch((error) => handleError(context, error))
|
2021-08-15 16:40:11 +02:00
|
|
|
.finally(() =>
|
|
|
|
context.commit(ROOT_STORE.MUTATIONS.UPDATE_APPLICATION_LOADING, false)
|
|
|
|
)
|
2021-08-15 12:30:39 +02:00
|
|
|
},
|
|
|
|
}
|