Co-authored-by: Alex van Andel <[email protected]> Co-authored-by: Keith Williams <[email protected]> Co-authored-by: CarinaWolli <[email protected]> Co-authored-by: Udit Takkar <[email protected]> Co-authored-by: Kiran K <[email protected]> Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: sean-brydon <[email protected]> Co-authored-by: zomars <[email protected]> Co-authored-by: Carina Wollendorfer <[email protected]>
31 lines
837 B
TypeScript
31 lines
837 B
TypeScript
import userCanCreateTeamGroupMapping from "@calcom/features/ee/dsync/lib/server/userCanCreateTeamGroupMapping";
|
|
import prisma from "@calcom/prisma";
|
|
import type { TrpcSessionUser } from "@calcom/trpc/server/trpc";
|
|
|
|
import type { ZDeleteInputSchema } from "./delete.schema";
|
|
|
|
type Options = {
|
|
ctx: {
|
|
user: NonNullable<TrpcSessionUser>;
|
|
};
|
|
input: ZDeleteInputSchema;
|
|
};
|
|
|
|
// Delete directory sync connection for a team
|
|
export const deleteHandler = async ({ ctx, input }: Options) => {
|
|
await userCanCreateTeamGroupMapping(ctx.user, ctx.user.organizationId, input.teamId);
|
|
|
|
await prisma.dSyncTeamGroupMapping.delete({
|
|
where: {
|
|
teamId_groupName: {
|
|
teamId: input.teamId,
|
|
groupName: input.groupName,
|
|
},
|
|
},
|
|
});
|
|
|
|
return { deletedGroupName: input.groupName };
|
|
};
|
|
|
|
export default deleteHandler;
|