From 7f1e20fe190bb3cc577d9c611cd91dd297f2ccb0 Mon Sep 17 00:00:00 2001 From: Vijay Date: Tue, 6 Aug 2024 17:18:01 +0530 Subject: [PATCH] fix: #16041 team eventtype create from api (#16058) * update for teameventType creation from api * update to set userid null for team event --- apps/api/v1/pages/api/event-types/_post.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/api/v1/pages/api/event-types/_post.ts b/apps/api/v1/pages/api/event-types/_post.ts index 9f196385d2..3d4a2e29bb 100644 --- a/apps/api/v1/pages/api/event-types/_post.ts +++ b/apps/api/v1/pages/api/event-types/_post.ts @@ -278,8 +278,8 @@ async function postHandler(req: NextApiRequest) { let data: Prisma.EventTypeCreateArgs["data"] = { ...parsedBody, - userId, - users: { connect: { id: userId } }, + userId: !!parsedBody.teamId ? null : userId, + users: !!parsedBody.teamId ? undefined : { connect: { id: userId } }, bookingLimits: bookingLimits === null ? Prisma.DbNull : bookingLimits, durationLimits: durationLimits === null ? Prisma.DbNull : durationLimits, }; @@ -291,7 +291,7 @@ async function postHandler(req: NextApiRequest) { await checkUserMembership(req); } - if (isSystemWideAdmin && parsedBody.userId) { + if (isSystemWideAdmin && parsedBody.userId && !parsedBody.teamId) { data = { ...parsedBody, users: { connect: { id: parsedBody.userId } } }; }