From 0b1d99aa7ab6a3361b812d377844a8dc3137afbe Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 13 Mar 2022 09:50:09 +0100 Subject: [PATCH] Client - update user typing --- .../src/components/Administration/AdminUsers.vue | 4 ++-- .../src/components/Common/StatsChart/index.vue | 6 +++--- fittrackee_client/src/components/NavBar.vue | 4 ++-- .../src/components/User/ProfileDisplay/UserInfos.vue | 4 ++-- .../src/store/modules/authUser/mutations.ts | 6 +++--- fittrackee_client/src/store/modules/authUser/state.ts | 4 ++-- fittrackee_client/src/store/modules/authUser/types.ts | 8 ++++---- fittrackee_client/src/types/user.ts | 10 +++++++--- fittrackee_client/src/views/Dashboard.vue | 4 ++-- fittrackee_client/src/views/StatisticsView.vue | 4 ++-- fittrackee_client/src/views/user/EmailUpdateView.vue | 4 ++-- fittrackee_client/src/views/user/ProfileView.vue | 4 ++-- fittrackee_client/src/views/workouts/AddWorkout.vue | 4 ++-- fittrackee_client/src/views/workouts/EditWorkout.vue | 4 ++-- fittrackee_client/src/views/workouts/Workout.vue | 4 ++-- fittrackee_client/src/views/workouts/WorkoutsView.vue | 4 ++-- 16 files changed, 41 insertions(+), 37 deletions(-) diff --git a/fittrackee_client/src/components/Administration/AdminUsers.vue b/fittrackee_client/src/components/Administration/AdminUsers.vue index d8f765c4..d78309e7 100644 --- a/fittrackee_client/src/components/Administration/AdminUsers.vue +++ b/fittrackee_client/src/components/Administration/AdminUsers.vue @@ -133,7 +133,7 @@ import UserPicture from '@/components/User/UserPicture.vue' import { AUTH_USER_STORE, ROOT_STORE, USERS_STORE } from '@/store/constants' import { IPagination, TPaginationPayload } from '@/types/api' - import { IUserProfile } from '@/types/user' + import { IAuthUserProfile, IUserProfile } from '@/types/user' import { useStore } from '@/use/useStore' import { getQuery, sortList } from '@/utils/api' import { getDateWithTZ } from '@/utils/dates' @@ -152,7 +152,7 @@ let query: TPaginationPayload = reactive( getQuery(route.query, orderByList, defaultOrderBy) ) - const authUser: ComputedRef = computed( + const authUser: ComputedRef = computed( () => store.getters[AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE] ) const users: ComputedRef = computed( diff --git a/fittrackee_client/src/components/Common/StatsChart/index.vue b/fittrackee_client/src/components/Common/StatsChart/index.vue index 96330c62..dcab80b8 100644 --- a/fittrackee_client/src/components/Common/StatsChart/index.vue +++ b/fittrackee_client/src/components/Common/StatsChart/index.vue @@ -96,7 +96,7 @@ TStatisticsFromApi, IStatisticsParams, } from '@/types/statistics' - import { IUserProfile } from '@/types/user' + import { IAuthUserProfile } from '@/types/user' import { useStore } from '@/use/useStore' import { formatStats } from '@/utils/statistics' @@ -111,7 +111,7 @@ required: true, }, user: { - type: Object as PropType, + type: Object as PropType, required: true, }, chartParams: { @@ -169,7 +169,7 @@ } function getApiParams( chartParams: IStatisticsDateParams, - user: IUserProfile + user: IAuthUserProfile ): IStatisticsParams { return { from: format(chartParams.start, 'yyyy-MM-dd'), diff --git a/fittrackee_client/src/components/NavBar.vue b/fittrackee_client/src/components/NavBar.vue index d685b7eb..11375129 100644 --- a/fittrackee_client/src/components/NavBar.vue +++ b/fittrackee_client/src/components/NavBar.vue @@ -84,7 +84,7 @@ import UserPicture from '@/components/User/UserPicture.vue' import { AUTH_USER_STORE, ROOT_STORE } from '@/store/constants' import { IDropdownOption } from '@/types/forms' - import { IUserProfile } from '@/types/user' + import { IAuthUserProfile } from '@/types/user' import { useStore } from '@/use/useStore' import { availableLanguages } from '@/utils/locales' @@ -93,7 +93,7 @@ const { locale } = useI18n() const store = useStore() - const authUser: ComputedRef = computed( + const authUser: ComputedRef = computed( () => store.getters[AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE] ) const isAuthenticated: ComputedRef = computed( diff --git a/fittrackee_client/src/components/User/ProfileDisplay/UserInfos.vue b/fittrackee_client/src/components/User/ProfileDisplay/UserInfos.vue index 85f8fbc4..bbb165c8 100644 --- a/fittrackee_client/src/components/User/ProfileDisplay/UserInfos.vue +++ b/fittrackee_client/src/components/User/ProfileDisplay/UserInfos.vue @@ -48,7 +48,7 @@ import { ComputedRef, Ref, computed, ref, toRefs, withDefaults } from 'vue' import { AUTH_USER_STORE, USERS_STORE } from '@/store/constants' - import { IUserProfile } from '@/types/user' + import { IAuthUserProfile, IUserProfile } from '@/types/user' import { useStore } from '@/use/useStore' interface Props { @@ -62,7 +62,7 @@ const store = useStore() const { user, fromAdmin } = toRefs(props) - const authUser: ComputedRef = computed( + const authUser: ComputedRef = computed( () => store.getters[AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE] ) const registrationDate = computed(() => diff --git a/fittrackee_client/src/store/modules/authUser/mutations.ts b/fittrackee_client/src/store/modules/authUser/mutations.ts index c3d05a40..811911f9 100644 --- a/fittrackee_client/src/store/modules/authUser/mutations.ts +++ b/fittrackee_client/src/store/modules/authUser/mutations.ts @@ -5,12 +5,12 @@ import { IAuthUserState, TAuthUserMutations, } from '@/store/modules/authUser/types' -import { IUserProfile } from '@/types/user' +import { IAuthUserProfile } from '@/types/user' export const mutations: MutationTree & TAuthUserMutations = { [AUTH_USER_STORE.MUTATIONS.CLEAR_AUTH_USER_TOKEN](state: IAuthUserState) { state.authToken = null - state.authUserProfile = {} + state.authUserProfile = {} }, [AUTH_USER_STORE.MUTATIONS.UPDATE_AUTH_TOKEN]( state: IAuthUserState, @@ -20,7 +20,7 @@ export const mutations: MutationTree & TAuthUserMutations = { }, [AUTH_USER_STORE.MUTATIONS.UPDATE_AUTH_USER_PROFILE]( state: IAuthUserState, - authUserProfile: IUserProfile + authUserProfile: IAuthUserProfile ) { state.authUserProfile = authUserProfile }, diff --git a/fittrackee_client/src/store/modules/authUser/state.ts b/fittrackee_client/src/store/modules/authUser/state.ts index 226101cc..c41e12d7 100644 --- a/fittrackee_client/src/store/modules/authUser/state.ts +++ b/fittrackee_client/src/store/modules/authUser/state.ts @@ -1,9 +1,9 @@ import { IAuthUserState } from '@/store/modules/authUser/types' -import { IUserProfile } from '@/types/user' +import { IAuthUserProfile } from '@/types/user' export const authUserState: IAuthUserState = { authToken: null, - authUserProfile: {}, + authUserProfile: {}, isSuccess: false, loading: false, } diff --git a/fittrackee_client/src/store/modules/authUser/types.ts b/fittrackee_client/src/store/modules/authUser/types.ts index 9847d7b4..494818a0 100644 --- a/fittrackee_client/src/store/modules/authUser/types.ts +++ b/fittrackee_client/src/store/modules/authUser/types.ts @@ -8,7 +8,7 @@ import { import { AUTH_USER_STORE } from '@/store/constants' import { IRootState } from '@/store/modules/root/types' import { - IUserProfile, + IAuthUserProfile, ILoginOrRegisterData, IUserDeletionPayload, IUserPasswordPayload, @@ -23,7 +23,7 @@ import { export interface IAuthUserState { authToken: string | null - authUserProfile: IUserProfile + authUserProfile: IAuthUserProfile isSuccess: boolean loading: boolean } @@ -106,7 +106,7 @@ export interface IAuthUserGetters { [AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE]( state: IAuthUserState - ): IUserProfile + ): IAuthUserProfile [AUTH_USER_STORE.GETTERS.IS_ADMIN](state: IAuthUserState): boolean @@ -125,7 +125,7 @@ export type TAuthUserMutations = { ): void [AUTH_USER_STORE.MUTATIONS.UPDATE_AUTH_USER_PROFILE]( state: S, - authUserProfile: IUserProfile + authUserProfile: IAuthUserProfile ): void [AUTH_USER_STORE.MUTATIONS.UPDATE_IS_SUCCESS]( state: S, diff --git a/fittrackee_client/src/types/user.ts b/fittrackee_client/src/types/user.ts index 7cab2bca..e6a8948a 100644 --- a/fittrackee_client/src/types/user.ts +++ b/fittrackee_client/src/types/user.ts @@ -8,9 +8,8 @@ export interface IUserProfile { birth_date: string | null created_at: string email: string + email_to_confirm?: string first_name: string | null - imperial_units: boolean - language: string | null last_name: string | null location: string | null nb_sports: number @@ -18,10 +17,15 @@ export interface IUserProfile { picture: string | boolean records: IRecord[] sports_list: number[] - timezone: string total_distance: number total_duration: string username: string +} + +export interface IAuthUserProfile extends IUserProfile { + imperial_units: boolean + language: string | null + timezone: string weekm: boolean } diff --git a/fittrackee_client/src/views/Dashboard.vue b/fittrackee_client/src/views/Dashboard.vue index 9f627c5c..184a87fb 100644 --- a/fittrackee_client/src/views/Dashboard.vue +++ b/fittrackee_client/src/views/Dashboard.vue @@ -82,12 +82,12 @@ import UserStatsCards from '@/components/Dashboard/UserStatsCards/index.vue' import { AUTH_USER_STORE, SPORTS_STORE } from '@/store/constants' import { ISport } from '@/types/sports' - import { IUserProfile } from '@/types/user' + import { IAuthUserProfile } from '@/types/user' import { useStore } from '@/use/useStore' const store = useStore() - const authUser: ComputedRef = computed( + const authUser: ComputedRef = computed( () => store.getters[AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE] ) const sports: ComputedRef = computed( diff --git a/fittrackee_client/src/views/StatisticsView.vue b/fittrackee_client/src/views/StatisticsView.vue index a66e1c3c..d2ef598d 100644 --- a/fittrackee_client/src/views/StatisticsView.vue +++ b/fittrackee_client/src/views/StatisticsView.vue @@ -23,12 +23,12 @@ import NoWorkouts from '@/components/Workouts/NoWorkouts.vue' import { AUTH_USER_STORE, SPORTS_STORE } from '@/store/constants' import { ISport } from '@/types/sports' - import { IUserProfile } from '@/types/user' + import { IAuthUserProfile } from '@/types/user' import { useStore } from '@/use/useStore' const store = useStore() - const authUser: ComputedRef = computed( + const authUser: ComputedRef = computed( () => store.getters[AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE] ) const sports: ComputedRef = computed(() => diff --git a/fittrackee_client/src/views/user/EmailUpdateView.vue b/fittrackee_client/src/views/user/EmailUpdateView.vue index bc331a84..85b6f27f 100644 --- a/fittrackee_client/src/views/user/EmailUpdateView.vue +++ b/fittrackee_client/src/views/user/EmailUpdateView.vue @@ -23,14 +23,14 @@ import ErrorImg from '@/components/Common/Images/ErrorImg.vue' import { AUTH_USER_STORE, ROOT_STORE } from '@/store/constants' - import { IUserProfile } from '@/types/user' + import { IAuthUserProfile } from '@/types/user' import { useStore } from '@/use/useStore' const route = useRoute() const router = useRouter() const store = useStore() - const authUser: ComputedRef = computed( + const authUser: ComputedRef = computed( () => store.getters[AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE] ) const isAuthenticated: ComputedRef = computed( diff --git a/fittrackee_client/src/views/user/ProfileView.vue b/fittrackee_client/src/views/user/ProfileView.vue index 560feeff..a94df80a 100644 --- a/fittrackee_client/src/views/user/ProfileView.vue +++ b/fittrackee_client/src/views/user/ProfileView.vue @@ -9,12 +9,12 @@ import { ComputedRef, computed } from 'vue' import { AUTH_USER_STORE } from '@/store/constants' - import { IUserProfile } from '@/types/user' + import { IAuthUserProfile } from '@/types/user' import { useStore } from '@/use/useStore' const store = useStore() - const authUser: ComputedRef = computed( + const authUser: ComputedRef = computed( () => store.getters[AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE] ) diff --git a/fittrackee_client/src/views/workouts/AddWorkout.vue b/fittrackee_client/src/views/workouts/AddWorkout.vue index b7407d20..4c7e886c 100644 --- a/fittrackee_client/src/views/workouts/AddWorkout.vue +++ b/fittrackee_client/src/views/workouts/AddWorkout.vue @@ -21,7 +21,7 @@ WORKOUTS_STORE, } from '@/store/constants' import { ISport } from '@/types/sports' - import { IUserProfile } from '@/types/user' + import { IAuthUserProfile } from '@/types/user' import { IWorkoutData } from '@/types/workouts' import { useStore } from '@/use/useStore' @@ -30,7 +30,7 @@ const sports: ComputedRef = computed( () => store.getters[SPORTS_STORE.GETTERS.SPORTS] ) - const authUser: ComputedRef = computed( + const authUser: ComputedRef = computed( () => store.getters[AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE] ) const workoutData: ComputedRef = computed( diff --git a/fittrackee_client/src/views/workouts/EditWorkout.vue b/fittrackee_client/src/views/workouts/EditWorkout.vue index 34f0f2f2..428335a0 100644 --- a/fittrackee_client/src/views/workouts/EditWorkout.vue +++ b/fittrackee_client/src/views/workouts/EditWorkout.vue @@ -22,14 +22,14 @@ WORKOUTS_STORE, } from '@/store/constants' import { ISport } from '@/types/sports' - import { IUserProfile } from '@/types/user' + import { IAuthUserProfile } from '@/types/user' import { IWorkoutData } from '@/types/workouts' import { useStore } from '@/use/useStore' const route = useRoute() const store = useStore() - const authUser: ComputedRef = computed( + const authUser: ComputedRef = computed( () => store.getters[AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE] ) const sports: ComputedRef = computed( diff --git a/fittrackee_client/src/views/workouts/Workout.vue b/fittrackee_client/src/views/workouts/Workout.vue index 9f4c54cf..70491307 100644 --- a/fittrackee_client/src/views/workouts/Workout.vue +++ b/fittrackee_client/src/views/workouts/Workout.vue @@ -62,7 +62,7 @@ WORKOUTS_STORE, } from '@/store/constants' import { ISport } from '@/types/sports' - import { IUserProfile } from '@/types/user' + import { IAuthUserProfile } from '@/types/user' import { IWorkoutData, IWorkoutPayload, TCoordinates } from '@/types/workouts' import { useStore } from '@/use/useStore' @@ -78,7 +78,7 @@ const workoutData: ComputedRef = computed( () => store.getters[WORKOUTS_STORE.GETTERS.WORKOUT_DATA] ) - const authUser: ComputedRef = computed( + const authUser: ComputedRef = computed( () => store.getters[AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE] ) const sports: ComputedRef = computed( diff --git a/fittrackee_client/src/views/workouts/WorkoutsView.vue b/fittrackee_client/src/views/workouts/WorkoutsView.vue index ba891a81..9626021a 100644 --- a/fittrackee_client/src/views/workouts/WorkoutsView.vue +++ b/fittrackee_client/src/views/workouts/WorkoutsView.vue @@ -34,14 +34,14 @@ import WorkoutsList from '@/components/Workouts/WorkoutsList.vue' import { AUTH_USER_STORE, SPORTS_STORE } from '@/store/constants' import { ISport, ITranslatedSport } from '@/types/sports' - import { IUserProfile } from '@/types/user' + import { IAuthUserProfile } from '@/types/user' import { useStore } from '@/use/useStore' import { translateSports } from '@/utils/sports' const { t } = useI18n() const store = useStore() - const authUser: ComputedRef = computed( + const authUser: ComputedRef = computed( () => store.getters[AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE] ) const sports: ComputedRef = computed(