diff --git a/fittrackee_client/src/store/index.ts b/fittrackee_client/src/store/index.ts index 52a6d08d..0de44100 100644 --- a/fittrackee_client/src/store/index.ts +++ b/fittrackee_client/src/store/index.ts @@ -1,7 +1,7 @@ import { createStore } from 'vuex' import root from '@/store/modules/root' -import { IRootState } from '@/store/modules/root/interfaces' +import { IRootState } from '@/store/modules/root/types' const store = createStore(root) diff --git a/fittrackee_client/src/store/modules/root/actions.ts b/fittrackee_client/src/store/modules/root/actions.ts index 5a98bdfc..5e4bccfb 100644 --- a/fittrackee_client/src/store/modules/root/actions.ts +++ b/fittrackee_client/src/store/modules/root/actions.ts @@ -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 & IRootActions = { diff --git a/fittrackee_client/src/store/modules/root/getters.ts b/fittrackee_client/src/store/modules/root/getters.ts index bd540fd8..7808b5da 100644 --- a/fittrackee_client/src/store/modules/root/getters.ts +++ b/fittrackee_client/src/store/modules/root/getters.ts @@ -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 & IRootGetters = { [ROOT_STORE.GETTERS.APP_CONFIG]: (state: IRootState) => { diff --git a/fittrackee_client/src/store/modules/root/index.ts b/fittrackee_client/src/store/modules/root/index.ts index 64a9529d..5087d7c7 100644 --- a/fittrackee_client/src/store/modules/root/index.ts +++ b/fittrackee_client/src/store/modules/root/index.ts @@ -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' diff --git a/fittrackee_client/src/store/modules/root/interfaces.ts b/fittrackee_client/src/store/modules/root/interfaces.ts deleted file mode 100644 index a703eb3d..00000000 --- a/fittrackee_client/src/store/modules/root/interfaces.ts +++ /dev/null @@ -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 - ): 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 -} diff --git a/fittrackee_client/src/store/modules/root/mutations.ts b/fittrackee_client/src/store/modules/root/mutations.ts index f722d6b4..a9491ba1 100644 --- a/fittrackee_client/src/store/modules/root/mutations.ts +++ b/fittrackee_client/src/store/modules/root/mutations.ts @@ -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 & TRootMutations = { diff --git a/fittrackee_client/src/store/modules/root/state.ts b/fittrackee_client/src/store/modules/root/state.ts index fb402c9c..98f462ea 100644 --- a/fittrackee_client/src/store/modules/root/state.ts +++ b/fittrackee_client/src/store/modules/root/state.ts @@ -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 = { diff --git a/fittrackee_client/src/store/modules/root/types.ts b/fittrackee_client/src/store/modules/root/types.ts index 41531055..e44e7b88 100644 --- a/fittrackee_client/src/store/modules/root/types.ts +++ b/fittrackee_client/src/store/modules/root/types.ts @@ -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 + ): 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 = { [ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES](state: S): void diff --git a/fittrackee_client/src/store/modules/statistics/actions.ts b/fittrackee_client/src/store/modules/statistics/actions.ts index 017e1338..56bff819 100644 --- a/fittrackee_client/src/store/modules/statistics/actions.ts +++ b/fittrackee_client/src/store/modules/statistics/actions.ts @@ -2,11 +2,11 @@ import { ActionContext, ActionTree } from 'vuex' import authApi from '@/api/authApi' import { STATS_STORE, ROOT_STORE } from '@/store/constants' -import { IRootState } from '@/store/modules/root/interfaces' +import { IRootState } from '@/store/modules/root/types' import { IStatisticsActions, IStatisticsState, -} from '@/store/modules/statistics/interfaces' +} from '@/store/modules/statistics/types' import { IUserStatisticsPayload } from '@/types/statistics' import { handleError } from '@/utils' diff --git a/fittrackee_client/src/store/modules/statistics/getters.ts b/fittrackee_client/src/store/modules/statistics/getters.ts index 3d9de8fd..1305d1bd 100644 --- a/fittrackee_client/src/store/modules/statistics/getters.ts +++ b/fittrackee_client/src/store/modules/statistics/getters.ts @@ -1,11 +1,11 @@ import { GetterTree } from 'vuex' import { STATS_STORE } from '@/store/constants' -import { IRootState } from '@/store/modules/root/interfaces' +import { IRootState } from '@/store/modules/root/types' import { IStatisticsGetters, IStatisticsState, -} from '@/store/modules/statistics/interfaces' +} from '@/store/modules/statistics/types' export const getters: GetterTree & IStatisticsGetters = { diff --git a/fittrackee_client/src/store/modules/statistics/index.ts b/fittrackee_client/src/store/modules/statistics/index.ts index 2db02f94..f5522ea2 100644 --- a/fittrackee_client/src/store/modules/statistics/index.ts +++ b/fittrackee_client/src/store/modules/statistics/index.ts @@ -1,11 +1,11 @@ import { Module } from 'vuex' -import { IRootState } from '@/store/modules/root/interfaces' +import { IRootState } from '@/store/modules/root/types' import { actions } from '@/store/modules/statistics/actions' import { getters } from '@/store/modules/statistics/getters' -import { IStatisticsState } from '@/store/modules/statistics/interfaces' import { mutations } from '@/store/modules/statistics/mutations' import { statisticsState } from '@/store/modules/statistics/state' +import { IStatisticsState } from '@/store/modules/statistics/types' const statistics: Module = { state: statisticsState, diff --git a/fittrackee_client/src/store/modules/statistics/interfaces.ts b/fittrackee_client/src/store/modules/statistics/interfaces.ts deleted file mode 100644 index 5d2fba35..00000000 --- a/fittrackee_client/src/store/modules/statistics/interfaces.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { ActionContext } from 'vuex' - -import { STATS_STORE } from '@/store/constants' -import { IRootState } from '@/store/modules/root/interfaces' -import { IUserStatisticsPayload, TStatisticsFromApi } from '@/types/statistics' - -export interface IStatisticsState { - statistics: TStatisticsFromApi -} - -export interface IStatisticsActions { - [STATS_STORE.ACTIONS.GET_USER_STATS]( - context: ActionContext, - payload: IUserStatisticsPayload - ): void -} - -export interface IStatisticsGetters { - [STATS_STORE.GETTERS.USER_STATS](state: IStatisticsState): TStatisticsFromApi -} diff --git a/fittrackee_client/src/store/modules/statistics/mutations.ts b/fittrackee_client/src/store/modules/statistics/mutations.ts index d42555d0..d91465ab 100644 --- a/fittrackee_client/src/store/modules/statistics/mutations.ts +++ b/fittrackee_client/src/store/modules/statistics/mutations.ts @@ -1,8 +1,10 @@ import { MutationTree } from 'vuex' import { STATS_STORE } from '@/store/constants' -import { IStatisticsState } from '@/store/modules/statistics/interfaces' -import { TStatisticsMutations } from '@/store/modules/statistics/types' +import { + IStatisticsState, + TStatisticsMutations, +} from '@/store/modules/statistics/types' import { TStatisticsFromApi } from '@/types/statistics' export const mutations: MutationTree & TStatisticsMutations = diff --git a/fittrackee_client/src/store/modules/statistics/state.ts b/fittrackee_client/src/store/modules/statistics/state.ts index d7beb3fb..88bb9615 100644 --- a/fittrackee_client/src/store/modules/statistics/state.ts +++ b/fittrackee_client/src/store/modules/statistics/state.ts @@ -1,4 +1,4 @@ -import { IStatisticsState } from '@/store/modules/statistics/interfaces' +import { IStatisticsState } from '@/store/modules/statistics/types' import { TStatisticsFromApi } from '@/types/statistics' export const statisticsState: IStatisticsState = { diff --git a/fittrackee_client/src/store/modules/statistics/types.ts b/fittrackee_client/src/store/modules/statistics/types.ts index 15cab644..7da8ca8f 100644 --- a/fittrackee_client/src/store/modules/statistics/types.ts +++ b/fittrackee_client/src/store/modules/statistics/types.ts @@ -1,12 +1,28 @@ -import { Store as VuexStore, CommitOptions, DispatchOptions } from 'vuex' +import { + ActionContext, + CommitOptions, + DispatchOptions, + Store as VuexStore, +} from 'vuex' import { STATS_STORE } from '@/store/constants' -import { - IStatisticsState, - IStatisticsActions, - IStatisticsGetters, -} from '@/store/modules/statistics/interfaces' -import { TStatisticsFromApi } from '@/types/statistics' +import { IRootState } from '@/store/modules/root/types' +import { IUserStatisticsPayload, TStatisticsFromApi } from '@/types/statistics' + +export interface IStatisticsState { + statistics: TStatisticsFromApi +} + +export interface IStatisticsActions { + [STATS_STORE.ACTIONS.GET_USER_STATS]( + context: ActionContext, + payload: IUserStatisticsPayload + ): void +} + +export interface IStatisticsGetters { + [STATS_STORE.GETTERS.USER_STATS](state: IStatisticsState): TStatisticsFromApi +} export type TStatisticsMutations = { [STATS_STORE.MUTATIONS.UPDATE_USER_STATS]( diff --git a/fittrackee_client/src/store/modules/user/actions.ts b/fittrackee_client/src/store/modules/user/actions.ts index 4a369147..74650ecf 100644 --- a/fittrackee_client/src/store/modules/user/actions.ts +++ b/fittrackee_client/src/store/modules/user/actions.ts @@ -4,8 +4,8 @@ import authApi from '@/api/authApi' import api from '@/api/defaultApi' import router from '@/router' import { ROOT_STORE, USER_STORE } from '@/store/constants' -import { IRootState } from '@/store/modules/root/interfaces' -import { IUserActions, IUserState } from '@/store/modules/user/interfaces' +import { IRootState } from '@/store/modules/root/types' +import { IUserActions, IUserState } from '@/store/modules/user/types' import { ILoginOrRegisterData } from '@/types/user' import { handleError } from '@/utils' diff --git a/fittrackee_client/src/store/modules/user/getters.ts b/fittrackee_client/src/store/modules/user/getters.ts index b0f8568c..8efa8d78 100644 --- a/fittrackee_client/src/store/modules/user/getters.ts +++ b/fittrackee_client/src/store/modules/user/getters.ts @@ -1,8 +1,8 @@ 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' +import { IRootState } from '@/store/modules/root/types' +import { IUserGetters, IUserState } from '@/store/modules/user/types' export const getters: GetterTree & IUserGetters = { [USER_STORE.GETTERS.AUTH_TOKEN]: (state: IUserState) => { diff --git a/fittrackee_client/src/store/modules/user/index.ts b/fittrackee_client/src/store/modules/user/index.ts index 610adb63..e744478b 100644 --- a/fittrackee_client/src/store/modules/user/index.ts +++ b/fittrackee_client/src/store/modules/user/index.ts @@ -1,11 +1,11 @@ import { Module } from 'vuex' -import { IRootState } from '@/store/modules/root/interfaces' +import { IRootState } from '@/store/modules/root/types' import { actions } from '@/store/modules/user/actions' import { getters } from '@/store/modules/user/getters' -import { IUserState } from '@/store/modules/user/interfaces' import { mutations } from '@/store/modules/user/mutations' import { userState } from '@/store/modules/user/state.ts' +import { IUserState } from '@/store/modules/user/types' const user: Module = { state: userState, diff --git a/fittrackee_client/src/store/modules/user/interfaces.ts b/fittrackee_client/src/store/modules/user/interfaces.ts deleted file mode 100644 index c1f64e73..00000000 --- a/fittrackee_client/src/store/modules/user/interfaces.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { ActionContext } from 'vuex' - -import { USER_STORE } from '@/store/constants' -import { IRootState } from '@/store/modules/root/interfaces' -import { IAuthUserProfile, ILoginOrRegisterData } from '@/types/user' - -export interface IUserState { - authToken: string | null - authUserProfile: IAuthUserProfile -} - -export interface IUserActions { - [USER_STORE.ACTIONS.CHECK_AUTH_USER]( - context: ActionContext - ): void - [USER_STORE.ACTIONS.GET_USER_PROFILE]( - context: ActionContext - ): void - [USER_STORE.ACTIONS.LOGIN_OR_REGISTER]( - context: ActionContext, - data: ILoginOrRegisterData - ): void - [USER_STORE.ACTIONS.LOGOUT]( - context: ActionContext - ): 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 -} diff --git a/fittrackee_client/src/store/modules/user/mutations.ts b/fittrackee_client/src/store/modules/user/mutations.ts index cb6b9524..7928e56d 100644 --- a/fittrackee_client/src/store/modules/user/mutations.ts +++ b/fittrackee_client/src/store/modules/user/mutations.ts @@ -1,8 +1,7 @@ import { MutationTree } from 'vuex' import { USER_STORE } from '@/store/constants' -import { IUserState } from '@/store/modules/user/interfaces' -import { TUserMutations } from '@/store/modules/user/types' +import { IUserState, TUserMutations } from '@/store/modules/user/types' import { IAuthUserProfile } from '@/types/user' export const mutations: MutationTree & TUserMutations = { diff --git a/fittrackee_client/src/store/modules/user/state.ts b/fittrackee_client/src/store/modules/user/state.ts index 2c0abb09..293019c7 100644 --- a/fittrackee_client/src/store/modules/user/state.ts +++ b/fittrackee_client/src/store/modules/user/state.ts @@ -1,4 +1,4 @@ -import { IUserState } from '@/store/modules/user/interfaces' +import { IUserState } from '@/store/modules/user/types' import { IAuthUserProfile } from '@/types/user' export const userState: IUserState = { diff --git a/fittrackee_client/src/store/modules/user/types.ts b/fittrackee_client/src/store/modules/user/types.ts index 682ec78d..a2eaff5e 100644 --- a/fittrackee_client/src/store/modules/user/types.ts +++ b/fittrackee_client/src/store/modules/user/types.ts @@ -1,12 +1,45 @@ -import { Store as VuexStore, CommitOptions, DispatchOptions } from 'vuex' +import { + ActionContext, + CommitOptions, + DispatchOptions, + Store as VuexStore, +} from 'vuex' import { USER_STORE } from '@/store/constants' -import { - IUserActions, - IUserGetters, - IUserState, -} from '@/store/modules/user/interfaces' -import { IAuthUserProfile } from '@/types/user' +import { IRootState } from '@/store/modules/root/types' +import { IAuthUserProfile, ILoginOrRegisterData } from '@/types/user' + +export interface IUserState { + authToken: string | null + authUserProfile: IAuthUserProfile +} + +export interface IUserActions { + [USER_STORE.ACTIONS.CHECK_AUTH_USER]( + context: ActionContext + ): void + + [USER_STORE.ACTIONS.GET_USER_PROFILE]( + context: ActionContext + ): void + + [USER_STORE.ACTIONS.LOGIN_OR_REGISTER]( + context: ActionContext, + data: ILoginOrRegisterData + ): void + + [USER_STORE.ACTIONS.LOGOUT]( + context: ActionContext + ): 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 +} export type TUserMutations = { [USER_STORE.MUTATIONS.CLEAR_AUTH_USER_TOKEN](state: S): void diff --git a/fittrackee_client/src/utils/index.ts b/fittrackee_client/src/utils/index.ts index 3bdff2b1..abdbfc61 100644 --- a/fittrackee_client/src/utils/index.ts +++ b/fittrackee_client/src/utils/index.ts @@ -2,9 +2,9 @@ import { AxiosError } from 'axios' import { ActionContext } from 'vuex' import { ROOT_STORE } from '@/store/constants' -import { IRootState } from '@/store/modules/root/interfaces' -import { IStatisticsState } from '@/store/modules/statistics/interfaces' -import { IUserState } from '@/store/modules/user/interfaces' +import { IRootState } from '@/store/modules/root/types' +import { IStatisticsState } from '@/store/modules/statistics/types' +import { IUserState } from '@/store/modules/user/types' export const getApiUrl = (): string => { return process.env.NODE_ENV === 'production'