Client - refactor store

This commit is contained in:
Sam
2021-08-11 18:33:02 +02:00
parent f8b020940a
commit 6b848228ca
16 changed files with 104 additions and 42 deletions

View File

@ -0,0 +1,3 @@
export enum RootMutations {
UPDATE_LANG = 'UPDATE_LANG',
}

View File

@ -0,0 +1,17 @@
import { Module, ModuleTree } from 'vuex'
import { IRootState } from '@/store/modules/root/interfaces'
import { mutations } from '@/store/modules/root/mutations'
import { state } from '@/store/modules/root/state.ts'
import userModule from '@/store/modules/user'
const modules: ModuleTree<IRootState> = {
userModule,
}
const root: Module<IRootState, IRootState> = {
state,
mutations,
modules,
}
export default root

View File

@ -0,0 +1,5 @@
export interface IRootState {
root: boolean
language: string
errorMessage: string | null
}

View File

@ -0,0 +1,10 @@
import { MutationTree } from 'vuex'
import { ROOT_STORE } from '@/store/constants'
import { IRootState } from '@/store/modules/root/interfaces'
import { TRootMutations } from '@/store/modules/root/types'
export const mutations: MutationTree<IRootState> & TRootMutations = {
[ROOT_STORE.MUTATIONS.UPDATE_LANG](state: IRootState, language: string) {
state.language = language
},
}

View File

@ -0,0 +1,7 @@
import { IRootState } from '@/store/modules/root/interfaces'
export const state: IRootState = {
root: true,
language: 'en',
errorMessage: null,
}

View File

@ -0,0 +1,6 @@
import { ROOT_STORE } from '@/store/constants'
import { IRootState } from '@/store/modules/root/interfaces'
export type TRootMutations<S = IRootState> = {
[ROOT_STORE.MUTATIONS.UPDATE_LANG](state: S, language: string): void
}