* feat: added ability to assign event to all members * fix: types * chore: incorporate assignment for collective and round robin event sas well * fix: update event types query * feat: round robin hosts * fix: update * fix: update * fix: assignAllTeamMembers issue * design fixes --------- Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: CarinaWolli <wollencarina@gmail.com>
59 lines
1.1 KiB
TypeScript
59 lines
1.1 KiB
TypeScript
import { updateNewTeamMemberEventTypes } from "@calcom/lib/server/queries";
|
|
import prisma from "@calcom/prisma";
|
|
|
|
export async function joinOrganization({
|
|
organizationId,
|
|
userId,
|
|
}: {
|
|
userId: number;
|
|
organizationId: number;
|
|
}) {
|
|
return await prisma.user.update({
|
|
where: {
|
|
id: userId,
|
|
},
|
|
data: {
|
|
organizationId: organizationId,
|
|
},
|
|
});
|
|
}
|
|
|
|
export async function joinAnyChildTeamOnOrgInvite({ userId, orgId }: { userId: number; orgId: number }) {
|
|
await prisma.$transaction([
|
|
prisma.user.update({
|
|
where: {
|
|
id: userId,
|
|
},
|
|
data: {
|
|
organizationId: orgId,
|
|
},
|
|
}),
|
|
prisma.membership.updateMany({
|
|
where: {
|
|
userId,
|
|
team: {
|
|
id: orgId,
|
|
},
|
|
accepted: false,
|
|
},
|
|
data: {
|
|
accepted: true,
|
|
},
|
|
}),
|
|
prisma.membership.updateMany({
|
|
where: {
|
|
userId,
|
|
team: {
|
|
parentId: orgId,
|
|
},
|
|
accepted: false,
|
|
},
|
|
data: {
|
|
accepted: true,
|
|
},
|
|
}),
|
|
]);
|
|
|
|
await updateNewTeamMemberEventTypes(userId, orgId);
|
|
}
|