fix: webhooks for managed event types (#10958)

Co-authored-by: CarinaWolli <[email protected]>
Co-authored-by: Omar López <[email protected]>
This commit is contained in:
authored and GitHub committed 2023-08-26 00:27:05 +00:00
1 parent a810a538e9
commit 83aea7d28c
8 files changed
+36 -14

No files matched your search

@@ -22,8 +22,14 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
try {
const where: Prisma.BookingWhereInput = {};
if (validKey.teamId) where.eventType = { teamId: validKey.teamId };
else where.userId = validKey.userId;
if (validKey.teamId) {
where.eventType = {
OR: [{ teamId: validKey.teamId }, { parent: { teamId: validKey.teamId } }],
};
} else {
where.userId = validKey.userId;
}
const bookings = await prisma.booking.findMany({
take: 3,
where,