Client - update user typing

This commit is contained in:
Sam 2022-03-13 09:50:09 +01:00
parent ac6aceadfd
commit 0b1d99aa7a
16 changed files with 41 additions and 37 deletions

View File

@ -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<IUserProfile> = computed(
const authUser: ComputedRef<IAuthUserProfile> = computed(
() => store.getters[AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE]
)
const users: ComputedRef<IUserProfile[]> = computed(

View File

@ -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<IUserProfile>,
type: Object as PropType<IAuthUserProfile>,
required: true,
},
chartParams: {
@ -169,7 +169,7 @@
}
function getApiParams(
chartParams: IStatisticsDateParams,
user: IUserProfile
user: IAuthUserProfile
): IStatisticsParams {
return {
from: format(chartParams.start, 'yyyy-MM-dd'),

View File

@ -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<IUserProfile> = computed(
const authUser: ComputedRef<IAuthUserProfile> = computed(
() => store.getters[AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE]
)
const isAuthenticated: ComputedRef<boolean> = computed(

View File

@ -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<IUserProfile> = computed(
const authUser: ComputedRef<IAuthUserProfile> = computed(
() => store.getters[AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE]
)
const registrationDate = computed(() =>

View File

@ -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<IAuthUserState> & TAuthUserMutations = {
[AUTH_USER_STORE.MUTATIONS.CLEAR_AUTH_USER_TOKEN](state: IAuthUserState) {
state.authToken = null
state.authUserProfile = <IUserProfile>{}
state.authUserProfile = <IAuthUserProfile>{}
},
[AUTH_USER_STORE.MUTATIONS.UPDATE_AUTH_TOKEN](
state: IAuthUserState,
@ -20,7 +20,7 @@ export const mutations: MutationTree<IAuthUserState> & TAuthUserMutations = {
},
[AUTH_USER_STORE.MUTATIONS.UPDATE_AUTH_USER_PROFILE](
state: IAuthUserState,
authUserProfile: IUserProfile
authUserProfile: IAuthUserProfile
) {
state.authUserProfile = authUserProfile
},

View File

@ -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: <IUserProfile>{},
authUserProfile: <IAuthUserProfile>{},
isSuccess: false,
loading: false,
}

View File

@ -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<S = IAuthUserState> = {
): 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,

View File

@ -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
}

View File

@ -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<IUserProfile> = computed(
const authUser: ComputedRef<IAuthUserProfile> = computed(
() => store.getters[AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE]
)
const sports: ComputedRef<ISport[]> = computed(

View File

@ -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<IUserProfile> = computed(
const authUser: ComputedRef<IAuthUserProfile> = computed(
() => store.getters[AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE]
)
const sports: ComputedRef<ISport[]> = computed(() =>

View File

@ -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<IUserProfile> = computed(
const authUser: ComputedRef<IAuthUserProfile> = computed(
() => store.getters[AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE]
)
const isAuthenticated: ComputedRef<boolean> = computed(

View File

@ -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<IUserProfile> = computed(
const authUser: ComputedRef<IAuthUserProfile> = computed(
() => store.getters[AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE]
)
</script>

View File

@ -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<ISport[]> = computed(
() => store.getters[SPORTS_STORE.GETTERS.SPORTS]
)
const authUser: ComputedRef<IUserProfile> = computed(
const authUser: ComputedRef<IAuthUserProfile> = computed(
() => store.getters[AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE]
)
const workoutData: ComputedRef<IWorkoutData> = computed(

View File

@ -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<IUserProfile> = computed(
const authUser: ComputedRef<IAuthUserProfile> = computed(
() => store.getters[AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE]
)
const sports: ComputedRef<ISport[]> = computed(

View File

@ -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<IWorkoutData> = computed(
() => store.getters[WORKOUTS_STORE.GETTERS.WORKOUT_DATA]
)
const authUser: ComputedRef<IUserProfile> = computed(
const authUser: ComputedRef<IAuthUserProfile> = computed(
() => store.getters[AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE]
)
const sports: ComputedRef<ISport[]> = computed(

View File

@ -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<IUserProfile> = computed(
const authUser: ComputedRef<IAuthUserProfile> = computed(
() => store.getters[AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE]
)
const sports: ComputedRef<ISport[]> = computed(