* added layouts for moving teams step * added admin section for org creation step * extended org creation to also move existing teams * wip * wip * wip * further changes * Add checkout for org in onboarding * Fix ts errors * Self review feedback * Self review addressed * Fix unit tests * Fix ts error * Seans feedback addressed * feat: fix correct accounts pending * fix: unit tests for new invite member permissions * tests: org admin onboarding tests for existing user * tests: Inital user self serve flow * chore: update teamAndUserFixture to create X amount of teams * chore: add testId to card actionButton * test: add test-Id to continue or checkout button * tests: add tests for migrating existing teams * feat: match new designs * fix: isAdminCheck * chore: fix pricing copy * fix: flacky tests * Fix tests? * More test fixes * Check all checkboxes * Fix type error * Fix failing test and typescript issues * Fix unpaid org allowing auto-add users * Add self-serve flag * Skip tests --------- Co-authored-by: Alex van Andel <me@alexvanandel.com> Co-authored-by: Hariom <hariombalhara@gmail.com> Co-authored-by: sean-brydon <sean@cal.com> Co-authored-by: Joe Au-Yeung <j.auyeung419@gmail.com> Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Co-authored-by: Omar López <zomars@me.com>
49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
import type { TFunction } from "next-i18next";
|
|
|
|
import { createAProfileForAnExistingUser } from "@calcom/lib/createAProfileForAnExistingUser";
|
|
import prisma from "@calcom/prisma";
|
|
import type { UserWithMembership } from "@calcom/trpc/server/routers/viewer/teams/inviteMember/utils";
|
|
|
|
/**
|
|
* This should only be used in a dsync context
|
|
*/
|
|
const inviteExistingUserToOrg = async ({
|
|
user,
|
|
org,
|
|
translation,
|
|
}: {
|
|
user: UserWithMembership;
|
|
org: { id: number; name: string; parent: { name: string } | null };
|
|
translation: TFunction;
|
|
}) => {
|
|
await createAProfileForAnExistingUser({
|
|
user: {
|
|
id: user.id,
|
|
email: user.email,
|
|
currentUsername: user.username,
|
|
},
|
|
organizationId: org.id,
|
|
});
|
|
|
|
await prisma.user.update({
|
|
where: {
|
|
id: user.id,
|
|
},
|
|
data: {
|
|
organizationId: org.id,
|
|
teams: {
|
|
create: {
|
|
teamId: org.id,
|
|
role: "MEMBER",
|
|
// Since coming from directory assume it'll be verified
|
|
accepted: true,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
return user;
|
|
};
|
|
|
|
export default inviteExistingUserToOrg;
|