Client - refactor

This commit is contained in:
Sam 2021-10-30 12:01:55 +02:00
parent b695d665d2
commit 1911b03db5
34 changed files with 73 additions and 73 deletions

View File

@ -68,7 +68,7 @@
TStatisticsFromApi,
IStatisticsParams,
} from '@/types/statistics'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
import { useStore } from '@/use/useStore'
import { formatStats } from '@/utils/statistics'
@ -83,7 +83,7 @@
required: true,
},
user: {
type: Object as PropType<IAuthUserProfile>,
type: Object as PropType<IUserProfile>,
required: true,
},
chartParams: {
@ -140,7 +140,7 @@
}
function getApiParams(
chartParams: IStatisticsDateParams,
user: IAuthUserProfile
user: IUserProfile
): IStatisticsParams {
return {
from: format(chartParams.start, 'yyyy-MM-dd'),

View File

@ -44,7 +44,7 @@
import NoWorkouts from '@/components/Workouts/NoWorkouts.vue'
import { WORKOUTS_STORE } from '@/store/constants'
import { ISport } from '@/types/sports'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
import { IWorkout } from '@/types/workouts'
import { useStore } from '@/use/useStore'
@ -60,7 +60,7 @@
required: true,
},
user: {
type: Object as PropType<IAuthUserProfile>,
type: Object as PropType<IUserProfile>,
required: true,
},
},

View File

@ -37,7 +37,7 @@
import CalendarHeader from '@/components/Dashboard/UserCalendar/CalendarHeader.vue'
import { WORKOUTS_STORE } from '@/store/constants'
import { ISport } from '@/types/sports'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
import { IWorkout, IWorkoutsPayload } from '@/types/workouts'
import { useStore } from '@/use/useStore'
import { getCalendarStartAndEnd } from '@/utils/dates'
@ -55,7 +55,7 @@
required: true,
},
user: {
type: Object as PropType<IAuthUserProfile>,
type: Object as PropType<IUserProfile>,
required: true,
},
},

View File

@ -21,7 +21,7 @@
import StatChart from '@/components/Common/StatsChart/index.vue'
import { ISport } from '@/types/sports'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
export default defineComponent({
name: 'UserMonthStats',
@ -34,7 +34,7 @@
required: true,
},
user: {
type: Object as PropType<IAuthUserProfile>,
type: Object as PropType<IUserProfile>,
required: true,
},
},

View File

@ -24,7 +24,7 @@
import RecordsCard from '@/components/Dashboard/UserRecords/RecordsCard.vue'
import { ISport } from '@/types/sports'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
import { getRecordsBySports } from '@/utils/records'
import { translateSports } from '@/utils/sports'
@ -39,7 +39,7 @@
required: true,
},
user: {
type: Object as PropType<IAuthUserProfile>,
type: Object as PropType<IUserProfile>,
required: true,
},
},

View File

@ -28,7 +28,7 @@
import { useI18n } from 'vue-i18n'
import StatCard from '@/components/Common/StatCard.vue'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
export default defineComponent({
name: 'UserStatsCards',
@ -37,7 +37,7 @@
},
props: {
user: {
type: Object as PropType<IAuthUserProfile>,
type: Object as PropType<IUserProfile>,
required: true,
},
},

View File

@ -84,7 +84,7 @@
import UserPicture from '@/components/User/UserPicture.vue'
import { ROOT_STORE, USER_STORE } from '@/store/constants'
import { IDropdownOption } from '@/types/forms'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
import { useStore } from '@/use/useStore'
import { getApiUrl } from '@/utils'
@ -101,7 +101,7 @@
const availableLanguages = availableLocales.map((l) => {
return { label: l.toUpperCase(), value: l }
})
const authUser: ComputedRef<IAuthUserProfile> = computed(
const authUser: ComputedRef<IUserProfile> = computed(
() => store.getters[USER_STORE.GETTERS.AUTH_USER_PROFILE]
)
const isAuthenticated: ComputedRef<boolean> = computed(

View File

@ -36,7 +36,7 @@
import SportsMenu from '@/components/Statistics/StatsSportsMenu.vue'
import { ISport, ITranslatedSport } from '@/types/sports'
import { IStatisticsDateParams } from '@/types/statistics'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
import { translateSports } from '@/utils/sports'
import { getStatsDateParams, updateChartParams } from '@/utils/statistics'
@ -53,7 +53,7 @@
required: true,
},
user: {
type: Object as PropType<IAuthUserProfile>,
type: Object as PropType<IUserProfile>,
required: true,
},
},

View File

@ -31,7 +31,7 @@
import { PropType, computed, defineComponent } from 'vue'
import UserPicture from '@/components/User/UserPicture.vue'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
import { getApiUrl } from '@/utils'
export default defineComponent({
@ -41,7 +41,7 @@
},
props: {
user: {
type: Object as PropType<IAuthUserProfile>,
type: Object as PropType<IUserProfile>,
required: true,
},
},

View File

@ -29,13 +29,13 @@
import { format } from 'date-fns'
import { PropType, computed, defineComponent } from 'vue'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
export default defineComponent({
name: 'UserInfos',
props: {
user: {
type: Object as PropType<IAuthUserProfile>,
type: Object as PropType<IUserProfile>,
required: true,
},
},

View File

@ -20,13 +20,13 @@
<script lang="ts">
import { PropType, computed, defineComponent } from 'vue'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
export default defineComponent({
name: 'UserPreferences',
props: {
user: {
type: Object as PropType<IAuthUserProfile>,
type: Object as PropType<IUserProfile>,
required: true,
},
},

View File

@ -13,7 +13,7 @@
import UserHeader from '@/components/User/ProfileDisplay/UserHeader.vue'
import UserProfileTabs from '@/components/User/UserProfileTabs.vue'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
export default defineComponent({
name: 'ProfileDisplay',
@ -23,7 +23,7 @@
},
props: {
user: {
type: Object as PropType<IAuthUserProfile>,
type: Object as PropType<IUserProfile>,
required: true,
},
tab: {

View File

@ -107,14 +107,14 @@
} from 'vue'
import { ROOT_STORE, USER_STORE } from '@/store/constants'
import { IAuthUserProfile, IUserPayload } from '@/types/user'
import { IUserProfile, IUserPayload } from '@/types/user'
import { useStore } from '@/use/useStore'
export default defineComponent({
name: 'UserInfosEdition',
props: {
user: {
type: Object as PropType<IAuthUserProfile>,
type: Object as PropType<IUserProfile>,
required: true,
},
},
@ -148,7 +148,7 @@
}
})
function updateUserForm(user: IAuthUserProfile) {
function updateUserForm(user: IUserProfile) {
userForm.first_name = user.first_name ? user.first_name : ''
userForm.last_name = user.last_name ? user.last_name : ''
userForm.birth_date = user.birth_date

View File

@ -40,7 +40,7 @@
import UserPicture from '@/components/User/UserPicture.vue'
import { ROOT_STORE, USER_STORE } from '@/store/constants'
import { TAppConfig } from '@/types/application'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
import { useStore } from '@/use/useStore'
import { getReadableFileSize } from '@/utils/files'
@ -51,7 +51,7 @@
},
props: {
user: {
type: Object as PropType<IAuthUserProfile>,
type: Object as PropType<IUserProfile>,
required: true,
},
},

View File

@ -63,14 +63,14 @@
import { useI18n } from 'vue-i18n'
import { ROOT_STORE, USER_STORE } from '@/store/constants'
import { IAuthUserProfile, IUserPreferencesPayload } from '@/types/user'
import { IUserProfile, IUserPreferencesPayload } from '@/types/user'
import { useStore } from '@/use/useStore'
export default defineComponent({
name: 'UserPreferencesEdition',
props: {
user: {
type: Object as PropType<IAuthUserProfile>,
type: Object as PropType<IUserProfile>,
required: true,
},
},
@ -108,7 +108,7 @@
}
})
function updateUserForm(user: IAuthUserProfile) {
function updateUserForm(user: IUserProfile) {
userForm.language = user.language ? user.language : 'en'
userForm.timezone = user.timezone ? user.timezone : 'Europe/Paris'
userForm.weekm = user.weekm ? user.weekm : false

View File

@ -22,7 +22,7 @@
import UserProfileTabs from '@/components/User/UserProfileTabs.vue'
import { USER_STORE } from '@/store/constants'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
import { useStore } from '@/use/useStore'
export default defineComponent({
@ -32,7 +32,7 @@
},
props: {
user: {
type: Object as PropType<IAuthUserProfile>,
type: Object as PropType<IUserProfile>,
required: true,
},
tab: {

View File

@ -15,14 +15,14 @@
<script lang="ts">
import { PropType, computed, defineComponent } from 'vue'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
import { getApiUrl } from '@/utils'
export default defineComponent({
name: 'UserPicture',
props: {
user: {
type: Object as PropType<IAuthUserProfile>,
type: Object as PropType<IUserProfile>,
required: true,
},
},

View File

@ -82,7 +82,7 @@
import StaticMap from '@/components/Common/StaticMap.vue'
import { ROOT_STORE } from '@/store/constants'
import { ISport } from '@/types/sports'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
import { IWorkout } from '@/types/workouts'
import { useStore } from '@/use/useStore'
import { getApiUrl } from '@/utils'
@ -99,7 +99,7 @@
required: false,
},
user: {
type: Object as PropType<IAuthUserProfile>,
type: Object as PropType<IUserProfile>,
required: true,
},
sport: {

View File

@ -42,7 +42,7 @@
import { LineChart, useLineChart } from 'vue-chart-3'
import { useI18n } from 'vue-i18n'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
import {
IWorkoutChartData,
IWorkoutData,
@ -57,7 +57,7 @@
},
props: {
authUser: {
type: Object as PropType<IAuthUserProfile>,
type: Object as PropType<IUserProfile>,
required: true,
},
workoutData: {

View File

@ -43,7 +43,7 @@
import WorkoutMap from '@/components/Workout/WorkoutDetail/WorkoutMap.vue'
import { WORKOUTS_STORE } from '@/store/constants'
import { ISport } from '@/types/sports'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
import {
IWorkout,
IWorkoutData,
@ -63,7 +63,7 @@
},
props: {
authUser: {
type: Object as PropType<IAuthUserProfile>,
type: Object as PropType<IUserProfile>,
required: true,
},
displaySegment: {

View File

@ -222,7 +222,7 @@
import { ROOT_STORE, WORKOUTS_STORE } from '@/store/constants'
import { TAppConfig } from '@/types/application'
import { ISport } from '@/types/sports'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
import { IWorkout, IWorkoutForm } from '@/types/workouts'
import { useStore } from '@/use/useStore'
import { formatWorkoutDate, getDateWithTZ } from '@/utils/dates'
@ -233,7 +233,7 @@
name: 'WorkoutEdition',
props: {
authUser: {
type: Object as PropType<IAuthUserProfile>,
type: Object as PropType<IUserProfile>,
required: true,
},
isCreation: {

View File

@ -139,14 +139,14 @@
import { useI18n } from 'vue-i18n'
import { ISport } from '@/types/sports'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
import { translateSports } from '@/utils/sports'
export default defineComponent({
name: 'WorkoutsFilters',
props: {
authUser: {
type: Object as PropType<IAuthUserProfile>,
type: Object as PropType<IUserProfile>,
required: true,
},
sports: {

View File

@ -118,7 +118,7 @@
import NoWorkouts from '@/components/Workouts/NoWorkouts.vue'
import { WORKOUTS_STORE } from '@/store/constants'
import { ITranslatedSport } from '@/types/sports'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
import { IWorkout } from '@/types/workouts'
import { useStore } from '@/use/useStore'
import { getDateWithTZ } from '@/utils/dates'
@ -135,7 +135,7 @@
required: true,
},
user: {
type: Object as PropType<IAuthUserProfile>,
type: Object as PropType<IUserProfile>,
required: true,
},
sports: {

View File

@ -2,12 +2,12 @@ import { MutationTree } from 'vuex'
import { USER_STORE } from '@/store/constants'
import { IUserState, TUserMutations } from '@/store/modules/user/types'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
export const mutations: MutationTree<IUserState> & TUserMutations = {
[USER_STORE.MUTATIONS.CLEAR_AUTH_USER_TOKEN](state: IUserState) {
state.authToken = null
state.authUserProfile = <IAuthUserProfile>{}
state.authUserProfile = <IUserProfile>{}
},
[USER_STORE.MUTATIONS.UPDATE_AUTH_TOKEN](
state: IUserState,
@ -17,7 +17,7 @@ export const mutations: MutationTree<IUserState> & TUserMutations = {
},
[USER_STORE.MUTATIONS.UPDATE_AUTH_USER_PROFILE](
state: IUserState,
authUserProfile: IAuthUserProfile
authUserProfile: IUserProfile
) {
state.authUserProfile = authUserProfile
},

View File

@ -1,8 +1,8 @@
import { IUserState } from '@/store/modules/user/types'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
export const userState: IUserState = {
authToken: null,
authUserProfile: <IAuthUserProfile>{},
authUserProfile: <IUserProfile>{},
loading: false,
}

View File

@ -8,7 +8,7 @@ import {
import { USER_STORE } from '@/store/constants'
import { IRootState } from '@/store/modules/root/types'
import {
IAuthUserProfile,
IUserProfile,
ILoginOrRegisterData,
IUserDeletionPayload,
IUserPasswordPayload,
@ -20,7 +20,7 @@ import {
export interface IUserState {
authToken: string | null
authUserProfile: IAuthUserProfile
authUserProfile: IUserProfile
loading: boolean
}
@ -80,7 +80,7 @@ export interface IUserActions {
export interface IUserGetters {
[USER_STORE.GETTERS.AUTH_TOKEN](state: IUserState): string | null
[USER_STORE.GETTERS.AUTH_USER_PROFILE](state: IUserState): IAuthUserProfile
[USER_STORE.GETTERS.AUTH_USER_PROFILE](state: IUserState): IUserProfile
[USER_STORE.GETTERS.IS_ADMIN](state: IUserState): boolean
@ -94,7 +94,7 @@ export type TUserMutations<S = IUserState> = {
[USER_STORE.MUTATIONS.UPDATE_AUTH_TOKEN](state: S, authToken: string): void
[USER_STORE.MUTATIONS.UPDATE_AUTH_USER_PROFILE](
state: S,
authUserProfile: IAuthUserProfile
authUserProfile: IUserProfile
): void
[USER_STORE.MUTATIONS.UPDATE_USER_LOADING](state: S, loading: boolean): void
}

View File

@ -1,6 +1,6 @@
import { IRecord } from '@/types/workouts'
export interface IAuthUserProfile {
export interface IUserProfile {
admin: boolean
bio: string | null
birth_date: string | null

View File

@ -85,7 +85,7 @@
import UserStatsCards from '@/components/Dashboard/UserStatsCards/index.vue'
import { SPORTS_STORE, USER_STORE, WORKOUTS_STORE } from '@/store/constants'
import { ISport } from '@/types/sports'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
import { useStore } from '@/use/useStore'
export default defineComponent({
@ -99,7 +99,7 @@
},
setup() {
const store = useStore()
const authUser: ComputedRef<IAuthUserProfile> = computed(
const authUser: ComputedRef<IUserProfile> = computed(
() => store.getters[USER_STORE.GETTERS.AUTH_USER_PROFILE]
)
const sports: ComputedRef<ISport[]> = computed(

View File

@ -8,14 +8,14 @@
import { computed, ComputedRef, defineComponent } from 'vue'
import { USER_STORE } from '@/store/constants'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
import { useStore } from '@/use/useStore'
export default defineComponent({
name: 'ProfileView',
setup() {
const store = useStore()
const authUser: ComputedRef<IAuthUserProfile> = computed(
const authUser: ComputedRef<IUserProfile> = computed(
() => store.getters[USER_STORE.GETTERS.AUTH_USER_PROFILE]
)
return { authUser }

View File

@ -23,7 +23,7 @@
import NoWorkouts from '@/components/Workouts/NoWorkouts.vue'
import { USER_STORE, SPORTS_STORE } from '@/store/constants'
import { ISport } from '@/types/sports'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
import { useStore } from '@/use/useStore'
export default defineComponent({
@ -34,7 +34,7 @@
},
setup() {
const store = useStore()
const authUser: ComputedRef<IAuthUserProfile> = computed(
const authUser: ComputedRef<IUserProfile> = computed(
() => store.getters[USER_STORE.GETTERS.AUTH_USER_PROFILE]
)
const sports: ComputedRef<ISport[]> = computed(() =>

View File

@ -17,7 +17,7 @@
import WorkoutEdition from '@/components/Workout/WorkoutEdition.vue'
import { SPORTS_STORE, USER_STORE, WORKOUTS_STORE } from '@/store/constants'
import { ISport } from '@/types/sports'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
import { IWorkoutData } from '@/types/workouts'
import { useStore } from '@/use/useStore'
@ -31,7 +31,7 @@
const sports: ComputedRef<ISport[]> = computed(
() => store.getters[SPORTS_STORE.GETTERS.SPORTS]
)
const authUser: ComputedRef<IAuthUserProfile> = computed(
const authUser: ComputedRef<IUserProfile> = computed(
() => store.getters[USER_STORE.GETTERS.AUTH_USER_PROFILE]
)
const workoutData: ComputedRef<IWorkoutData> = computed(

View File

@ -24,7 +24,7 @@
import WorkoutEdition from '@/components/Workout/WorkoutEdition.vue'
import { SPORTS_STORE, USER_STORE, WORKOUTS_STORE } from '@/store/constants'
import { ISport } from '@/types/sports'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
import { IWorkoutData } from '@/types/workouts'
import { useStore } from '@/use/useStore'
@ -43,7 +43,7 @@
})
})
const authUser: ComputedRef<IAuthUserProfile> = computed(
const authUser: ComputedRef<IUserProfile> = computed(
() => store.getters[USER_STORE.GETTERS.AUTH_USER_PROFILE]
)
const sports: ComputedRef<ISport[]> = computed(

View File

@ -57,7 +57,7 @@
import WorkoutSegments from '@/components/Workout/WorkoutSegments.vue'
import { SPORTS_STORE, USER_STORE, WORKOUTS_STORE } from '@/store/constants'
import { ISport } from '@/types/sports'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
import { IWorkoutData, IWorkoutPayload, TCoordinates } from '@/types/workouts'
import { useStore } from '@/use/useStore'
@ -91,7 +91,7 @@
const workoutData: ComputedRef<IWorkoutData> = computed(
() => store.getters[WORKOUTS_STORE.GETTERS.WORKOUT_DATA]
)
const authUser: ComputedRef<IAuthUserProfile> = computed(
const authUser: ComputedRef<IUserProfile> = computed(
() => store.getters[USER_STORE.GETTERS.AUTH_USER_PROFILE]
)
const sports: ComputedRef<ISport[]> = computed(

View File

@ -38,7 +38,7 @@
import WorkoutsList from '@/components/Workouts/WorkoutsList.vue'
import { USER_STORE, SPORTS_STORE } from '@/store/constants'
import { ISport, ITranslatedSport } from '@/types/sports'
import { IAuthUserProfile } from '@/types/user'
import { IUserProfile } from '@/types/user'
import { useStore } from '@/use/useStore'
import { translateSports } from '@/utils/sports'
@ -51,7 +51,7 @@
setup() {
const { t } = useI18n()
const store = useStore()
const authUser: ComputedRef<IAuthUserProfile> = computed(
const authUser: ComputedRef<IUserProfile> = computed(
() => store.getters[USER_STORE.GETTERS.AUTH_USER_PROFILE]
)
const sports: ComputedRef<ISport[]> = computed(