diff --git a/server/routes/athletes.js b/server/routes/athletes.js index 18d52b5..96e01a7 100644 --- a/server/routes/athletes.js +++ b/server/routes/athletes.js @@ -21,8 +21,17 @@ router.get('/api/athletes/:id/edit', requireAuth, async (req, res) => { }); router.put('/api/athletes/:id', requireAuth, async (req, res) => { - const {id, user} = req.params - await Athlete.findByIdAndUpdate(id, user) + const {name, _trainer} = req.body + const updateAthlete = {name, _trainer} + + if (name || _trainer) + await Athlete.findByIdAndUpdate(req.params.id, updateAthlete, {}, (err, athlete) => { + if (err) + return res.status(400).json({errors: 'Something went wrong!0'}); + + res.send(athlete) + }) + }); router.delete('/api/athlete/:id', requireAuth, async (req, res) => { diff --git a/web/src/components/Navbar.vue b/web/src/components/Navbar.vue index 2c9ced3..3083343 100644 --- a/web/src/components/Navbar.vue +++ b/web/src/components/Navbar.vue @@ -22,7 +22,7 @@
Trainer Status
+It seems that this athlete has no trainer attached to him!
+By adopting an athlete you can edit his personal details and view his performance stats.
+{{ trainer.username }}
+{{ trainer.email }}
+-
+{{ trainerLogin }}
+Athlete id | +Name | +Trainer | +Actions | +|
---|---|---|---|---|
+ + + {{ athlete.id }} + + | ++ + + {{ athlete.name }} + + | ++ + | ++ + | +
+ |
+