Adding the User's joined and managed Clubs could be done simply by changing this function
and for the frontend devs the Addition Shouldn't be that hard you just iterate on an array if it exists
const renderProfile = async (req, res) => {
try {
const user = await User.findById(req.user.id)
if (!user) {
return res.status(404).send('User not found');
}
res.render('profile', { user });
} catch (err) {
res.status(500).send('Server error');
}
};
to this
const renderProfile = async (req, res) => {
try {
const user = await User.findById(req.user.id)
.populate('clubsManaged')
.populate('clubsJoined')
.lean();
res.render('profile', { user });
} catch (err) {
if (err == "User not Found") {
res.status(404).send('User not found');
}
res.status(500).send('Server error');
}
};
or even use the Service From #47
const renderProfile = async (req, res) => {
try {
const user = await userService.findById(req.user.id)
if (!user) {
return res.status(404).send('User not found');
}
res.render('profile', { user });
} catch (err) {
res.status(500).send('Server error');
}
};
Adding the User's joined and managed Clubs could be done simply by changing this function
and for the frontend devs the Addition Shouldn't be that hard you just iterate on an array if it exists
to this
or even use the Service From #47