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 @@