Client - refactor store interfaces (move w/ types)

This commit is contained in:
Sam
2021-08-22 20:38:22 +02:00
parent 3b8ac44433
commit cac9607489
23 changed files with 124 additions and 127 deletions

View File

@ -2,7 +2,7 @@ import { ActionContext, ActionTree } from 'vuex'
import authApi from '@/api/authApi'
import { ROOT_STORE } from '@/store/constants'
import { IRootActions, IRootState } from '@/store/modules/root/interfaces'
import { IRootActions, IRootState } from '@/store/modules/root/types'
import { handleError } from '@/utils'
export const actions: ActionTree<IRootState, IRootState> & IRootActions = {

View File

@ -1,7 +1,7 @@
import { GetterTree } from 'vuex'
import { ROOT_STORE } from '@/store/constants'
import { IRootState, IRootGetters } from '@/store/modules/root/interfaces'
import { IRootGetters, IRootState } from '@/store/modules/root/types'
export const getters: GetterTree<IRootState, IRootState> & IRootGetters = {
[ROOT_STORE.GETTERS.APP_CONFIG]: (state: IRootState) => {

View File

@ -2,9 +2,9 @@ import { Module, ModuleTree } from 'vuex'
import { actions } from '@/store/modules/root/actions'
import { getters } from '@/store/modules/root/getters'
import { IRootState } from '@/store/modules/root/interfaces'
import { mutations } from '@/store/modules/root/mutations'
import { state } from '@/store/modules/root/state.ts'
import { IRootState } from '@/store/modules/root/types'
import statsModule from '@/store/modules/statistics'
import userModule from '@/store/modules/user'

View File

@ -1,27 +0,0 @@
import { ActionContext } from 'vuex'
import { ROOT_STORE } from '@/store/constants'
import { IAppConfig, IApplication } from '@/types/application'
export interface IRootState {
root: boolean
language: string
errorMessages: string | string[] | null
application: IApplication
appLoading: boolean
}
export interface IRootActions {
[ROOT_STORE.ACTIONS.GET_APPLICATION_CONFIG](
context: ActionContext<IRootState, IRootState>
): void
}
export interface IRootGetters {
[ROOT_STORE.GETTERS.APP_CONFIG](state: IRootState): IAppConfig
[ROOT_STORE.GETTERS.APP_LOADING](state: IRootState): boolean
[ROOT_STORE.GETTERS.ERROR_MESSAGES](
state: IRootState
): string | string[] | null
[ROOT_STORE.GETTERS.LANGUAGE](state: IRootState): string
}

View File

@ -1,8 +1,7 @@
import { MutationTree } from 'vuex'
import { ROOT_STORE } from '@/store/constants'
import { IRootState } from '@/store/modules/root/interfaces'
import { TRootMutations } from '@/store/modules/root/types'
import { IRootState, TRootMutations } from '@/store/modules/root/types'
import { IAppConfig } from '@/types/application'
export const mutations: MutationTree<IRootState> & TRootMutations = {

View File

@ -1,4 +1,4 @@
import { IRootState } from '@/store/modules/root/interfaces'
import { IRootState } from '@/store/modules/root/types'
import { IApplication } from '@/types/application'
export const state: IRootState = {

View File

@ -1,11 +1,38 @@
import { Store as VuexStore, CommitOptions, DispatchOptions } from 'vuex'
import {
ActionContext,
CommitOptions,
DispatchOptions,
Store as VuexStore,
} from 'vuex'
import { ROOT_STORE } from '@/store/constants'
import {
IRootActions,
IRootGetters,
IRootState,
} from '@/store/modules/root/interfaces'
import { IAppConfig, IApplication } from '@/types/application'
export interface IRootState {
root: boolean
language: string
errorMessages: string | string[] | null
application: IApplication
appLoading: boolean
}
export interface IRootActions {
[ROOT_STORE.ACTIONS.GET_APPLICATION_CONFIG](
context: ActionContext<IRootState, IRootState>
): void
}
export interface IRootGetters {
[ROOT_STORE.GETTERS.APP_CONFIG](state: IRootState): IAppConfig
[ROOT_STORE.GETTERS.APP_LOADING](state: IRootState): boolean
[ROOT_STORE.GETTERS.ERROR_MESSAGES](
state: IRootState
): string | string[] | null
[ROOT_STORE.GETTERS.LANGUAGE](state: IRootState): string
}
export type TRootMutations<S = IRootState> = {
[ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES](state: S): void