Client - refactor types
This commit is contained in:
parent
f60847cc5f
commit
db9ea49998
@ -20,7 +20,7 @@
|
||||
import NavBar from '@/components/NavBar.vue'
|
||||
import NoConfig from '@/components/NoConfig.vue'
|
||||
import { ROOT_STORE } from '@/store/constants'
|
||||
import { IAppConfig } from '@/store/modules/root/interfaces'
|
||||
import { IAppConfig } from '@/types/application'
|
||||
import { useStore } from '@/use/useStore'
|
||||
|
||||
export default defineComponent({
|
||||
|
@ -20,8 +20,7 @@
|
||||
<script lang="ts">
|
||||
import { PropType, defineComponent, ref } from 'vue'
|
||||
|
||||
import { IDropdownOption } from '@/interfaces'
|
||||
import { TDropdownOptions } from '@/types'
|
||||
import { IDropdownOption, TDropdownOptions } from '@/types/forms'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'Dropdown',
|
||||
|
@ -28,7 +28,7 @@
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
import UserStatCard from '@/components/Dashboard/UserStatCard.vue'
|
||||
import { IAuthUserProfile } from '@/store/modules/user/interfaces'
|
||||
import { IAuthUserProfile } from '@/types/user'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'UserStats',
|
||||
|
@ -78,9 +78,9 @@
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
import Dropdown from '@/components/Common/Dropdown.vue'
|
||||
import { IDropdownOption } from '@/interfaces'
|
||||
import { ROOT_STORE, USER_STORE } from '@/store/constants'
|
||||
import { IAuthUserProfile } from '@/store/modules/user/interfaces'
|
||||
import { IDropdownOption } from '@/types/forms'
|
||||
import { IAuthUserProfile } from '@/types/user'
|
||||
import { useStore } from '@/use/useStore'
|
||||
import { capitalize, getApiUrl } from '@/utils'
|
||||
|
||||
|
@ -64,10 +64,10 @@
|
||||
|
||||
import AlertMessage from '@/components/Common/AlertMessage.vue'
|
||||
import ErrorMessage from '@/components/Common/ErrorMessage.vue'
|
||||
import { IFormData } from '@/interfaces'
|
||||
import router from '@/router'
|
||||
import { ROOT_STORE, USER_STORE } from '@/store/constants'
|
||||
import { IAppConfig } from '@/store/modules/root/interfaces'
|
||||
import { IAppConfig } from '@/types/application'
|
||||
import { ILoginRegisterFormData } from '@/types/user'
|
||||
import { useStore } from '@/use/useStore'
|
||||
|
||||
export default defineComponent({
|
||||
@ -83,7 +83,7 @@
|
||||
},
|
||||
},
|
||||
setup(props) {
|
||||
const formData: IFormData = reactive({
|
||||
const formData: ILoginRegisterFormData = reactive({
|
||||
username: '',
|
||||
email: '',
|
||||
password: '',
|
||||
|
@ -1,11 +0,0 @@
|
||||
export interface IDropdownOption {
|
||||
value: string
|
||||
label: string
|
||||
}
|
||||
|
||||
export interface IFormData {
|
||||
username: string
|
||||
email: string
|
||||
password: string
|
||||
password_conf: string
|
||||
}
|
@ -1,28 +1,7 @@
|
||||
import { ActionContext } from 'vuex'
|
||||
|
||||
import { ROOT_STORE } from '@/store/constants'
|
||||
|
||||
export interface IAppStatistics {
|
||||
sports: number
|
||||
uploads_dir_size: number
|
||||
users: number
|
||||
workouts: number
|
||||
}
|
||||
|
||||
export interface IAppConfig {
|
||||
federation_enabled: boolean
|
||||
gpx_limit_import: number | null
|
||||
is_registration_enabled: boolean
|
||||
map_attribution: string
|
||||
max_single_file_size: number | null
|
||||
max_users: number | null
|
||||
max_zip_file_size: number | null
|
||||
}
|
||||
|
||||
export interface IApplication {
|
||||
statistics: IAppStatistics
|
||||
config: IAppConfig
|
||||
}
|
||||
import { IAppConfig, IApplication } from '@/types/application'
|
||||
|
||||
export interface IRootState {
|
||||
root: boolean
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { MutationTree } from 'vuex'
|
||||
|
||||
import { ROOT_STORE } from '@/store/constants'
|
||||
import { IAppConfig, IRootState } from '@/store/modules/root/interfaces'
|
||||
import { IRootState } from '@/store/modules/root/interfaces'
|
||||
import { TRootMutations } from '@/store/modules/root/types'
|
||||
import { IAppConfig } from '@/types/application'
|
||||
|
||||
export const mutations: MutationTree<IRootState> & TRootMutations = {
|
||||
[ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES](state: IRootState) {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { IRootState, IApplication } from '@/store/modules/root/interfaces'
|
||||
import { IRootState } from '@/store/modules/root/interfaces'
|
||||
import { IApplication } from '@/types/application'
|
||||
|
||||
export const state: IRootState = {
|
||||
root: true,
|
||||
|
@ -5,11 +5,8 @@ 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 {
|
||||
ILoginOrRegisterData,
|
||||
IUserActions,
|
||||
IUserState,
|
||||
} from '@/store/modules/user/interfaces'
|
||||
import { IUserActions, IUserState } from '@/store/modules/user/interfaces'
|
||||
import { ILoginOrRegisterData } from '@/types/user'
|
||||
import { handleError } from '@/utils'
|
||||
|
||||
export const actions: ActionTree<IUserState, IRootState> & IUserActions = {
|
||||
|
@ -1,35 +1,8 @@
|
||||
import { ActionContext } from 'vuex'
|
||||
|
||||
import { IFormData } from '@/interfaces'
|
||||
import { USER_STORE } from '@/store/constants'
|
||||
import { IRootState } from '@/store/modules/root/interfaces'
|
||||
|
||||
// DATA
|
||||
export interface IAuthUserProfile {
|
||||
admin: boolean
|
||||
bio: string | null
|
||||
birth_date: string | null
|
||||
created_at: string
|
||||
email: string
|
||||
first_name: string | null
|
||||
language: string | null
|
||||
last_name: string | null
|
||||
location: string | null
|
||||
nb_sports: number
|
||||
nb_workouts: number
|
||||
picture: string | boolean
|
||||
sports_list: number[]
|
||||
timezone: string
|
||||
total_distance: number
|
||||
total_duration: string
|
||||
username: string
|
||||
weekm: boolean
|
||||
}
|
||||
|
||||
export interface ILoginOrRegisterData {
|
||||
actionType: string
|
||||
formData: IFormData
|
||||
}
|
||||
import { IAuthUserProfile, ILoginOrRegisterData } from '@/types/user'
|
||||
|
||||
// STORE
|
||||
export interface IUserState {
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { MutationTree } from 'vuex'
|
||||
|
||||
import { USER_STORE } from '@/store/constants'
|
||||
import { IAuthUserProfile, IUserState } from '@/store/modules/user/interfaces'
|
||||
import { IUserState } from '@/store/modules/user/interfaces'
|
||||
import { TUserMutations } from '@/store/modules/user/types'
|
||||
import { IAuthUserProfile } from '@/types/user'
|
||||
|
||||
export const mutations: MutationTree<IUserState> & TUserMutations = {
|
||||
[USER_STORE.MUTATIONS.CLEAR_AUTH_USER_TOKEN](state: IUserState) {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { IAuthUserProfile, IUserState } from '@/store/modules/user/interfaces'
|
||||
import { IUserState } from '@/store/modules/user/interfaces'
|
||||
import { IAuthUserProfile } from '@/types/user'
|
||||
|
||||
export const userState: IUserState = {
|
||||
authToken: null,
|
||||
|
@ -2,11 +2,11 @@ import { Store as VuexStore, CommitOptions, DispatchOptions } from 'vuex'
|
||||
|
||||
import { USER_STORE } from '@/store/constants'
|
||||
import {
|
||||
IAuthUserProfile,
|
||||
IUserActions,
|
||||
IUserGetters,
|
||||
IUserState,
|
||||
} from '@/store/modules/user/interfaces'
|
||||
import { IAuthUserProfile } from '@/types/user'
|
||||
|
||||
export type TUserMutations<S = IUserState> = {
|
||||
[USER_STORE.MUTATIONS.CLEAR_AUTH_USER_TOKEN](state: S): void
|
||||
|
@ -1,3 +0,0 @@
|
||||
import { IDropdownOption } from '@/interfaces'
|
||||
|
||||
export type TDropdownOptions = IDropdownOption[]
|
21
fittrackee_client/src/types/application.ts
Normal file
21
fittrackee_client/src/types/application.ts
Normal file
@ -0,0 +1,21 @@
|
||||
export interface IAppStatistics {
|
||||
sports: number
|
||||
uploads_dir_size: number
|
||||
users: number
|
||||
workouts: number
|
||||
}
|
||||
|
||||
export interface IAppConfig {
|
||||
federation_enabled: boolean
|
||||
gpx_limit_import: number | null
|
||||
is_registration_enabled: boolean
|
||||
map_attribution: string
|
||||
max_single_file_size: number | null
|
||||
max_users: number | null
|
||||
max_zip_file_size: number | null
|
||||
}
|
||||
|
||||
export interface IApplication {
|
||||
statistics: IAppStatistics
|
||||
config: IAppConfig
|
||||
}
|
6
fittrackee_client/src/types/forms.ts
Normal file
6
fittrackee_client/src/types/forms.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export interface IDropdownOption {
|
||||
value: string
|
||||
label: string
|
||||
}
|
||||
|
||||
export type TDropdownOptions = IDropdownOption[]
|
32
fittrackee_client/src/types/user.ts
Normal file
32
fittrackee_client/src/types/user.ts
Normal file
@ -0,0 +1,32 @@
|
||||
export interface IAuthUserProfile {
|
||||
admin: boolean
|
||||
bio: string | null
|
||||
birth_date: string | null
|
||||
created_at: string
|
||||
email: string
|
||||
first_name: string | null
|
||||
language: string | null
|
||||
last_name: string | null
|
||||
location: string | null
|
||||
nb_sports: number
|
||||
nb_workouts: number
|
||||
picture: string | boolean
|
||||
sports_list: number[]
|
||||
timezone: string
|
||||
total_distance: number
|
||||
total_duration: string
|
||||
username: string
|
||||
weekm: boolean
|
||||
}
|
||||
|
||||
export interface ILoginRegisterFormData {
|
||||
username: string
|
||||
email: string
|
||||
password: string
|
||||
password_conf: string
|
||||
}
|
||||
|
||||
export interface ILoginOrRegisterData {
|
||||
actionType: string
|
||||
formData: ILoginRegisterFormData
|
||||
}
|
@ -11,7 +11,7 @@
|
||||
|
||||
import UserStats from '@/components/Dashboard/UserStats.vue'
|
||||
import { USER_STORE } from '@/store/constants'
|
||||
import { IAuthUserProfile } from '@/store/modules/user/interfaces'
|
||||
import { IAuthUserProfile } from '@/types/user'
|
||||
import { useStore } from '@/use/useStore'
|
||||
|
||||
export default defineComponent({
|
||||
|
Loading…
Reference in New Issue
Block a user