+1








1b5d50c45c
Co-authored-by: Alex van Andel <me@alexvanandel.com> Co-authored-by: Keith Williams <keithwillcode@gmail.com> Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Co-authored-by: Kiran K <mailtokirankk@gmail.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Co-authored-by: zomars <zomars@me.com> Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
34 lines
839 B
TypeScript
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;
|