From 9acc21d8823bce30e0e4345229ebf2e153ac6da5 Mon Sep 17 00:00:00 2001 From: Somay Chauhan Date: Fri, 22 Mar 2024 23:12:49 +0530 Subject: [PATCH] fix: removing apps from team events (#14182) * fix: removing apps from team events * fix: lnstalling an app to a team enables it on all the team-events by default --- .../loggedInViewer/deleteCredential.handler.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/trpc/server/routers/loggedInViewer/deleteCredential.handler.ts b/packages/trpc/server/routers/loggedInViewer/deleteCredential.handler.ts index 139b77fbc14953..2448ffec38cb69 100644 --- a/packages/trpc/server/routers/loggedInViewer/deleteCredential.handler.ts +++ b/packages/trpc/server/routers/loggedInViewer/deleteCredential.handler.ts @@ -53,7 +53,17 @@ export const deleteCredentialHandler = async ({ ctx, input }: DeleteCredentialOp const eventTypes = await prisma.eventType.findMany({ where: { - userId: ctx.user.id, + OR: [ + { + ...(teamId ? { teamId } : { userId: ctx.user.id }), + }, + // for managed events + { + parent: { + teamId, + }, + }, + ], }, select: { id: true, @@ -147,6 +157,7 @@ export const deleteCredentialHandler = async ({ ctx, input }: DeleteCredentialOp ...metadata?.apps, stripe: { ...metadata?.apps?.stripe, + enabled: false, price: 0, }, },