Skip to content

Add Clubs Managed and Clubs Joined to the Profile Page #49

Description

@AFAskar

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');
    }
};

Metadata

Metadata

Labels

Projects

Status
Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions