Scheduling infrastructure for absolutely everyone.
feat: Don't remove hosts when disabling 'Add all team members' (#17747)
Amit Sharmad952e77b7815
diff --git a/packages/app-store/routing-forms/trpc/getAttributesForTeam.handler.ts b/packages/app-store/routing-forms/trpc/getAttributesForTeam.handler.tsindex 9ebbcaeedf9..f6b8e51bd32 100644--- a/packages/app-store/routing-forms/trpc/getAttributesForTeam.handler.ts+++ b/packages/app-store/routing-forms/trpc/getAttributesForTeam.handler.ts@@ -1,9 +1,9 @@+import { getAttributesForTeam } from "@calcom/lib/raqb/getAttributes";import { MembershipRepository } from "@calcom/lib/server/repository/membership";import type { TrpcSessionUser } from "@calcom/trpc/server/trpc";import { TRPCError } from "@trpc/server";-import { getAttributesForTeam } from "@calcom/lib/raqb/getAttributes";import type { TGetAttributesForTeamInputSchema } from "./getAttributesForTeam.schema";type GetAttributesForTeamHandlerOptions = {diff --git a/packages/features/bookings/Booker/components/hooks/useBookings.ts b/packages/features/bookings/Booker/components/hooks/useBookings.tsindex 208ab06b859..875475a7436 100644--- a/packages/features/bookings/Booker/components/hooks/useBookings.ts+++ b/packages/features/bookings/Booker/components/hooks/useBookings.ts@@ -309,7 +309,7 @@ export const useBookings = ({ event, hashedLink, bookingForm, metadata, teamMembmutationFn: createRecurringBooking,onSuccess: async (bookings) => {const booking = bookings[0] || {};-+if (booking.isDryRun) {showToast(t("booking_dry_run_successful"), "success");return;diff --git a/packages/features/eventtypes/components/AddMembersWithSwitch.tsx b/packages/features/eventtypes/components/AddMembersWithSwitch.tsxindex 02722637260..8e68d0c3de7 100644--- a/packages/features/eventtypes/components/AddMembersWithSwitch.tsx+++ b/packages/features/eventtypes/components/AddMembersWithSwitch.tsx@@ -250,7 +250,6 @@ function AddMembersWithSwitch({});const onAssignAllTeamMembersInactive = () => {- setValue("hosts", [], { shouldDirty: true });setAssignRRMembersUsingSegment(false);};diff --git a/packages/features/eventtypes/components/HostEditDialogs.tsx b/packages/features/eventtypes/components/HostEditDialogs.tsxindex ebd2729d738..ca2b89b86d9 100644--- a/packages/features/eventtypes/components/HostEditDialogs.tsx+++ b/packages/features/eventtypes/components/HostEditDialogs.tsx@@ -76,7 +76,7 @@ export const PriorityDialog = (props: IDialog) => {</div><DialogFooter>- <DialogClose />+ <DialogClose onClick={() => setNewPriority(undefined)} /><Button onClick={setPriority}>{t("confirm")}</Button></DialogFooter></DialogContent>@@ -121,25 +121,26 @@ export const WeightDialog = (props: IDialog) => {const { t } = useLocale();const { isOpenDialog, setIsOpenDialog, option, onChange } = props;const { getValues } = useFormContext<FormValues>();- const [newWeight, setNewWeight] = useState<number>(100);+ const [newWeight, setNewWeight] = useState<number | undefined>();const setWeight = () => {- const hosts: Host[] = getValues("hosts");- const updatedHosts = hosts- .filter((host) => !host.isFixed)- .map((host) => {- return {- ...option,- value: host.userId.toString(),- priority: host.priority,- weight: host.userId === parseInt(option.value, 10) ? newWeight : host.weight,- isFixed: false,- };- });-- const sortedHosts = updatedHosts.sort((a, b) => sortHosts(a, b, true));-- onChange(sortedHosts);+ if (!!newWeight) {+ const hosts: Host[] = getValues("hosts");+ const updatedHosts = hosts+ .filter((host) => !host.isFixed)+ .map((host) => {+ return {+ ...option,+ value: host.userId.toString(),+ priority: host.priority,+ weight: host.userId === parseInt(option.value, 10) ? newWeight : host.weight,+ isFixed: false,+ };+ });++ const sortedHosts = updatedHosts.sort((a, b) => sortHosts(a, b, true));+ onChange(sortedHosts);+ }setIsOpenDialog(false);};@@ -154,6 +155,7 @@ export const WeightDialog = (props: IDialog) => {min={0}label={t("Weight")}value={newWeight}+ defaultValue={option.weight ?? 100}type="number"onChange={(e) => setNewWeight(parseInt(e.target.value))}addOnSuffix={<>%</>}@@ -161,7 +163,7 @@ export const WeightDialog = (props: IDialog) => {</div></div><DialogFooter>- <DialogClose />+ <DialogClose onClick={() => setNewWeight(undefined)} /><Button onClick={setWeight}>{t("confirm")}</Button></DialogFooter></DialogContent>diff --git a/packages/features/eventtypes/components/tabs/assignment/EventTeamAssignmentTab.tsx b/packages/features/eventtypes/components/tabs/assignment/EventTeamAssignmentTab.tsxindex c7046d46bad..f0c7c2770ac 100644--- a/packages/features/eventtypes/components/tabs/assignment/EventTeamAssignmentTab.tsx+++ b/packages/features/eventtypes/components/tabs/assignment/EventTeamAssignmentTab.tsx@@ -151,8 +151,8 @@ const FixedHosts = ({return {isFixed: true,userId: parseInt(teamMember.value, 10),- priority: 2,- weight: 100,+ priority: host?.priority ?? 2,+ weight: host?.weight ?? 100,// if host was already added, retain scheduleIdscheduleId: host?.scheduleId || teamMember.defaultScheduleId,};@@ -202,8 +202,8 @@ const FixedHosts = ({return {isFixed: true,userId: parseInt(teamMember.value, 10),- priority: 2,- weight: 100,+ priority: host?.priority ?? 2,+ weight: host?.weight ?? 100,// if host was already added, retain scheduleIdscheduleId: host?.scheduleId || teamMember.defaultScheduleId,};@@ -292,8 +292,8 @@ const RoundRobinHosts = ({return {isFixed: false,userId: parseInt(teamMember.value, 10),- priority: 2,- weight: 100,+ priority: host?.priority ?? 2,+ weight: host?.weight ?? 100,// if host was already added, retain scheduleIdscheduleId: host?.scheduleId || teamMember.defaultScheduleId,};diff --git a/packages/features/eventtypes/lib/types.ts b/packages/features/eventtypes/lib/types.tsindex 604796ae9eb..3d0390b5b58 100644--- a/packages/features/eventtypes/lib/types.ts+++ b/packages/features/eventtypes/lib/types.ts@@ -2,6 +2,7 @@ import type { z } from "zod";import type { EventLocationType } from "@calcom/core/location";import type { ChildrenEventType } from "@calcom/features/eventtypes/components/ChildrenEventTypeSelect";+import type { AttributesQueryValue } from "@calcom/lib/raqb/types";import type { EventTypeTranslation } from "@calcom/prisma/client";import type { PeriodType, SchedulingType } from "@calcom/prisma/enums";import type { BookerLayoutSettings, EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";@@ -10,7 +11,7 @@ import type { eventTypeBookingFields } from "@calcom/prisma/zod-utils";import type { eventTypeColor } from "@calcom/prisma/zod-utils";import type { RouterOutputs, RouterInputs } from "@calcom/trpc/react";import type { IntervalLimit, RecurringEvent } from "@calcom/types/Calendar";-import type { AttributesQueryValue } from "@calcom/lib/raqb/types";+export type CustomInputParsed = typeof customInputSchema._output;export type AvailabilityOption = {diff --git a/packages/lib/server/queries/teams/index.ts b/packages/lib/server/queries/teams/index.tsindex 3246d172247..a615eb6656b 100644--- a/packages/lib/server/queries/teams/index.ts+++ b/packages/lib/server/queries/teams/index.ts@@ -452,8 +452,7 @@ export async function updateNewTeamMemberEventTypes(userId: number, teamId: numbdurationLimits: (managedEventTypeValues.durationLimits as Prisma.InputJsonValue) ?? undefined,eventTypeColor: (managedEventTypeValues.eventTypeColor as Prisma.InputJsonValue) ?? undefined,rrSegmentQueryValue:- (managedEventTypeValues.rrSegmentQueryValue as Prisma.InputJsonValue) ??- undefined,+ (managedEventTypeValues.rrSegmentQueryValue as Prisma.InputJsonValue) ?? undefined,onlyShowFirstAvailableSlot: managedEventTypeValues.onlyShowFirstAvailableSlot ?? false,userId,users: {diff --git a/packages/trpc/server/routers/viewer/eventTypes/update.handler.ts b/packages/trpc/server/routers/viewer/eventTypes/update.handler.tsindex 954be95e80f..819ac79b75f 100644--- a/packages/trpc/server/routers/viewer/eventTypes/update.handler.ts+++ b/packages/trpc/server/routers/viewer/eventTypes/update.handler.ts@@ -160,9 +160,7 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {bookingFields,isRRWeightsEnabled,rrSegmentQueryValue:- rest.rrSegmentQueryValue === null- ? Prisma.DbNull- : (rest.rrSegmentQueryValue as Prisma.InputJsonValue),+ rest.rrSegmentQueryValue === null ? Prisma.DbNull : (rest.rrSegmentQueryValue as Prisma.InputJsonValue),metadata: rest.metadata === null ? Prisma.DbNull : (rest.metadata as Prisma.InputJsonObject),eventTypeColor: eventTypeColor === null ? Prisma.DbNull : (eventTypeColor as Prisma.InputJsonObject),};