From 2626981ec245616bdbc8d80ad96b5525adf86183 Mon Sep 17 00:00:00 2001 From: Haris Razis Date: Thu, 14 Jan 2021 12:28:44 +0200 Subject: [PATCH] Fix weird button behavior in Athlete.vue and Profile.vue --- server/routes/athletes.js | 5 ++-- server/schemas/joi.js | 4 ++-- web/src/store/modules/athletes.ts | 25 +++++-------------- web/src/store/modules/user.ts | 1 - web/src/views/Athlete.vue | 17 ++++++++----- web/src/views/Athletes.vue | 11 +++++---- web/src/views/Profile.vue | 40 +++++++++++++++---------------- 7 files changed, 49 insertions(+), 54 deletions(-) diff --git a/server/routes/athletes.js b/server/routes/athletes.js index d7f09a3..92fe0b0 100644 --- a/server/routes/athletes.js +++ b/server/routes/athletes.js @@ -34,9 +34,10 @@ router.put('/api/athletes/:id', res.send(athlete); }); - }); + } +); -router.delete('/api/athlete/:id', +router.delete('/api/athletes/:id', requireAuth, celebrate(guid), async (req, res) => { diff --git a/server/schemas/joi.js b/server/schemas/joi.js index f3951f5..6a4dbd4 100644 --- a/server/schemas/joi.js +++ b/server/schemas/joi.js @@ -32,8 +32,8 @@ const athleteUpdateSchema = { id: Joi.string().required(), socketID: Joi.string().required(), name: Joi.string().required(), - __v: Joi.number().integer(), - _trainer: Joi.string().allow('').default(''), + __v: Joi.number().integer().required(), + _trainer: Joi.string().optional(), } }; diff --git a/web/src/store/modules/athletes.ts b/web/src/store/modules/athletes.ts index c59b520..01b837b 100644 --- a/web/src/store/modules/athletes.ts +++ b/web/src/store/modules/athletes.ts @@ -1,8 +1,6 @@ import {Action, Module, Mutation, VuexModule} from 'vuex-module-decorators' import axios, {AxiosResponse} from "axios"; -import {UserInterface} from "@/store/modules/user"; - export interface AthleteInterface { _id: string, id: string, @@ -14,7 +12,6 @@ export interface AthleteInterface { @Module export default class Athletes extends VuexModule { private athlete = {}; - private trainer = {}; private athletes = [{}]; private err = {}; @@ -22,22 +19,10 @@ export default class Athletes extends VuexModule { return this.athlete; } - get athlete_trainer() { - return this.trainer; - } - - get athlete_currents() { - return this.athletes; - } - get athlete_err() { return this.err; } - @Mutation api_trainer(trainer: UserInterface) { - this.trainer = trainer; - } - @Mutation private api_athlete(athlete: AthleteInterface) { this.athlete = athlete; @@ -51,7 +36,6 @@ export default class Athletes extends VuexModule { @Mutation private athletes_logout() { this.athlete = {}; - this.trainer = {}; this.athletes = [{}]; } @@ -61,11 +45,14 @@ export default class Athletes extends VuexModule { } @Mutation - private athlete_addTrainer(trainer: UserInterface) { - this.trainer = trainer; - this.athlete._trainer = this.trainer._id; + private athlete_addTrainer(trainerId: string) { + this.athlete._trainer = trainerId; } + @Mutation + private athlete_deleteTrainer() { + delete this.athlete['_trainer']; + } @Action private athlete_getAll() { diff --git a/web/src/store/modules/user.ts b/web/src/store/modules/user.ts index 4908b57..d4be553 100644 --- a/web/src/store/modules/user.ts +++ b/web/src/store/modules/user.ts @@ -116,7 +116,6 @@ export default class User extends VuexModule { }); } - @Action private user_update() { return new Promise((resolve, reject) => { diff --git a/web/src/views/Athlete.vue b/web/src/views/Athlete.vue index 7a1e59d..456652e 100644 --- a/web/src/views/Athlete.vue +++ b/web/src/views/Athlete.vue @@ -30,12 +30,16 @@

Personal Details

-
+
+
+ +

{{ athlete.name }}

+

Online

@@ -58,7 +62,7 @@
-
+