Files
cal.diy/packages/features/auth/signup/utils/organization.ts
T
f9359aaa7b feat: added ability to assign event to all members (#13219)
* 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>
2024-01-26 17:37:38 +00:00

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);
}