fix: add default schedule while creating org member (#16855)
* add default schedule while creating org user * naming as per review comments * added e2e test * move bookTeamEvent and expectPageNotFound to testUtils * Update EventTeamAssignmentTab.tsx * Update AddMembersWithSwitch.tsx * Update utils.ts --------- Co-authored-by: Anik Dhabal Babu <[email protected]>
This commit is contained in:
1 parent
9aa8f8a30c
commit
7b94822c8d
6 files changed
+124
-51
No files matched your search
@@ -3,6 +3,7 @@ import type { TFunction } from "next-i18next";
|
||||
|
||||
import { getOrgFullOrigin } from "@calcom/ee/organizations/lib/orgDomains";
|
||||
import { sendTeamInviteEmail } from "@calcom/emails";
|
||||
import { DEFAULT_SCHEDULE, getAvailabilityFromSchedule } from "@calcom/lib/availability";
|
||||
import { ENABLE_PROFILE_SWITCHER, WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { createAProfileForAnExistingUser } from "@calcom/lib/createAProfileForAnExistingUser";
|
||||
import logger from "@calcom/lib/logger";
|
||||
@@ -272,6 +273,7 @@ export async function createNewUsersConnectToOrgIfExists({
|
||||
timeFormat,
|
||||
weekStart,
|
||||
timeZone,
|
||||
language,
|
||||
}: {
|
||||
invitations: Invitation[];
|
||||
isOrg: boolean;
|
||||
@@ -283,6 +285,7 @@ export async function createNewUsersConnectToOrgIfExists({
|
||||
timeFormat?: number;
|
||||
weekStart?: string;
|
||||
timeZone?: string;
|
||||
language: string;
|
||||
}) {
|
||||
// fail if we have invalid emails
|
||||
invitations.forEach((invitation) => checkInputEmailIsValid(invitation.usernameOrEmail));
|
||||
@@ -307,6 +310,8 @@ export async function createNewUsersConnectToOrgIfExists({
|
||||
|
||||
const isBecomingAnOrgMember = parentId || isOrg;
|
||||
|
||||
const defaultAvailability = getAvailabilityFromSchedule(DEFAULT_SCHEDULE);
|
||||
const t = await getTranslation(language ?? "en", "common");
|
||||
const createdUser = await tx.user.create({
|
||||
data: {
|
||||
username: isBecomingAnOrgMember ? orgMemberUsername : regularTeamMemberUsername,
|
||||
@@ -340,6 +345,20 @@ export async function createNewUsersConnectToOrgIfExists({
|
||||
accepted: autoAccept, // If the user is invited to a child team, they are automatically accepted
|
||||
},
|
||||
},
|
||||
schedules: {
|
||||
create: {
|
||||
name: t("default_schedule_name"),
|
||||
availability: {
|
||||
createMany: {
|
||||
data: defaultAvailability.map((schedule) => ({
|
||||
days: schedule.days,
|
||||
startTime: schedule.startTime,
|
||||
endTime: schedule.endTime,
|
||||
})),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -908,6 +927,7 @@ export async function handleNewUsersInvites({
|
||||
orgConnectInfoByUsernameOrEmail,
|
||||
autoAcceptEmailDomain: autoAcceptEmailDomain,
|
||||
parentId: team.parentId,
|
||||
language,
|
||||
});
|
||||
|
||||
const sendVerifyEmailsPromises = invitationsForNewUsers.map((invitation) => {
|
||||
|
||||
Reference in new issue
Block a user