diff --git a/fittrackee_client/src/store/modules/statistics/enums.ts b/fittrackee_client/src/store/modules/statistics/enums.ts index 532cf357..d6627a40 100644 --- a/fittrackee_client/src/store/modules/statistics/enums.ts +++ b/fittrackee_client/src/store/modules/statistics/enums.ts @@ -7,5 +7,6 @@ export enum StatisticsGetters { } export enum StatisticsMutations { + EMPTY_USER_STATS = 'EMPTY_USER_STATS', UPDATE_USER_STATS = 'UPDATE_USER_STATS', } diff --git a/fittrackee_client/src/store/modules/statistics/mutations.ts b/fittrackee_client/src/store/modules/statistics/mutations.ts index d91465ab..d797a9a3 100644 --- a/fittrackee_client/src/store/modules/statistics/mutations.ts +++ b/fittrackee_client/src/store/modules/statistics/mutations.ts @@ -15,4 +15,7 @@ export const mutations: MutationTree & TStatisticsMutations = ) { state.statistics = statistics }, + [STATS_STORE.MUTATIONS.EMPTY_USER_STATS](state: IStatisticsState) { + state.statistics = {} + }, } diff --git a/fittrackee_client/src/store/modules/statistics/types.ts b/fittrackee_client/src/store/modules/statistics/types.ts index 7da8ca8f..4b4f65d3 100644 --- a/fittrackee_client/src/store/modules/statistics/types.ts +++ b/fittrackee_client/src/store/modules/statistics/types.ts @@ -29,6 +29,7 @@ export type TStatisticsMutations = { state: S, statistics: TStatisticsFromApi ): void + [STATS_STORE.MUTATIONS.EMPTY_USER_STATS](state: S): void } export type TStatisticsStoreModule = Omit< diff --git a/fittrackee_client/src/store/modules/user/actions.ts b/fittrackee_client/src/store/modules/user/actions.ts index bf04feb4..1dcd893b 100644 --- a/fittrackee_client/src/store/modules/user/actions.ts +++ b/fittrackee_client/src/store/modules/user/actions.ts @@ -3,7 +3,13 @@ import { ActionContext, ActionTree } from 'vuex' import authApi from '@/api/authApi' import api from '@/api/defaultApi' import router from '@/router' -import { ROOT_STORE, SPORTS_STORE, USER_STORE } from '@/store/constants' +import { + ROOT_STORE, + SPORTS_STORE, + STATS_STORE, + USER_STORE, + WORKOUTS_STORE, +} from '@/store/constants' import { IRootState } from '@/store/modules/root/types' import { IUserActions, IUserState } from '@/store/modules/user/types' import { ILoginOrRegisterData } from '@/types/user' @@ -68,8 +74,10 @@ export const actions: ActionTree & IUserActions = { context: ActionContext ): void { localStorage.removeItem('authToken') - context.commit(USER_STORE.MUTATIONS.CLEAR_AUTH_USER_TOKEN) context.commit(ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES) + context.commit(STATS_STORE.MUTATIONS.EMPTY_USER_STATS) + context.commit(USER_STORE.MUTATIONS.CLEAR_AUTH_USER_TOKEN) + context.commit(WORKOUTS_STORE.MUTATIONS.EMPTY_WORKOUTS) router.push('/login') }, } diff --git a/fittrackee_client/src/store/modules/workouts/enums.ts b/fittrackee_client/src/store/modules/workouts/enums.ts index 563197fd..b86b12f7 100644 --- a/fittrackee_client/src/store/modules/workouts/enums.ts +++ b/fittrackee_client/src/store/modules/workouts/enums.ts @@ -9,6 +9,7 @@ export enum WorkoutsGetters { } export enum WorkoutsMutations { + EMPTY_WORKOUTS = 'EMPTY_WORKOUTS', SET_CALENDAR_WORKOUTS = 'SET_CALENDAR_WORKOUTS', SET_USER_WORKOUTS = 'SET_USER_WORKOUTS', } diff --git a/fittrackee_client/src/store/modules/workouts/mutations.ts b/fittrackee_client/src/store/modules/workouts/mutations.ts index 1c237178..65ef2574 100644 --- a/fittrackee_client/src/store/modules/workouts/mutations.ts +++ b/fittrackee_client/src/store/modules/workouts/mutations.ts @@ -20,4 +20,8 @@ export const mutations: MutationTree & TWorkoutsMutations = { ) { state.user_workouts = workouts }, + [WORKOUTS_STORE.MUTATIONS.EMPTY_WORKOUTS](state: IWorkoutsState) { + state.calendar_workouts = [] + state.user_workouts = [] + }, } diff --git a/fittrackee_client/src/store/modules/workouts/types.ts b/fittrackee_client/src/store/modules/workouts/types.ts index db3a8b91..25dad1a6 100644 --- a/fittrackee_client/src/store/modules/workouts/types.ts +++ b/fittrackee_client/src/store/modules/workouts/types.ts @@ -39,6 +39,7 @@ export type TWorkoutsMutations = { state: S, workouts: IWorkout[] ): void + [WORKOUTS_STORE.MUTATIONS.EMPTY_WORKOUTS](state: S): void } export type TWorkoutsStoreModule = Omit<