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 } } }; }