Only include accepted users, ignore all pending, unregistered or not (#9250)

pull/9252/head
Alex van Andel 2023-05-31 20:48:32 +02:00 committed by GitHub
parent 64ae135f90
commit 6a56c12ef1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -133,7 +133,12 @@ async function handler(req: NextApiRequest) {
});
if (!team) throw new HttpError({ statusCode: 404, message: "teamId not found" });
if (!team.members) throw new HttpError({ statusCode: 404, message: "team has no members" });
const allMemberIds = team.members.map((membership) => membership.userId);
const allMemberIds = team.members.reduce((allMemberIds: number[], member) => {
if (member.accepted) {
allMemberIds.push(member.userId);
}
return allMemberIds;
}, []);
const members = await prisma.user.findMany({
where: { id: { in: allMemberIds } },
select: availabilityUserSelect,