Only include accepted users, ignore all pending, unregistered or not (#9250)
This commit is contained in:
1 parent
64ae135f90
commit
6a56c12ef1
1 file changed
+6
-1
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user