Files
cal.diy/packages/trpc/server/routers/viewer/dsync/teamGroupMapping/create.handler.ts
T
1b5d50c45c feat: SCIM Group Provisioning To Teams Within An Org (#13850)
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]>
2024-03-07 16:16:53 -07:00

34 lines
839 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 { ZCreateInputSchema } from "./create.schema";
type Options = {
ctx: {
user: NonNullable<TrpcSessionUser>;
};
input: ZCreateInputSchema;
};
export const createHandler = async ({ ctx, input }: Options) => {
const { organizationId } = await userCanCreateTeamGroupMapping(
ctx.user,
ctx.user.organizationId,
input.teamId
);
await prisma.dSyncTeamGroupMapping.create({
data: {
organizationId,
teamId: input.teamId,
groupName: input.name,
directoryId: input.directoryId,
},
});
return { newGroupName: input.name };
};
export default createHandler;