refactor: move shared components from apps/web to packages/features (#27490)

* refactor: move shared components from apps/web to packages/features

Move components that don't require dependency injection:
- DisconnectIntegrationModal
- Booking components (Header, Section, TimeFormatToggle, PayIcon, Price)
- useInitializeWeekStart hook
- TeamEventTypeForm
- Event type components (AssignAllTeamMembers, BulkEditDefaultForEventsModal, etc.)
- Event type dialogs (HostEditDialogs, ManagedEventDialog)
- Location components (LocationInput, types)
- Tab components (EventLimitsTab, EventRecurringTab, etc.)

Co-Authored-By: [email protected] <[email protected]>

* refactor: update import paths to use @calcom/features

Update imports in apps/web and packages/platform/atoms to reference
the moved components from @calcom/features instead of @calcom/web.

Co-Authored-By: [email protected] <[email protected]>

* refactor: delete original files from apps/web/modules

Complete the file move by deleting the original files that were
copied to packages/features. This makes it a proper move instead
of a copy, reducing the PR size significantly.

Co-Authored-By: [email protected] <[email protected]>

* fix: update import paths to use @calcom/features for moved files

Update import paths in apps/web files that reference components
that were moved from apps/web/modules to packages/features:
- LearnMoreLink
- ChildrenEventTypeSelect
- AssignAllTeamMembers
- WeightDescription
- LocationCustomClassNames (types)

Co-Authored-By: [email protected] <[email protected]>

* fix: update additional import paths for moved components

Update import paths in apps/web files that reference components
moved from apps/web/modules to packages/features:
- AppList.tsx: BulkEditDefaultForEventsModal
- schedule-view.tsx: BulkUpdatParams type
- AddMembersWithSwitch.tsx: AssignAllTeamMembers, CheckedTeamSelect
- EventTypeWebWrapper.tsx: ChildrenEventType, ManagedEventDialog
- DefaultLocationSettings.tsx: LocationCustomClassNames, LocationInput
- Locations.tsx: LocationCustomClassNames, LocationInput

Co-Authored-By: [email protected] <[email protected]>

* fix: resolve circular dependency by adding isPlatform prop to Header

This fixes the circular dependency where @calcom/atoms (CalendarViewComponent)
was importing Header from @calcom/features, but Header was importing
useIsPlatform from @calcom/atoms.

The fix adds an isPlatform prop to the Header component so it no longer
needs to import useIsPlatform from @calcom/atoms. Callers now pass the
isPlatform value directly:
- atoms components pass isPlatform={true}
- web components pass the isPlatform prop they receive

Fix confidence: 9/10 (Cubic AI)

Co-Authored-By: unknown <>

* fix

* fix

* fix

* fix

* fix

* fix

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-02-02 10:25:41 -03:00
1 parent e29662b173
commit 8c123ece25
61 files changed
+77 -76

No files matched your search

@@ -0,0 +1,50 @@
import type { Dispatch, SetStateAction } from "react";
import { Controller, useFormContext } from "react-hook-form";
import type { FormValues, SettingsToggleClassNames } from "@calcom/features/eventtypes/lib/types";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { SettingsToggle } from "@calcom/ui/components/form";
import classNames from "@calcom/ui/classNames";
const AssignAllTeamMembers = ({
assignAllTeamMembers,
setAssignAllTeamMembers,
onActive,
onInactive,
customClassNames,
}: {
assignAllTeamMembers: boolean;
setAssignAllTeamMembers: Dispatch<SetStateAction<boolean>>;
onActive: () => void;
onInactive?: () => void;
customClassNames?: SettingsToggleClassNames;
}) => {
const { t } = useLocale();
const { setValue } = useFormContext<FormValues>();
return (
<Controller<FormValues>
name="assignAllTeamMembers"
render={() => (
<SettingsToggle
data-testid="assign-all-team-members-toggle"
title={t("automatically_add_all_team_members")}
labelClassName={classNames("mt-[3px] text-sm", customClassNames?.label)}
switchContainerClassName={customClassNames?.container}
checked={assignAllTeamMembers}
onCheckedChange={(active) => {
setValue("assignAllTeamMembers", active, { shouldDirty: true });
setAssignAllTeamMembers(active);
if (active) {
onActive();
} else if (!!onInactive) {
onInactive();
}
}}
/>
)}
/>
);
};
export default AssignAllTeamMembers;
@@ -0,0 +1,107 @@
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { Dialog } from "@calcom/features/components/controlled-dialog";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Button } from "@calcom/ui/components/button";
import { DialogContent, DialogFooter, DialogClose } from "@calcom/ui/components/dialog";
import { Form } from "@calcom/ui/components/form";
import { CheckboxField } from "@calcom/ui/components/form";
export const BulkUpdateEventSchema = z.object({
eventTypeIds: z.array(z.number()),
});
export type BulkUpdatParams = { eventTypeIds: number[]; callback: () => void };
export type EventTypes = Array<{ id: number; title: string }>;
export function BulkEditDefaultForEventsModal({
eventTypes,
isEventTypesFetching,
...props
}: {
open: boolean;
setOpen: (open: boolean) => void;
bulkUpdateFunction: (params: BulkUpdatParams) => void;
isPending: boolean;
description: string;
isEventTypesFetching?: boolean;
eventTypes?: EventTypes;
handleBulkEditDialogToggle: () => void;
}) {
const { t } = useLocale();
const form = useForm({
resolver: zodResolver(BulkUpdateEventSchema),
defaultValues: {
eventTypeIds: eventTypes?.map((e) => e.id) ?? [],
},
});
const eventTypesSelected = form.watch("eventTypeIds");
const isButtonDisabled = eventTypesSelected.length === 0;
if (isEventTypesFetching || !open || !eventTypes) return null;
return (
<Dialog name="Bulk Default Location Update" open={props.open} onOpenChange={props.setOpen}>
<DialogContent
type="creation"
title={t("default_conferencing_bulk_title")}
description={props.description}
enableOverflow>
<Form
form={form}
handleSubmit={(values) => {
props.bulkUpdateFunction({
eventTypeIds: values.eventTypeIds,
callback: () => props.setOpen(false),
});
}}>
<div className="flex flex-col stack-y-2">
{eventTypes.length > 0 && (
<div className="flex items-center space-x-2 rounded-md px-3 pb-2.5 pt-1">
<CheckboxField
description={t("select_all")}
descriptionAsLabel
onChange={(e) => {
form.setValue("eventTypeIds", e.target.checked ? eventTypes.map((e) => e.id) : []);
}}
checked={eventTypesSelected.length === eventTypes.length}
/>
</div>
)}
{eventTypes.map((eventType) => (
<div key={eventType.id} className="bg-cal-muted flex items-center space-x-2 rounded-md px-3 py-2.5">
<CheckboxField
description={eventType.title}
descriptionAsLabel
checked={eventTypesSelected.includes(eventType.id)}
onChange={(e) => {
form.setValue(
"eventTypeIds",
e.target.checked
? [...eventTypesSelected, eventType.id]
: eventTypesSelected.filter((id) => id !== eventType.id)
);
}}
/>
</div>
))}
</div>
<DialogFooter showDivider className="mt-10">
<DialogClose
onClick={() => {
props.handleBulkEditDialogToggle();
}}
/>
<Button type="submit" color="primary" loading={props.isPending} disabled={isButtonDisabled}>
{t("update")}
</Button>
</DialogFooter>
</Form>
</DialogContent>
</Dialog>
);
}
@@ -0,0 +1,228 @@
"use client";
import { useAutoAnimate } from "@formkit/auto-animate/react";
import { useState } from "react";
import type { Options, Props } from "react-select";
import { useIsPlatform } from "@calcom/atoms/hooks/useIsPlatform";
import type { SelectClassNames } from "@calcom/features/eventtypes/lib/types";
import { getHostsFromOtherGroups } from "@calcom/lib/bookings/hostGroupUtils";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import classNames from "@calcom/ui/classNames";
import { Avatar } from "@calcom/ui/components/avatar";
import { Button } from "@calcom/ui/components/button";
import { Select } from "@calcom/ui/components/form";
import { Icon } from "@calcom/ui/components/icon";
import { Tooltip } from "@calcom/ui/components/tooltip";
import type { PriorityDialogCustomClassNames, WeightDialogCustomClassNames } from "@calcom/features/eventtypes/components/dialogs/HostEditDialogs";
import { PriorityDialog, WeightDialog } from "@calcom/features/eventtypes/components/dialogs/HostEditDialogs";
export type CheckedSelectOption = {
avatar: string;
label: string;
value: string;
priority?: number;
weight?: number;
isFixed?: boolean;
disabled?: boolean;
defaultScheduleId?: number | null;
groupId: string | null;
};
export type CheckedTeamSelectCustomClassNames = {
hostsSelect?: SelectClassNames;
selectedHostList?: {
container?: string;
listItem?: {
container?: string;
avatar?: string;
name?: string;
changePriorityButton?: string;
changeWeightButton?: string;
removeButton?: string;
};
};
priorityDialog?: PriorityDialogCustomClassNames;
weightDialog?: WeightDialogCustomClassNames;
};
export const CheckedTeamSelect = ({
options = [],
value = [],
isRRWeightsEnabled,
customClassNames,
groupId,
...props
}: Omit<Props<CheckedSelectOption, true>, "value" | "onChange"> & {
options?: Options<CheckedSelectOption>;
value?: readonly CheckedSelectOption[];
onChange: (value: readonly CheckedSelectOption[]) => void;
isRRWeightsEnabled?: boolean;
customClassNames?: CheckedTeamSelectCustomClassNames;
groupId: string | null;
}) => {
const isPlatform = useIsPlatform();
const [priorityDialogOpen, setPriorityDialogOpen] = useState(false);
const [weightDialogOpen, setWeightDialogOpen] = useState(false);
const [currentOption, setCurrentOption] = useState(value[0] ?? null);
const { t } = useLocale();
const [animationRef] = useAutoAnimate<HTMLUListElement>();
const valueFromGroup = groupId ? value.filter((host) => host.groupId === groupId) : value;
const handleSelectChange = (newValue: readonly CheckedSelectOption[]) => {
const otherGroupsHosts = getHostsFromOtherGroups(value, groupId);
const newValueAllGroups = [...otherGroupsHosts, ...newValue.map((host) => ({ ...host, groupId }))];
props.onChange(newValueAllGroups);
};
return (
<>
<Select
{...props}
name={props.name}
placeholder={props.placeholder || t("select")}
isSearchable={true}
options={options}
value={valueFromGroup}
onChange={handleSelectChange}
isMulti
className={customClassNames?.hostsSelect?.select}
innerClassNames={{
...customClassNames?.hostsSelect?.innerClassNames,
control: "rounded-md",
}}
/>
{/* This class name conditional looks a bit odd but it allows a seamless transition when using autoanimate
- Slides down from the top instead of just teleporting in from nowhere*/}
<ul
className={classNames(
"mb-4 mt-3 rounded-md",
valueFromGroup.length >= 1 && "border-subtle border",
customClassNames?.selectedHostList?.container
)}
ref={animationRef}>
{valueFromGroup.map((option, index) => (
<>
<li
key={option.value}
className={classNames(
`flex px-3 py-2 ${index === valueFromGroup.length - 1 ? "" : "border-subtle border-b"}`,
customClassNames?.selectedHostList?.listItem?.container
)}>
{!isPlatform && <Avatar size="sm" imageSrc={option.avatar} alt={option.label} />}
{isPlatform && (
<Icon
name="user"
className={classNames(
"mt-0.5 h-4 w-4",
customClassNames?.selectedHostList?.listItem?.avatar
)}
/>
)}
<p
className={classNames(
"text-emphasis my-auto ms-3 text-sm",
customClassNames?.selectedHostList?.listItem?.name
)}>
{option.label}
</p>
<div className="ml-auto flex items-center">
{option && !option.isFixed ? (
<>
<Tooltip content={t("change_priority")}>
<Button
color="minimal"
onClick={() => {
setPriorityDialogOpen(true);
setCurrentOption(option);
}}
className={classNames(
"mr-6 h-2 p-0 text-sm hover:bg-transparent",
getPriorityTextAndColor(option.priority).color,
customClassNames?.selectedHostList?.listItem?.changePriorityButton
)}>
{t(getPriorityTextAndColor(option.priority).text)}
</Button>
</Tooltip>
{isRRWeightsEnabled ? (
<Button
color="minimal"
className={classNames(
"mr-6 h-2 w-4 p-0 text-sm hover:bg-transparent",
customClassNames?.selectedHostList?.listItem?.changeWeightButton
)}
onClick={() => {
setWeightDialogOpen(true);
setCurrentOption(option);
}}>
{option.weight ?? 100}%
</Button>
) : (
<></>
)}
</>
) : (
<></>
)}
<Icon
name="x"
onClick={() => props.onChange(value.filter((item) => item.value !== option.value))}
className={classNames(
"my-auto ml-2 h-4 w-4",
customClassNames?.selectedHostList?.listItem?.removeButton
)}
/>
</div>
</li>
</>
))}
</ul>
{currentOption && !currentOption.isFixed ? (
<>
<PriorityDialog
isOpenDialog={priorityDialogOpen}
setIsOpenDialog={setPriorityDialogOpen}
option={currentOption}
options={options}
onChange={props.onChange}
customClassNames={customClassNames?.priorityDialog}
/>
<WeightDialog
isOpenDialog={weightDialogOpen}
setIsOpenDialog={setWeightDialogOpen}
option={currentOption}
options={options}
onChange={props.onChange}
customClassNames={customClassNames?.weightDialog}
/>
</>
) : (
<></>
)}
</>
);
};
const getPriorityTextAndColor = (priority?: number) => {
switch (priority) {
case 0:
return { text: "lowest", color: "text-gray-300" };
case 1:
return { text: "low", color: "text-gray-400" };
case 2:
return { text: "medium", color: "text-gray-500" };
case 3:
return { text: "high", color: "text-gray-600" };
case 4:
return { text: "highest", color: "text-gray-700" };
default:
return { text: "medium", color: "text-gray-500" };
}
};
export default CheckedTeamSelect;
@@ -0,0 +1,198 @@
import { useAutoAnimate } from "@formkit/auto-animate/react";
import type { Props } from "react-select";
import { getBookerBaseUrlSync } from "@calcom/features/ee/organizations/lib/getBookerBaseUrlSync";
import type { ChildrenEventType } from "@calcom/features/eventtypes/lib/childrenEventType";
import type { SelectClassNames } from "@calcom/features/eventtypes/lib/types";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { MembershipRole } from "@calcom/prisma/enums";
import classNames from "@calcom/ui/classNames";
import { Avatar } from "@calcom/ui/components/avatar";
import { Badge } from "@calcom/ui/components/badge";
import { Button } from "@calcom/ui/components/button";
import { ButtonGroup } from "@calcom/ui/components/buttonGroup";
import { Select } from "@calcom/ui/components/form";
import { Switch } from "@calcom/ui/components/form";
import { Tooltip } from "@calcom/ui/components/tooltip";
export type { ChildrenEventType } from "@calcom/features/eventtypes/lib/childrenEventType";
export type ChildrenEventTypeSelectCustomClassNames = {
assignToSelect?: SelectClassNames;
selectedChildrenList?: {
container?: string;
listItem?: {
container?: string;
avatar?: string;
name?: string;
ownerBadge?: string;
memberBadge?: string;
hiddenBadge?: string;
badgeContainer?: string;
eventLink?: string;
showOnProfileTooltip?: string;
previewEventTypeTooltip?: string;
previewEventTypeButton?: string;
deleteEventTypeTooltip?: string;
deleteEventTypeButton?: string;
};
};
};
// TODO: This isnt just a select... rename this component in the future took me ages to find the component i was looking for
export const ChildrenEventTypeSelect = ({
options = [],
value = [],
customClassNames,
...props
}: Omit<Props<ChildrenEventType, true>, "value" | "onChange"> & {
value?: ChildrenEventType[];
onChange: (value: readonly ChildrenEventType[]) => void;
customClassNames?: ChildrenEventTypeSelectCustomClassNames;
}) => {
const { t } = useLocale();
const [animationRef] = useAutoAnimate<HTMLUListElement>();
return (
<>
<Select
name={props.name}
placeholder={t("select")}
options={options}
className={customClassNames?.assignToSelect?.select}
innerClassNames={customClassNames?.assignToSelect?.innerClassNames}
value={value}
isMulti
{...props}
/>
{/* This class name conditional looks a bit odd but it allows a seamless transition when using autoanimate
- Slides down from the top instead of just teleporting in from nowhere*/}
<ul
className={classNames(
"border-subtle divide-subtle mt-3 divide-y rounded-md",
value.length >= 1 && "border",
customClassNames?.selectedChildrenList?.container
)}
ref={animationRef}>
{value.map((children, index) => (
<li key={index}>
<div
className={classNames(
"flex flex-row items-center gap-3 p-3",
customClassNames?.selectedChildrenList?.listItem?.container
)}>
<Avatar
size="mdLg"
className={classNames(
"overflow-visible",
customClassNames?.selectedChildrenList?.listItem?.avatar
)}
imageSrc={children.owner.avatar}
alt={children.owner.name || children.owner.email || ""}
/>
<div className="flex w-full flex-row justify-between">
<div className="flex flex-col">
<span
className={classNames(
"text text-sm font-semibold leading-none",
customClassNames?.selectedChildrenList?.listItem?.name
)}>
{children.owner.name || children.owner.email}
<div
className={classNames(
"flex flex-row gap-1",
customClassNames?.selectedChildrenList?.listItem?.badgeContainer
)}>
{children.owner.membership === MembershipRole.OWNER ? (
<Badge
variant="gray"
className={customClassNames?.selectedChildrenList?.listItem?.ownerBadge}>
{t("owner")}
</Badge>
) : (
<Badge
variant="gray"
className={customClassNames?.selectedChildrenList?.listItem?.memberBadge}>
{t("member")}
</Badge>
)}
{children.hidden && (
<Badge
variant="gray"
className={customClassNames?.selectedChildrenList?.listItem?.hiddenBadge}>
{t("hidden")}
</Badge>
)}
</div>
</span>
{children.owner.username && (
<small
className={classNames(
"text-subtle font-normal leading-normal",
customClassNames?.selectedChildrenList?.listItem?.eventLink
)}>
{`/${children.owner.username}/${children.slug}`}
</small>
)}
</div>
<div className={classNames("flex flex-row items-center gap-2")}>
<Tooltip
className={customClassNames?.selectedChildrenList?.listItem?.showOnProfileTooltip}
content={t("show_eventtype_on_profile")}>
<div className="self-center rounded-md p-2">
<Switch
name="Hidden"
checked={!children.hidden}
onCheckedChange={(checked) => {
const newData = value.map((item) =>
item.owner.id === children.owner.id ? { ...item, hidden: !checked } : item
);
props.onChange(newData);
}}
/>
</div>
</Tooltip>
<ButtonGroup combined>
{children.created && children.owner.username && (
<Tooltip
className={customClassNames?.selectedChildrenList?.listItem?.previewEventTypeTooltip}
content={t("preview")}>
<Button
data-testid="preview-button"
color="secondary"
target="_blank"
variant="icon"
className={customClassNames?.selectedChildrenList?.listItem?.previewEventTypeButton}
href={`${getBookerBaseUrlSync(
children.owner.profile?.organization?.slug ?? null
)}/${children.owner?.username}/${children.slug}`}
StartIcon="external-link"
/>
</Tooltip>
)}
<Tooltip
className={customClassNames?.selectedChildrenList?.listItem?.deleteEventTypeTooltip}
content={t("delete")}>
<Button
color="secondary"
target="_blank"
variant="icon"
className={customClassNames?.selectedChildrenList?.listItem?.deleteEventTypeButton}
onClick={() =>
props.onChange(value.filter((item) => item.owner.id !== children.owner.id))
}
StartIcon="x"
/>
</Tooltip>
</ButtonGroup>
</div>
</div>
</div>
</li>
))}
</ul>
</>
);
};
export default ChildrenEventTypeSelect;
@@ -0,0 +1,155 @@
import type { ReactNode } from "react";
import { useState } from "react";
import type { UseFormReturn } from "react-hook-form";
import { useIsPlatform } from "@calcom/atoms/hooks/useIsPlatform";
import type { CreateEventTypeFormValues } from "@calcom/features/eventtypes/hooks/useCreateEventType";
import { MAX_EVENT_DURATION_MINUTES, MIN_EVENT_DURATION_MINUTES } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { md } from "@calcom/lib/markdownIt";
import slugify from "@calcom/lib/slugify";
import turndown from "@calcom/lib/turndownService";
import { Editor } from "@calcom/ui/components/editor";
import { Form } from "@calcom/ui/components/form";
import { TextAreaField } from "@calcom/ui/components/form";
import { TextField } from "@calcom/ui/components/form";
import { Tooltip } from "@calcom/ui/components/tooltip";
export default function CreateEventTypeForm({
form,
isManagedEventType,
handleSubmit,
pageSlug,
isPending,
urlPrefix,
SubmitButton,
}: {
form: UseFormReturn<CreateEventTypeFormValues>;
isManagedEventType: boolean;
handleSubmit: (values: CreateEventTypeFormValues) => void;
pageSlug?: string;
isPending: boolean;
urlPrefix?: string;
SubmitButton: (isPending: boolean) => ReactNode;
}) {
const isPlatform = useIsPlatform();
const { t } = useLocale();
const [firstRender, setFirstRender] = useState(true);
const { register } = form;
return (
<Form
form={form}
handleSubmit={(values) => {
handleSubmit(values);
}}>
<div className="mt-3 stack-y-6 pb-11">
<TextField
label={t("title")}
placeholder={t("quick_chat")}
data-testid="event-type-quick-chat"
{...register("title")}
onChange={(e) => {
form.setValue("title", e?.target.value);
if (form.formState.touchedFields["slug"] === undefined) {
form.setValue("slug", slugify(e?.target.value));
}
}}
/>
{urlPrefix && urlPrefix.length >= 21 ? (
<div>
<TextField
label={isPlatform ? "Slug" : `${t("url")}: ${urlPrefix}`}
required
addOnLeading={
!isPlatform ? (
<span className="max-w-24 md:max-w-56 inline-block overflow-hidden text-ellipsis whitespace-nowrap min-w-0">
{`/${!isManagedEventType ? pageSlug : t("username_placeholder")}/`}
</span>
) : undefined
}
containerClassName="[&>div]:gap-0"
className="pl-0"
{...register("slug")}
onChange={(e) => {
form.setValue("slug", slugify(e?.target.value), { shouldTouch: true });
}}
/>
{isManagedEventType && !isPlatform && (
<p className="mt-2 text-sm text-gray-600">{t("managed_event_url_clarification")}</p>
)}
</div>
) : (
<div>
<TextField
label={isPlatform ? "Slug" : t("url")}
required
addOnLeading={
!isPlatform ? (
<Tooltip
content={`${urlPrefix}/${!isManagedEventType ? pageSlug : t("username_placeholder")}/`}>
<span className="max-w-24 md:max-w-56 inline-block overflow-hidden text-ellipsis whitespace-nowrap min-w-0">
{`${urlPrefix}/${!isManagedEventType ? pageSlug : t("username_placeholder")}/`}
</span>
</Tooltip>
) : undefined
}
containerClassName="[&>div]:gap-0"
className="pl-0"
{...register("slug")}
onChange={(e) => {
form.setValue("slug", slugify(e?.target.value), { shouldTouch: true });
}}
/>
{isManagedEventType && !isPlatform && (
<p className="mt-2 text-sm text-gray-600">{t("managed_event_url_clarification")}</p>
)}
</div>
)}
<>
{isPlatform ? (
<TextAreaField {...register("description")} placeholder={t("quick_video_meeting")} />
) : (
<Editor
label={t("description")}
getText={() => md.render(form.getValues("description") || "")}
setText={(value: string) => form.setValue("description", turndown(value))}
excludedToolbarItems={["blockType", "link"]}
placeholder={t("quick_video_meeting")}
firstRender={firstRender}
setFirstRender={setFirstRender}
maxHeight="200px"
/>
)}
<div className="relative">
<TextField
type="number"
required
min={MIN_EVENT_DURATION_MINUTES}
max={MAX_EVENT_DURATION_MINUTES}
placeholder="15"
label={t("duration")}
className="pr-4"
{...register("length", {
valueAsNumber: true,
min: {
value: MIN_EVENT_DURATION_MINUTES,
message: t("duration_min_error", { min: MIN_EVENT_DURATION_MINUTES }),
},
max: {
value: MAX_EVENT_DURATION_MINUTES,
message: t("duration_max_error", { max: MAX_EVENT_DURATION_MINUTES }),
},
})}
addOnSuffix={t("minutes").toLowerCase()}
/>
</div>
</>
</div>
{SubmitButton(isPending)}
</Form>
);
}
@@ -0,0 +1,37 @@
import type { TFunction } from "i18next";
import Link from "next/link";
import ServerTrans from "@calcom/lib/components/ServerTrans";
import { IS_CALCOM } from "@calcom/lib/constants";
type LearnMoreLinkProps = {
t: TFunction;
i18nKey: string;
href: string;
};
export const LearnMoreLink = ({ t, i18nKey, href }: LearnMoreLinkProps) => {
if (!IS_CALCOM) {
const text = t(i18nKey)
.replace(/<0>[\s\S]*?<\/0>/g, "")
.trim();
return <>{text}</>;
}
return (
<ServerTrans
t={t}
i18nKey={i18nKey}
components={[
<Link
key={i18nKey}
className="underline underline-offset-2"
target="_blank"
rel="noopener noreferrer"
href={href}>
Learn more
</Link>,
]}
/>
);
};
@@ -0,0 +1,22 @@
import type { TFunction } from "i18next";
import Link from "next/link";
import ServerTrans from "@calcom/lib/components/ServerTrans";
export default function WeightDescription({ t }: { t: TFunction }) {
return (
<ServerTrans
t={t}
i18nKey="weights_description"
components={[
<Link
key="weights_description"
className="underline underline-offset-2"
target="_blank"
href="https://cal.com/docs/enterprise-features/teams/round-robin-scheduling#weights">
Learn more
</Link>,
]}
/>
);
}
@@ -0,0 +1,244 @@
import type { Dispatch, SetStateAction } from "react";
import { useState } from "react";
import { useFormContext } from "react-hook-form";
import type { Options } from "react-select";
import { Dialog } from "@calcom/features/components/controlled-dialog";
import type {
FormValues,
Host,
InputClassNames,
SelectClassNames,
} from "@calcom/features/eventtypes/lib/types";
import { groupHostsByGroupId, getHostsFromOtherGroups, sortHosts } from "@calcom/lib/bookings/hostGroupUtils";
import { DEFAULT_GROUP_ID } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import classNames from "@calcom/ui/classNames";
import { Button } from "@calcom/ui/components/button";
import { DialogContent, DialogFooter, DialogClose } from "@calcom/ui/components/dialog";
import { Label } from "@calcom/ui/components/form";
import { Select } from "@calcom/ui/components/form";
import { TextField } from "@calcom/ui/components/form";
import type { CheckedSelectOption } from "@calcom/features/eventtypes/components/CheckedTeamSelect";
import WeightDescription from "@calcom/features/eventtypes/components/WeightDescription";
interface IDialog {
isOpenDialog: boolean;
setIsOpenDialog: Dispatch<SetStateAction<boolean>>;
option: CheckedSelectOption;
options: Options<CheckedSelectOption>;
onChange: (value: readonly CheckedSelectOption[]) => void;
}
export type PriorityDialogCustomClassNames = SelectClassNames & {
confirmButton?: string;
};
export const PriorityDialog = (
props: IDialog & {
customClassNames?: PriorityDialogCustomClassNames;
}
) => {
const { t } = useLocale();
const { isOpenDialog, setIsOpenDialog, option, options, onChange, customClassNames } = props;
const { getValues } = useFormContext<FormValues>();
const priorityOptions = [
{ label: t("lowest"), value: 0 },
{ label: t("low"), value: 1 },
{ label: t("medium"), value: 2 },
{ label: t("high"), value: 3 },
{ label: t("highest"), value: 4 },
];
const [newPriority, setNewPriority] = useState<{ label: string; value: number }>();
const setPriority = () => {
if (!!newPriority) {
const hosts: Host[] = getValues("hosts");
const isRRWeightsEnabled = getValues("isRRWeightsEnabled");
const hostGroups = getValues("hostGroups");
const rrHosts = hosts.filter((host) => !host.isFixed);
const groupedHosts = groupHostsByGroupId({ hosts: rrHosts, hostGroups });
let sortedHostGroup: CheckedSelectOption[] = [];
const hostGroupToSort = groupedHosts[option.groupId ?? DEFAULT_GROUP_ID];
if (hostGroupToSort) {
sortedHostGroup = hostGroupToSort
.map((host) => {
return {
...option,
value: host.userId.toString(),
priority: host.userId === parseInt(option.value, 10) ? newPriority.value : host.priority,
isFixed: false,
weight: host.weight,
groupId: host.groupId,
userId: host.userId,
};
})
.sort((a, b) => sortHosts(a, b, isRRWeightsEnabled));
}
const otherGroupsHosts = getHostsFromOtherGroups(rrHosts, option.groupId);
const otherGroupsOptions = otherGroupsHosts.map((host) => {
return {
...option,
value: host.userId.toString(),
priority: host.priority,
weight: host.weight,
isFixed: host.isFixed,
groupId: host.groupId,
userId: host.userId,
};
});
const updatedHosts = [...otherGroupsOptions, ...sortedHostGroup];
onChange(updatedHosts);
}
setIsOpenDialog(false);
};
return (
<Dialog open={isOpenDialog} onOpenChange={setIsOpenDialog}>
<DialogContent title={t("set_priority")}>
<div className={classNames("mb-4", customClassNames?.container)}>
<Label className={customClassNames?.label}>
{t("priority_for_user", { userName: option.label })}
</Label>
<Select
defaultValue={priorityOptions[option.priority ?? 2]}
className={customClassNames?.select}
innerClassNames={customClassNames?.innerClassNames}
value={newPriority}
onChange={(value) => setNewPriority(value ?? priorityOptions[2])}
options={priorityOptions}
/>
</div>
<DialogFooter>
<DialogClose onClick={() => setNewPriority(undefined)} />
<Button onClick={setPriority} className={customClassNames?.confirmButton}>
{t("confirm")}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
);
};
export type WeightDialogCustomClassNames = {
container?: string;
label?: string;
confirmButton?: string;
weightInput?: InputClassNames;
};
export const WeightDialog = (props: IDialog & { customClassNames?: WeightDialogCustomClassNames }) => {
const { t } = useLocale();
const { isOpenDialog, setIsOpenDialog, option, options, onChange, customClassNames } = props;
const { getValues } = useFormContext<FormValues>();
const [newWeight, setNewWeight] = useState<number | undefined>();
const setWeight = () => {
if (!!newWeight) {
const hosts: Host[] = getValues("hosts");
const isRRWeightsEnabled = getValues("isRRWeightsEnabled");
const hostGroups = getValues("hostGroups");
const rrHosts = hosts.filter((host) => !host.isFixed);
const groupedHosts = groupHostsByGroupId({ hosts: rrHosts, hostGroups });
const updateHostWeight = (host: Host) => {
if (host.userId === parseInt(option.value, 10)) {
return { ...host, weight: newWeight };
}
return host;
};
// Sort hosts within the group
let sortedHostGroup: (Host & {
avatar: string;
label: string;
})[] = [];
const hostGroupToSort = groupedHosts[option.groupId ?? DEFAULT_GROUP_ID];
if (hostGroupToSort) {
sortedHostGroup = hostGroupToSort
.map((host) => {
const userOption = options.find((opt) => opt.value === host.userId.toString());
const updatedHost = updateHostWeight(host);
return {
...updatedHost,
avatar: userOption?.avatar ?? "",
label: userOption?.label ?? host.userId.toString(),
};
})
.sort((a, b) => sortHosts(a, b, isRRWeightsEnabled));
}
const updatedOptions = sortedHostGroup.map((host) => ({
avatar: host.avatar,
label: host.label,
value: host.userId.toString(),
priority: host.priority,
weight: host.weight,
isFixed: host.isFixed,
groupId: host.groupId,
}));
// Preserve hosts from other groups
const otherGroupsHosts = getHostsFromOtherGroups(rrHosts, option.groupId);
const otherGroupsOptions = otherGroupsHosts.map((host) => {
const userOption = options.find((opt) => opt.value === host.userId.toString());
return {
avatar: userOption?.avatar ?? "",
label: userOption?.label ?? host.userId.toString(),
value: host.userId.toString(),
priority: host.priority,
weight: host.weight,
isFixed: host.isFixed,
groupId: host.groupId,
};
});
const newFullValue = [...otherGroupsOptions, ...updatedOptions];
onChange(newFullValue);
}
setIsOpenDialog(false);
};
return (
<Dialog open={isOpenDialog} onOpenChange={setIsOpenDialog}>
<DialogContent title={t("set_weight")} description={<WeightDescription t={t} />}>
<div className={classNames("mb-4 mt-2", customClassNames?.container)}>
<Label className={customClassNames?.label}>
{t("weight_for_user", { userName: option.label })}
</Label>
<div className={classNames("w-36", customClassNames?.weightInput?.container)}>
<TextField
required
min={0}
className={customClassNames?.weightInput?.input}
labelClassName={customClassNames?.weightInput?.label}
addOnClassname={customClassNames?.weightInput?.addOn}
label={t("Weight")}
value={newWeight}
defaultValue={option.weight ?? 100}
type="number"
onChange={(e) => setNewWeight(parseInt(e.target.value))}
addOnSuffix={<>%</>}
/>
</div>
</div>
<DialogFooter>
<DialogClose onClick={() => setNewWeight(undefined)} />
<Button onClick={setWeight} className={customClassNames?.confirmButton}>
{t("confirm")}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
);
};
@@ -0,0 +1,55 @@
import type { ChildrenEventType } from "@calcom/features/eventtypes/components/ChildrenEventTypeSelect";
import ServerTrans from "@calcom/lib/components/ServerTrans";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { ConfirmationDialogContent, Dialog } from "@calcom/ui/components/dialog";
interface ManagedEventDialogProps {
slugExistsChildrenDialogOpen: ChildrenEventType[];
slug: string;
onOpenChange: () => void;
isPending: boolean;
onConfirm: (e: { preventDefault: () => void }) => void;
}
export default function ManagedEventDialog(props: ManagedEventDialogProps) {
const { t } = useLocale();
const { slugExistsChildrenDialogOpen, slug, onOpenChange, isPending, onConfirm } = props;
return (
<Dialog open={slugExistsChildrenDialogOpen.length > 0} onOpenChange={onOpenChange}>
<ConfirmationDialogContent
isPending={isPending}
variety="warning"
title={t("managed_event_dialog_title", {
slug,
count: slugExistsChildrenDialogOpen.length,
})}
confirmBtnText={t("managed_event_dialog_confirm_button", {
count: slugExistsChildrenDialogOpen.length,
})}
cancelBtnText={t("go_back")}
onConfirm={onConfirm}>
<p className="mt-5">
<ServerTrans
t={t}
i18nKey={
slugExistsChildrenDialogOpen.length > 1
? "managed_event_dialog_information_other"
: "managed_event_dialog_information_one"
}
values={{
names: `${slugExistsChildrenDialogOpen
.map((ch) => ch.owner.name)
.slice(0, -1)
.join(", ")} ${
slugExistsChildrenDialogOpen.length > 1 ? t("and") : ""
} ${slugExistsChildrenDialogOpen.map((ch) => ch.owner.name).slice(-1)}`,
slug,
}}
/>
</p>{" "}
<p className="mt-5">{t("managed_event_dialog_clarification")}</p>
</ConfirmationDialogContent>
</Dialog>
);
}
@@ -0,0 +1,76 @@
import { useFormContext, Controller } from "react-hook-form";
import type { EventLocationType } from "@calcom/app-store/locations";
import PhoneInput from "@calcom/features/components/phone-input";
import type { FormValues } from "@calcom/features/eventtypes/lib/types";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import classNames from "@calcom/ui/classNames";
import { TextField } from "@calcom/ui/components/form";
import type { LocationInputCustomClassNames } from "./types";
const LocationInput = (props: {
eventLocationType: EventLocationType;
defaultValue?: string;
index: number;
customClassNames?: LocationInputCustomClassNames;
disableLocationProp?: boolean;
label?: string | null;
}) => {
const { t } = useLocale();
const { eventLocationType, index, customClassNames, disableLocationProp, label, ...remainingProps } = props;
const formMethods = useFormContext<FormValues>();
if (eventLocationType?.organizerInputType === "text") {
const { defaultValue, ...rest } = remainingProps;
return (
<Controller
name={`locations.${index}.${eventLocationType.defaultValueVariable}`}
defaultValue={defaultValue}
render={({ field: { onChange, value } }) => {
return (
<TextField
label={label ? t(label) : null}
name={`locations[${index}].${eventLocationType.defaultValueVariable}`}
placeholder={t(eventLocationType.organizerInputPlaceholder || "")}
type="text"
required
onChange={onChange}
value={value}
{...(disableLocationProp ? { disabled: true } : {})}
className={classNames("my-0", customClassNames?.addressInput)}
{...rest}
/>
);
}}
/>
);
} else if (eventLocationType?.organizerInputType === "phone") {
const { defaultValue, ...rest } = remainingProps;
return (
<Controller
name={`locations.${index}.${eventLocationType.defaultValueVariable}`}
defaultValue={defaultValue}
render={({ field: { onChange, value } }) => {
return (
<PhoneInput
required
disabled={disableLocationProp}
placeholder={t(eventLocationType.organizerInputPlaceholder || "")}
name={`locations[${index}].${eventLocationType.defaultValueVariable}`}
className={customClassNames?.phoneInput}
value={value}
onChange={onChange}
{...rest}
/>
);
}}
/>
);
}
return null;
};
export default LocationInput;
@@ -0,0 +1,25 @@
import type { LocationSelectCustomClassNames } from "@calcom/features/form/components/LocationSelect";
export type LocationCustomClassNames = {
container?: string;
locationSelect?: LocationSelectCustomClassNames;
removeLocationButton?: string;
removeLocationIcon?: string;
addLocationButton?: string;
organizerContactInput?: {
errorMessage?: string;
locationInput?: LocationInputCustomClassNames;
publicDisplayCheckbox?: CheckboxClassNames;
};
};
export type LocationInputCustomClassNames = {
addressInput?: string;
phoneInput?: string;
};
export type CheckboxClassNames = {
container?: string;
label?: string;
checkbox?: string;
};
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,100 @@
import { useState } from "react";
import { Controller, useFormContext } from "react-hook-form";
import { LearnMoreLink } from "@calcom/features/eventtypes/components/LearnMoreLink";
import type { FormValues } from "@calcom/features/eventtypes/lib/types";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import classNames from "@calcom/ui/classNames";
import { SettingsToggle } from "@calcom/ui/components/form";
import { TextField, CheckboxField } from "@calcom/ui/components/form";
type maxActiveBookingsPerBookerLockedProps = {
disabled: boolean;
LockedIcon: false | JSX.Element;
isLocked: boolean;
};
export default function MaxActiveBookingsPerBookerController({
maxActiveBookingsPerBookerLocked,
}: {
maxActiveBookingsPerBookerLocked: maxActiveBookingsPerBookerLockedProps;
}) {
const { t } = useLocale();
const formMethods = useFormContext<FormValues>();
const [maxActiveBookingsPerBookerToggle, setMaxActiveBookingsPerBookerToggle] = useState(
(formMethods.getValues("maxActiveBookingsPerBooker") ?? 0) > 0
);
const isRecurringEvent = !!formMethods.getValues("recurringEvent");
const maxActiveBookingPerBookerOfferReschedule = formMethods.watch(
"maxActiveBookingPerBookerOfferReschedule"
);
return (
<Controller
name="maxActiveBookingsPerBooker"
render={({ field: { onChange, value } }) => {
const isChecked = maxActiveBookingsPerBookerToggle;
return (
<SettingsToggle
labelClassName={classNames("text-sm")}
{...maxActiveBookingsPerBookerLocked}
disabled={isRecurringEvent || maxActiveBookingsPerBookerLocked.disabled}
tooltip={isRecurringEvent ? t("recurring_event_doesnt_support_booker_booking_limit") : ""}
toggleSwitchAtTheEnd={true}
switchContainerClassName={classNames(
"border-subtle mt-6 rounded-lg border py-6 px-4 sm:px-6",
isChecked && "rounded-b-none"
)}
childrenClassName={classNames("lg:ml-0")}
title={t("booker_upcoming_limit")}
description={
<LearnMoreLink
t={t}
i18nKey="booker_booking_limit_description"
href="https://cal.com/help/event-types/booker-active-booking-limit"
/>
}
checked={isChecked}
onCheckedChange={(active) => {
if (active) {
onChange(1);
} else {
onChange(null);
}
setMaxActiveBookingsPerBookerToggle((state) => !state);
}}>
<div className="border-subtle rounded-b-lg border border-t-0 p-6">
<TextField
required
type="number"
value={value ?? ""}
disabled={maxActiveBookingsPerBookerLocked.disabled}
onChange={(e) => {
onChange(e.target.value === "" ? null : parseInt(e.target.value, 10));
}}
min={1}
step={1}
containerClassName={classNames("max-w-80")}
addOnSuffix="bookings"
data-testid="booker-booking-limit-input"
/>
<CheckboxField
checked={!!maxActiveBookingPerBookerOfferReschedule}
descriptionAsLabel
description={t("reschedule_last_booking_offer")}
disabled={maxActiveBookingsPerBookerLocked.disabled}
onChange={(e) => {
formMethods.setValue("maxActiveBookingPerBookerOfferReschedule", e.target.checked, {
shouldDirty: true,
});
}}
/>
</div>
</SettingsToggle>
);
}}
/>
);
}
@@ -0,0 +1,24 @@
import { getPaymentAppData } from "@calcom/app-store/_utils/payments/getPaymentAppData";
import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils";
import type { RecurringEventControllerProps } from "./RecurringEventController";
import RecurringEventController from "./RecurringEventController";
export type EventRecurringTabProps = Omit<RecurringEventControllerProps, "paymentEnabled">;
export const EventRecurringTab = ({ eventType, customClassNames }: EventRecurringTabProps) => {
const paymentAppData = getPaymentAppData({
...eventType,
metadata: eventTypeMetaDataSchemaWithTypedApps.parse(eventType.metadata),
});
const requirePayment = paymentAppData.price > 0;
return (
<RecurringEventController
paymentEnabled={requirePayment}
eventType={eventType}
customClassNames={customClassNames}
/>
);
};
@@ -0,0 +1,220 @@
import { useState } from "react";
import { useFormContext } from "react-hook-form";
import useLockedFieldsManager from "@calcom/features/ee/managed-event-types/hooks/useLockedFieldsManager";
import { LearnMoreLink } from "@calcom/features/eventtypes/components/LearnMoreLink";
import type {
EventTypeSetup,
InputClassNames,
SelectClassNames,
SettingsToggleClassNames,
} from "@calcom/features/eventtypes/lib/types";
import type { FormValues } from "@calcom/features/eventtypes/lib/types";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Frequency } from "@calcom/prisma/zod-utils";
import type { RecurringEvent } from "@calcom/types/Calendar";
import classNames from "@calcom/ui/classNames";
import { Alert } from "@calcom/ui/components/alert";
import { Select } from "@calcom/ui/components/form";
import { SettingsToggle } from "@calcom/ui/components/form";
import { TextField } from "@calcom/ui/components/form";
export type RecurringEventControllerProps = {
eventType: EventTypeSetup;
paymentEnabled: boolean;
customClassNames?: EventRecurringTabCustomClassNames;
};
export type EventRecurringTabCustomClassNames = {
container?: string;
recurringToggle?: SettingsToggleClassNames;
frequencyInput?: InputClassNames;
frequencyUnitSelect?: SelectClassNames;
maxEventsInput?: {
countInput?: string;
labelText?: string;
suffixText?: string;
container?: string;
};
experimentalAlert?: string;
paymentAlert?: string;
};
export default function RecurringEventController({
eventType,
paymentEnabled,
customClassNames,
}: RecurringEventControllerProps) {
const { t } = useLocale();
const formMethods = useFormContext<FormValues>();
const [recurringEventState, setRecurringEventState] = useState<RecurringEvent | null>(
formMethods.getValues("recurringEvent")
);
const isSeatsOffered = !!formMethods.getValues("seatsPerTimeSlot");
const hasBookingLimitPerBooker = !!formMethods.getValues("maxActiveBookingsPerBooker");
/* Just yearly-0, monthly-1 and weekly-2 */
const recurringEventFreqOptions = Object.entries(Frequency)
.filter(([key, value]) => isNaN(Number(key)) && Number(value) < 3)
.map(([key, value]) => ({
label: t(`${key.toString().toLowerCase()}`, { count: recurringEventState?.interval }),
value: value.toString(),
}));
const { shouldLockDisableProps } = useLockedFieldsManager({ eventType, translate: t, formMethods });
const recurringLocked = shouldLockDisableProps("recurringEvent");
return (
<div className={classNames("block items-start sm:flex", customClassNames?.container)}>
<div className={!paymentEnabled ? "w-full" : ""}>
{paymentEnabled ? (
<Alert
severity="warning"
className={customClassNames?.paymentAlert}
title={t("warning_payment_recurring_event")}
/>
) : (
<>
<Alert
className={classNames("mb-4", customClassNames?.experimentalAlert)}
severity="warning"
title="Experimental: Recurring Events are currently experimental and causes some issues sometimes when checking for availability. We are working on fixing this."
/>
<SettingsToggle
labelClassName={classNames("text-sm", customClassNames?.recurringToggle?.label)}
toggleSwitchAtTheEnd={true}
switchContainerClassName={classNames(
"border-subtle rounded-lg border py-6 px-4 sm:px-6",
recurringEventState !== null && "rounded-b-none",
customClassNames?.recurringToggle?.container
)}
childrenClassName={classNames("lg:ml-0", customClassNames?.recurringToggle?.children)}
descriptionClassName={customClassNames?.recurringToggle?.description}
title={t("recurring_event")}
{...recurringLocked}
description={
<LearnMoreLink
t={t}
i18nKey="recurring_event_description"
href="https://cal.com/help/event-types/recurring-events"
/>
}
checked={!!recurringEventState}
data-testid="recurring-event-check"
disabled={(!recurringEventState && isSeatsOffered) || hasBookingLimitPerBooker}
tooltip={
isSeatsOffered
? t("seats_doesnt_support_recurring")
: hasBookingLimitPerBooker
? t("booking_limit_per_booker_doesnt_support_recurring")
: undefined
}
onCheckedChange={(e) => {
if (!e) {
formMethods.setValue("recurringEvent", null, { shouldDirty: true });
setRecurringEventState(null);
} else {
const newVal = eventType.recurringEvent || {
interval: 1,
count: 12,
freq: Frequency.WEEKLY,
};
formMethods.setValue("recurringEvent", newVal, { shouldDirty: true });
setRecurringEventState(newVal);
}
}}>
<div className="border-subtle rounded-b-lg border border-t-0 p-6">
{recurringEventState && (
<div data-testid="recurring-event-collapsible" className="text-sm">
<div className="flex items-center">
<p
className={classNames(
"text-emphasis ltr:mr-2 rtl:ml-2",
customClassNames?.frequencyInput?.label
)}>
{t("repeats_every")}
</p>
<TextField
disabled={recurringLocked.disabled}
type="number"
min="1"
max="20"
className={classNames("mb-0", customClassNames?.frequencyInput?.input)}
defaultValue={recurringEventState.interval}
onChange={(event) => {
const newVal = {
...recurringEventState,
interval: parseInt(event?.target.value),
};
formMethods.setValue("recurringEvent", newVal, { shouldDirty: true });
setRecurringEventState(newVal);
}}
/>
<Select
options={recurringEventFreqOptions}
value={recurringEventFreqOptions[recurringEventState.freq]}
isSearchable={false}
className={classNames(
"w-18 ml-2 block min-w-0 rounded-md text-sm",
customClassNames?.frequencyUnitSelect?.select
)}
innerClassNames={customClassNames?.frequencyUnitSelect?.innerClassNames}
isDisabled={recurringLocked.disabled}
onChange={(event) => {
const newVal = {
...recurringEventState,
freq: parseInt(event?.value || `${Frequency.WEEKLY}`),
};
formMethods.setValue("recurringEvent", newVal, { shouldDirty: true });
setRecurringEventState(newVal);
}}
/>
</div>
<div
className={classNames(
"mt-4 flex items-center",
customClassNames?.maxEventsInput?.container
)}>
<p
className={classNames(
"text-emphasis ltr:mr-2 rtl:ml-2",
customClassNames?.maxEventsInput?.labelText
)}>
{t("for_a_maximum_of")}
</p>
<TextField
disabled={recurringLocked.disabled}
type="number"
min="1"
max="24"
defaultValue={recurringEventState.count}
className={classNames("mb-0", customClassNames?.maxEventsInput?.countInput)}
onChange={(event) => {
const newVal = {
...recurringEventState,
count: parseInt(event?.target.value),
};
formMethods.setValue("recurringEvent", newVal, { shouldDirty: true });
setRecurringEventState(newVal);
}}
/>
<p
className={classNames(
"text-emphasis ltr:ml-2 rtl:mr-2",
customClassNames?.maxEventsInput?.suffixText
)}>
{t("events", {
count: recurringEventState.count,
})}
</p>
</div>
</div>
)}
</div>
</SettingsToggle>
</>
)}
</div>
</div>
);
}