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
@@ -111,6 +111,7 @@ const AddMembersWithSwitch = ({
|
||||
placeholder = "",
|
||||
containerClassName = "",
|
||||
isRRWeightsEnabled,
|
||||
...rest
|
||||
}: {
|
||||
value: Host[];
|
||||
onChange: (hosts: Host[]) => void;
|
||||
@@ -123,6 +124,7 @@ const AddMembersWithSwitch = ({
|
||||
placeholder?: string;
|
||||
containerClassName?: string;
|
||||
isRRWeightsEnabled?: boolean;
|
||||
"data-testid"?: string;
|
||||
}) => {
|
||||
const { t } = useLocale();
|
||||
const { setValue } = useFormContext<FormValues>();
|
||||
@@ -144,6 +146,7 @@ const AddMembersWithSwitch = ({
|
||||
)}
|
||||
{!assignAllTeamMembers || !automaticAddAllEnabled ? (
|
||||
<CheckedHostField
|
||||
data-testid={rest["data-testid"]}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
isFixed={isFixed}
|
||||
|
||||
@@ -157,6 +157,7 @@ const FixedHosts = ({
|
||||
</>
|
||||
) : (
|
||||
<SettingsToggle
|
||||
data-testid="fixed-hosts-switch"
|
||||
toggleSwitchAtTheEnd={true}
|
||||
title={t("fixed_hosts")}
|
||||
description={FixedHostHelper}
|
||||
@@ -175,6 +176,7 @@ const FixedHosts = ({
|
||||
childrenClassName="lg:ml-0">
|
||||
<div className="border-subtle flex flex-col gap-6 rounded-bl-md rounded-br-md border border-t-0 px-6">
|
||||
<AddMembersWithSwitch
|
||||
data-testid="fixed-hosts-select"
|
||||
teamMembers={teamMembers}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
|
||||
@@ -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