Client - refactor store
This commit is contained in:
3
fittrackee_client/src/store/modules/root/enums.ts
Normal file
3
fittrackee_client/src/store/modules/root/enums.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export enum RootMutations {
|
||||
UPDATE_LANG = 'UPDATE_LANG',
|
||||
}
|
17
fittrackee_client/src/store/modules/root/index.ts
Normal file
17
fittrackee_client/src/store/modules/root/index.ts
Normal 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
|
5
fittrackee_client/src/store/modules/root/interfaces.ts
Normal file
5
fittrackee_client/src/store/modules/root/interfaces.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export interface IRootState {
|
||||
root: boolean
|
||||
language: string
|
||||
errorMessage: string | null
|
||||
}
|
10
fittrackee_client/src/store/modules/root/mutations.ts
Normal file
10
fittrackee_client/src/store/modules/root/mutations.ts
Normal 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
|
||||
},
|
||||
}
|
7
fittrackee_client/src/store/modules/root/state.ts
Normal file
7
fittrackee_client/src/store/modules/root/state.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { IRootState } from '@/store/modules/root/interfaces'
|
||||
|
||||
export const state: IRootState = {
|
||||
root: true,
|
||||
language: 'en',
|
||||
errorMessage: null,
|
||||
}
|
6
fittrackee_client/src/store/modules/root/types.ts
Normal file
6
fittrackee_client/src/store/modules/root/types.ts
Normal 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
|
||||
}
|
Reference in New Issue
Block a user