feat(match): add endpoint to retrieve active players for a club
- Implemented a new controller method `getMatchPlayers` to fetch active members of a specified club, returning their details. - Updated the match routes to include a new GET route for retrieving players by club ID. - Modified the ScheduleView to include the current club ID when updating player information.
This commit is contained in:
@@ -145,3 +145,21 @@ export const getPlayerMatchStats = async (req, res) => {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const getMatchPlayers = async (req, res) => {
|
||||
try {
|
||||
const { clubId } = req.params;
|
||||
if (!clubId) {
|
||||
return res.status(400).json({ error: 'Club-ID fehlt' });
|
||||
}
|
||||
const Member = (await import('../models/Member.js')).default;
|
||||
const members = await Member.findAll({
|
||||
where: { clubId: clubId, active: true },
|
||||
attributes: ['id', 'firstName', 'lastName', 'gender']
|
||||
});
|
||||
return res.status(200).json(members);
|
||||
} catch (error) {
|
||||
console.error('Error retrieving match players:', error);
|
||||
return res.status(500).json({ error: 'Failed to retrieve match players' });
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user