diff --git a/web/src/store/modules/athletes.ts b/web/src/store/modules/athletes.ts index a3a15da..c59b520 100644 --- a/web/src/store/modules/athletes.ts +++ b/web/src/store/modules/athletes.ts @@ -60,6 +60,13 @@ export default class Athletes extends VuexModule { this.err = err; } + @Mutation + private athlete_addTrainer(trainer: UserInterface) { + this.trainer = trainer; + this.athlete._trainer = this.trainer._id; + } + + @Action private athlete_getAll() { return new Promise((resolve, reject) => { @@ -78,12 +85,12 @@ export default class Athletes extends VuexModule { } @Action - private athlete_update(athlete: AthleteInterface) { + private athlete_update() { return new Promise((resolve, reject) => { axios({ method: 'PUT', - url: `/api/athletes/${athlete._id}`, - data: {...athlete} + url: `/api/athletes/${this.athlete._id}`, + data: {...this.athlete} }) .then((resp: AxiosResponse) => { this.context.commit('api_athlete', resp.data); @@ -95,11 +102,6 @@ export default class Athletes extends VuexModule { }); } - @Action - private athlete_saveLocalTrainer(trainer: UserInterface) { - this.context.commit('api_trainer', trainer); - } - @Action private athlete_saveLocal(athlete: AthleteInterface) { this.context.commit('api_athlete', athlete); diff --git a/web/src/store/modules/backend.ts b/web/src/store/modules/backend.ts index 10fe52c..a0beb25 100644 --- a/web/src/store/modules/backend.ts +++ b/web/src/store/modules/backend.ts @@ -36,12 +36,11 @@ export default class Backend extends VuexModule { @Mutation private server_logout() { - this.liveAthData = [] + this.liveAthData = []; } @Action private server_saveLiveData(data: AthleteData) { - console.log(this.liveAthData); this.context.commit('server_queueData', data); if (this.liveAthData.length > 15) this.context.commit('server_dequeueData'); @@ -55,10 +54,10 @@ export default class Backend extends VuexModule { url: `/api/data/` }) .then((resp: AxiosResponse) => { - resolve(resp) + resolve(resp); }) .catch((err: Error) => { - reject(err) + reject(err); }); }); } @@ -71,10 +70,10 @@ export default class Backend extends VuexModule { url: `/api/data/${id}` }) .then((resp: AxiosResponse) => { - resolve(resp) + resolve(resp); }) .catch((err: Error) => { - reject(err) + reject(err); }); }); } diff --git a/web/src/store/modules/user.ts b/web/src/store/modules/user.ts index 78da540..4908b57 100644 --- a/web/src/store/modules/user.ts +++ b/web/src/store/modules/user.ts @@ -6,7 +6,9 @@ export interface UserInterface { _id: string, username: string, email: string, - password: string, + password: string | undefined, + newPassword: string | undefined, + repeatNewPassword: string | undefined, registered: Date, lastLogin: Date, } @@ -32,6 +34,7 @@ export default class User extends VuexModule { @Mutation private auth_success(user: UserInterface) { this.user = user; + delete this.user['password']; this.userStatus = true; } @@ -55,6 +58,7 @@ export default class User extends VuexModule { @Mutation private update_user(user: UserInterface) { this.user = user; + delete this.user['password']; } @Action @@ -106,7 +110,7 @@ export default class User extends VuexModule { resolve(resp); }) .catch((err: Error) => { - this.context.commit('auth_error') + this.context.commit('auth_error'); reject(err); }); }); @@ -114,19 +118,19 @@ export default class User extends VuexModule { @Action - private user_update(user: UserInterface) { + private user_update() { return new Promise((resolve, reject) => { axios({ method: 'PUT', - url: `/api/user/${user._id}`, - data: {...user} + url: `/api/user/${this.user._id}`, + data: {...this.user} }) .then((resp: AxiosResponse) => { this.context.commit('update_user', resp.data); resolve(resp); }) .catch((err: Error) => { - this.context.commit('update_err', err) + this.context.commit('update_err', err); reject(err); }); }); diff --git a/web/src/views/Athlete.vue b/web/src/views/Athlete.vue index 7172196..7a1e59d 100644 --- a/web/src/views/Athlete.vue +++ b/web/src/views/Athlete.vue @@ -87,7 +87,7 @@
- +
Change Password
-
@@ -79,17 +79,9 @@ import {Vue} from "vue-class-component"; import {UserInterface} from "@/store/modules/user"; -interface UpdatedUser extends UserInterface { - newPassword: string, - repeatNewPassword: string, -} - export default class Profile extends Vue { - private user =