Client - minor refactor

This commit is contained in:
Sam
2021-08-11 22:21:26 +02:00
parent 72db7afe44
commit 3dc1e46329
20 changed files with 32 additions and 12 deletions

View File

@ -1,4 +1,5 @@
import { createStore } from 'vuex'
import { IRootState } from '@/store/modules/root/interfaces'
import root from '@/store/modules/root'

View File

@ -1,4 +1,5 @@
import { GetterTree } from 'vuex'
import { ROOT_STORE } from '@/store/constants'
import { IRootState, IRootGetters } from '@/store/modules/root/interfaces'

View File

@ -1,4 +1,5 @@
import { Module, ModuleTree } from 'vuex'
import { getters } from '@/store/modules/root/getters'
import { IRootState } from '@/store/modules/root/interfaces'
import { mutations } from '@/store/modules/root/mutations'

View File

@ -1,4 +1,5 @@
import { MutationTree } from 'vuex'
import { ROOT_STORE } from '@/store/constants'
import { IRootState } from '@/store/modules/root/interfaces'
import { TRootMutations } from '@/store/modules/root/types'

View File

@ -1,14 +1,15 @@
import { ActionContext, ActionTree } from 'vuex'
import { ROOT_STORE, USER_STORE } from '@/store/constants'
import { IRootState } from '@/store/modules/root/interfaces'
import {
ILoginOrRegisterData,
IUserActions,
IUserState,
} from '@/store/modules/user/interfaces'
import { IRootState } from '@/store/modules/root/interfaces'
import { handleError } from '@/utils'
import api from '@/api/defaultApi'
import authApi from '@/api/authApi'
import api from '@/api/defaultApi'
import router from '@/router'
export const actions: ActionTree<IUserState, IRootState> & IUserActions = {

View File

@ -2,11 +2,13 @@ export enum UserActions {
GET_USER_PROFILE = 'GET_USER_PROFILE',
LOGIN_OR_REGISTER = 'LOGIN_OR_REGISTER',
}
export enum UserGetters {
AUTH_TOKEN = 'AUTH_TOKEN',
AUTH_USER_PROFILE = 'AUTH_USER_PROFILE',
IS_AUTHENTICATED = 'IS_AUTHENTICATED',
}
export enum UserMutations {
UPDATE_AUTH_TOKEN = 'UPDATE_AUTH_TOKEN',
UPDATE_AUTH_USER_PROFILE = 'UPDATE_AUTH_USER_PROFILE',

View File

@ -1,4 +1,5 @@
import { GetterTree } from 'vuex'
import { USER_STORE } from '@/store/constants'
import { IRootState } from '@/store/modules/root/interfaces'
import { IUserGetters, IUserState } from '@/store/modules/user/interfaces'

View File

@ -1,4 +1,5 @@
import { Module } from 'vuex'
import { IRootState } from '@/store/modules/root/interfaces'
import { actions } from '@/store/modules/user/actions'
import { getters } from '@/store/modules/user/getters'

View File

@ -1,4 +1,5 @@
import { ActionContext } from 'vuex'
import { IFormData } from '@/interfaces'
import { USER_STORE } from '@/store/constants'
import { IRootState } from '@/store/modules/root/interfaces'
@ -36,15 +37,15 @@ export interface IUserState {
authUserProfile: IAuthUserProfile
}
export interface IUserGetters {
[USER_STORE.GETTERS.AUTH_TOKEN](state: IUserState): string | null
[USER_STORE.GETTERS.AUTH_USER_PROFILE](state: IUserState): IAuthUserProfile
[USER_STORE.GETTERS.IS_AUTHENTICATED](state: IUserState): boolean
}
export interface IUserActions {
[USER_STORE.ACTIONS.LOGIN_OR_REGISTER](
context: ActionContext<IUserState, IRootState>,
data: ILoginOrRegisterData
): void
}
export interface IUserGetters {
[USER_STORE.GETTERS.AUTH_TOKEN](state: IUserState): string | null
[USER_STORE.GETTERS.AUTH_USER_PROFILE](state: IUserState): IAuthUserProfile
[USER_STORE.GETTERS.IS_AUTHENTICATED](state: IUserState): boolean
}

View File

@ -1,7 +1,8 @@
import { MutationTree } from 'vuex'
import { TUserMutations } from '@/store/modules/user/types'
import { USER_STORE } from '@/store/constants'
import { IAuthUserProfile, IUserState } from '@/store/modules/user/interfaces'
import { TUserMutations } from '@/store/modules/user/types'
export const mutations: MutationTree<IUserState> & TUserMutations = {
[USER_STORE.MUTATIONS.UPDATE_AUTH_TOKEN](