Client - add application administration
This commit is contained in:
@ -1,8 +1,10 @@
|
||||
import { ActionContext, ActionTree } from 'vuex'
|
||||
|
||||
import authApi from '@/api/authApi'
|
||||
import router from '@/router'
|
||||
import { ROOT_STORE } from '@/store/constants'
|
||||
import { IRootActions, IRootState } from '@/store/modules/root/types'
|
||||
import { TAppConfigForm } from '@/types/application'
|
||||
import { handleError } from '@/utils'
|
||||
|
||||
export const actions: ActionTree<IRootState, IRootState> & IRootActions = {
|
||||
@ -46,4 +48,24 @@ export const actions: ActionTree<IRootState, IRootState> & IRootActions = {
|
||||
})
|
||||
.catch((error) => handleError(context, error))
|
||||
},
|
||||
[ROOT_STORE.ACTIONS.UPDATE_APPLICATION_CONFIG](
|
||||
context: ActionContext<IRootState, IRootState>,
|
||||
payload: TAppConfigForm
|
||||
): void {
|
||||
context.commit(ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES)
|
||||
authApi
|
||||
.patch('config', payload)
|
||||
.then((res) => {
|
||||
if (res.data.status === 'success') {
|
||||
context.commit(
|
||||
ROOT_STORE.MUTATIONS.UPDATE_APPLICATION_CONFIG,
|
||||
res.data.data
|
||||
)
|
||||
router.push('/admin/application')
|
||||
} else {
|
||||
handleError(context, null)
|
||||
}
|
||||
})
|
||||
.catch((error) => handleError(context, error))
|
||||
},
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
export enum RootActions {
|
||||
GET_APPLICATION_CONFIG = 'GET_APPLICATION_CONFIG',
|
||||
GET_APPLICATION_STATS = 'GET_APPLICATION_STATS',
|
||||
UPDATE_APPLICATION_CONFIG = 'UPDATE_APPLICATION_CONFIG',
|
||||
}
|
||||
|
||||
export enum RootGetters {
|
||||
|
@ -2,7 +2,7 @@ import { MutationTree } from 'vuex'
|
||||
|
||||
import { ROOT_STORE } from '@/store/constants'
|
||||
import { IRootState, TRootMutations } from '@/store/modules/root/types'
|
||||
import { IAppConfig, IAppStatistics } from '@/types/application'
|
||||
import { TAppConfig, IAppStatistics } from '@/types/application'
|
||||
import { localeFromLanguage } from '@/utils/locales'
|
||||
|
||||
export const mutations: MutationTree<IRootState> & TRootMutations = {
|
||||
@ -17,7 +17,7 @@ export const mutations: MutationTree<IRootState> & TRootMutations = {
|
||||
},
|
||||
[ROOT_STORE.MUTATIONS.UPDATE_APPLICATION_CONFIG](
|
||||
state: IRootState,
|
||||
config: IAppConfig
|
||||
config: TAppConfig
|
||||
) {
|
||||
state.application.config = config
|
||||
},
|
||||
|
@ -7,7 +7,12 @@ import {
|
||||
} from 'vuex'
|
||||
|
||||
import { ROOT_STORE } from '@/store/constants'
|
||||
import { IAppConfig, IApplication, IAppStatistics } from '@/types/application'
|
||||
import {
|
||||
TAppConfig,
|
||||
IApplication,
|
||||
IAppStatistics,
|
||||
TAppConfigForm,
|
||||
} from '@/types/application'
|
||||
|
||||
export interface IRootState {
|
||||
root: boolean
|
||||
@ -25,10 +30,14 @@ export interface IRootActions {
|
||||
[ROOT_STORE.ACTIONS.GET_APPLICATION_STATS](
|
||||
context: ActionContext<IRootState, IRootState>
|
||||
): void
|
||||
[ROOT_STORE.ACTIONS.UPDATE_APPLICATION_CONFIG](
|
||||
context: ActionContext<IRootState, IRootState>,
|
||||
payload: TAppConfigForm
|
||||
): void
|
||||
}
|
||||
|
||||
export interface IRootGetters {
|
||||
[ROOT_STORE.GETTERS.APP_CONFIG](state: IRootState): IAppConfig
|
||||
[ROOT_STORE.GETTERS.APP_CONFIG](state: IRootState): TAppConfig
|
||||
|
||||
[ROOT_STORE.GETTERS.APP_LOADING](state: IRootState): boolean
|
||||
|
||||
@ -51,7 +60,7 @@ export type TRootMutations<S = IRootState> = {
|
||||
): void
|
||||
[ROOT_STORE.MUTATIONS.UPDATE_APPLICATION_CONFIG](
|
||||
state: S,
|
||||
config: IAppConfig
|
||||
config: TAppConfig
|
||||
): void
|
||||
[ROOT_STORE.MUTATIONS.UPDATE_APPLICATION_LOADING](
|
||||
state: S,
|
||||
|
Reference in New Issue
Block a user