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

@@ -9,8 +9,8 @@ import { getPaymentAppData } from "@calcom/app-store/_utils/payments/getPaymentA
import { getSuccessPageLocationMessage } from "@calcom/app-store/locations";
import dayjs from "@calcom/dayjs";
import { sdkActionManager, useIsEmbed } from "@calcom/embed-core/embed-iframe";
import { PayIcon } from "@calcom/web/modules/bookings/components/event-meta/PayIcon";
import { Price } from "@calcom/web/modules/bookings/components/event-meta/Price";
import { PayIcon } from "@calcom/features/bookings/components/event-meta/PayIcon";
import { Price } from "@calcom/features/bookings/components/event-meta/Price";
import type { PaymentPageProps } from "@calcom/features/ee/payments/pages/payment";
import { APP_NAME, WEBSITE_URL } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
+2 -2
View File
@@ -10,8 +10,8 @@ import { AppSetDefaultLinkDialog } from "@calcom/web/modules/apps/components/App
import type {
BulkUpdatParams,
EventTypes,
} from "@calcom/web/modules/event-types/components/BulkEditDefaultForEventsModal";
import { BulkEditDefaultForEventsModal } from "@calcom/web/modules/event-types/components/BulkEditDefaultForEventsModal";
} from "@calcom/features/eventtypes/components/BulkEditDefaultForEventsModal";
import { BulkEditDefaultForEventsModal } from "@calcom/features/eventtypes/components/BulkEditDefaultForEventsModal";
import { isDelegationCredential } from "@calcom/lib/delegationCredential";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import type { AppCategories } from "@calcom/prisma/enums";
@@ -12,7 +12,7 @@ import { SkeletonText, SkeletonContainer } from "@calcom/ui/components/skeleton"
import { showToast } from "@calcom/ui/components/toast";
import { AppList } from "./AppList";
import DisconnectIntegrationModal from "./DisconnectIntegrationModal";
import DisconnectIntegrationModal from "@calcom/features/apps/components/DisconnectIntegrationModal";
type UpdateUsersDefaultConferencingAppParams = {
appSlug: string;
@@ -1,49 +0,0 @@
import { useIsPlatform } from "@calcom/atoms/hooks/useIsPlatform";
import { Dialog } from "@calcom/features/components/controlled-dialog";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import type { App } from "@calcom/types/App";
import { ConfirmationDialogContent } from "@calcom/ui/components/dialog";
export type RemoveAppParams = {
credentialId: number;
app?: App["slug"];
teamId?: number;
callback: () => void;
};
interface DisconnectIntegrationModalProps {
credentialId: number | null;
isOpen: boolean;
handleModelClose: () => void;
teamId?: number;
handleRemoveApp: (params: RemoveAppParams) => void;
app?: App["slug"] | null;
}
export default function DisconnectIntegrationModal({
credentialId,
app,
isOpen,
handleModelClose,
teamId,
handleRemoveApp,
}: DisconnectIntegrationModalProps) {
const { t } = useLocale();
const isPlatform = useIsPlatform();
return (
<Dialog open={isOpen} onOpenChange={handleModelClose}>
<ConfirmationDialogContent
variety="danger"
title={t("remove_app")}
confirmBtnText={t("yes_remove_app")}
onConfirm={() => {
if (isPlatform && app && credentialId) {
handleRemoveApp({ credentialId, app, teamId, callback: () => handleModelClose() });
} else if (credentialId) {
handleRemoveApp({ credentialId, teamId, callback: () => handleModelClose() });
}
}}>
<p className="mt-5">{t("are_you_sure_you_want_to_remove_this_app")}</p>
</ConfirmationDialogContent>
</Dialog>
);
}
@@ -5,10 +5,10 @@ import { useReducer } from "react";
import getAppCategoryTitle from "@calcom/app-store/_utils/getAppCategoryTitle";
import { AppList, type HandleDisconnect } from "@calcom/web/modules/apps/components/AppList";
import type { UpdateUsersDefaultConferencingAppParams } from "@calcom/web/modules/apps/components/AppSetDefaultLinkDialog";
import DisconnectIntegrationModal from "@calcom/web/modules/apps/components/DisconnectIntegrationModal";
import type { RemoveAppParams } from "@calcom/web/modules/apps/components/DisconnectIntegrationModal";
import DisconnectIntegrationModal from "@calcom/features/apps/components/DisconnectIntegrationModal";
import type { RemoveAppParams } from "@calcom/features/apps/components/DisconnectIntegrationModal";
import { SkeletonLoader } from "@calcom/web/modules/apps/components/SkeletonLoader";
import type { BulkUpdatParams } from "@calcom/web/modules/event-types/components/BulkEditDefaultForEventsModal";
import type { BulkUpdatParams } from "@calcom/features/eventtypes/components/BulkEditDefaultForEventsModal";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { AppCategories } from "@calcom/prisma/enums";
import { trpc } from "@calcom/trpc/react";
@@ -6,7 +6,7 @@ import { useRouter, useSearchParams } from "next/navigation";
import { useState } from "react";
import { AvailabilitySettings } from "@calcom/atoms/availability/AvailabilitySettings";
import type { BulkUpdatParams } from "@calcom/web/modules/event-types/components/BulkEditDefaultForEventsModal";
import type { BulkUpdatParams } from "@calcom/features/eventtypes/components/BulkEditDefaultForEventsModal";
import { withErrorFromUnknown } from "@calcom/lib/getClientErrorFromUnknown";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { HttpError } from "@calcom/lib/http-error";
@@ -7,8 +7,8 @@ import { useRouter, usePathname } from "next/navigation";
import { useCallback, useState } from "react";
import posthog from "posthog-js";
import { BulkEditDefaultForEventsModal } from "@calcom/web/modules/event-types/components/BulkEditDefaultForEventsModal";
import type { BulkUpdatParams } from "@calcom/web/modules/event-types/components/BulkEditDefaultForEventsModal";
import { BulkEditDefaultForEventsModal } from "@calcom/features/eventtypes/components/BulkEditDefaultForEventsModal";
import type { BulkUpdatParams } from "@calcom/features/eventtypes/components/BulkEditDefaultForEventsModal";
import { NewScheduleButton } from "@calcom/web/modules/schedules/components/NewScheduleButton";
import { ScheduleListItem } from "@calcom/features/schedules/components/ScheduleListItem";
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
@@ -8,7 +8,7 @@ import { nameOfDay } from "@calcom/lib/weekday";
import { BookerLayouts } from "@calcom/prisma/zod-utils";
import classNames from "@calcom/ui/classNames";
import { TimeFormatToggle } from "./TimeFormatToggle";
import { TimeFormatToggle } from "@calcom/features/bookings/components/TimeFormatToggle";
type AvailableTimesHeaderProps = {
date: Dayjs;
@@ -45,12 +45,12 @@ import { DatePicker } from "./DatePicker";
import { DryRunMessage } from "./DryRunMessage";
import { EventMeta } from "./EventMeta";
import { HavingTroubleFindingTime } from "./HavingTroubleFindingTime";
import { Header } from "./Header";
import { Header } from "@calcom/features/bookings/components/Header";
import { InstantBooking } from "./InstantBooking";
import { LargeCalendar } from "./LargeCalendar";
import { OverlayCalendar } from "./OverlayCalendar/OverlayCalendar";
import { RedirectToInstantMeetingModal } from "./RedirectToInstantMeetingModal";
import { BookerSection } from "./Section";
import { BookerSection } from "@calcom/features/bookings/components/Section";
import { SlotSelectionModalHeader } from "./SlotSelectionModalHeader";
import { NotFound } from "./Unavailable";
import { VerifyCodeDialog } from "./VerifyCodeDialog";
@@ -1,253 +0,0 @@
import { useCallback, useMemo } from "react";
import { shallow } from "zustand/shallow";
import { useIsPlatform } from "@calcom/atoms/hooks/useIsPlatform";
import dayjs from "@calcom/dayjs";
import { useIsEmbed } from "@calcom/embed-core/embed-iframe";
import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";
import { useInitializeWeekStart } from "@calcom/web/modules/bookings/hooks/useInitializeWeekStart";
import { WEBAPP_URL } from "@calcom/lib/constants";
import { formatDateTime } from "@calcom/lib/dateTimeFormatter";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { BookerLayouts } from "@calcom/prisma/zod-utils";
import { Button } from "@calcom/ui/components/button";
import { ButtonGroup } from "@calcom/ui/components/buttonGroup";
import { ToggleGroup } from "@calcom/ui/components/form";
import { Icon } from "@calcom/ui/components/icon";
import { Tooltip } from "@calcom/ui/components/tooltip";
import { TimeFormatToggle } from "@calcom/web/modules/bookings/components/TimeFormatToggle";
import type { BookerLayout } from "@calcom/features/bookings/Booker/types";
export function Header({
extraDays,
isMobile,
enabledLayouts,
nextSlots,
eventSlug,
isMyLink,
renderOverlay,
isCalendarView,
}: {
extraDays: number;
isMobile: boolean;
enabledLayouts: BookerLayouts[];
nextSlots: number;
eventSlug: string;
isMyLink: boolean;
renderOverlay?: () => JSX.Element | null;
isCalendarView?: boolean;
}) {
const { t, i18n } = useLocale();
const isEmbed = useIsEmbed();
const isPlatform = useIsPlatform();
const [layout, setLayout] = useBookerStoreContext((state) => [state.layout, state.setLayout], shallow);
const selectedDateString = useBookerStoreContext((state) => state.selectedDate);
const setSelectedDate = useBookerStoreContext((state) => state.setSelectedDate);
const addToSelectedDate = useBookerStoreContext((state) => state.addToSelectedDate);
const isMonthView = isCalendarView !== undefined ? !isCalendarView : layout === BookerLayouts.MONTH_VIEW;
const today = dayjs();
const selectedDate = selectedDateString ? dayjs(selectedDateString) : today;
const selectedDateMin3DaysDifference = useMemo(() => {
const diff = today.diff(selectedDate, "days");
return diff > 3 || diff < -3;
}, [today, selectedDate]);
useInitializeWeekStart(isPlatform, isCalendarView ?? false);
const onLayoutToggle = useCallback(
(newLayout: string) => {
if (layout === newLayout || !newLayout) return;
setLayout(newLayout as BookerLayout);
},
[setLayout, layout]
);
if (isMobile || !enabledLayouts) return null;
// In month view we only show the layout toggle.
if (isMonthView) {
return (
<div className="flex gap-2">
{isMyLink && !isEmbed ? (
<Tooltip content={t("troubleshooter_tooltip")} side="bottom">
<Button
color="primary"
target="_blank"
href={`${WEBAPP_URL}/availability/troubleshoot?eventType=${eventSlug}`}>
{t("need_help")}
</Button>
</Tooltip>
) : (
renderOverlay?.()
)}
<LayoutToggleWithData
layout={layout}
enabledLayouts={enabledLayouts}
onLayoutToggle={onLayoutToggle}
/>
</div>
);
}
const endDate = selectedDate.add(layout === BookerLayouts.COLUMN_VIEW ? extraDays : extraDays - 1, "days");
const isSameMonth = () => {
return selectedDate.format("MMM") === endDate.format("MMM");
};
const isSameYear = () => {
return selectedDate.format("YYYY") === endDate.format("YYYY");
};
const formatMonthLabel = (date: Date) =>
formatDateTime(date, { locale: i18n.language ?? "en", month: "short" });
const FormattedSelectedDateRange = () => {
return (
<h3 className="min-w-[150px] text-base font-semibold leading-4">
{formatMonthLabel(selectedDate.toDate())} {selectedDate.format("D")}
{!isSameYear() && <span className="text-subtle">, {selectedDate.format("YYYY")} </span>}-{" "}
{!isSameMonth() && formatMonthLabel(endDate.toDate())} {endDate.format("D")},{" "}
<span className="text-subtle">
{isSameYear() ? selectedDate.format("YYYY") : endDate.format("YYYY")}
</span>
</h3>
);
};
return (
<div className="border-default relative z-10 flex border-b px-5 py-4 ltr:border-l rtl:border-r">
<div className="flex items-center gap-5 rtl:grow">
<FormattedSelectedDateRange />
<ButtonGroup>
<Button
className="group rtl:ml-1 rtl:rotate-180"
variant="icon"
color="minimal"
StartIcon="chevron-left"
aria-label="Previous Day"
onClick={() => addToSelectedDate(layout === BookerLayouts.COLUMN_VIEW ? -nextSlots : -extraDays)}
/>
<Button
className="group rtl:mr-1 rtl:rotate-180"
variant="icon"
color="minimal"
StartIcon="chevron-right"
aria-label="Next Day"
onClick={() => addToSelectedDate(layout === BookerLayouts.COLUMN_VIEW ? nextSlots : extraDays)}
/>
{selectedDateMin3DaysDifference && (
<Button
className="capitalize ltr:ml-2 rtl:mr-2"
color="secondary"
onClick={() => {
const selectedDate = (isCalendarView ? today.startOf("week") : today).format("YYYY-MM-DD");
setSelectedDate({ date: selectedDate });
}}>
{t("today")}
</Button>
)}
</ButtonGroup>
</div>
<div className="ml-auto flex gap-2">
{renderOverlay?.()}
<TimeFormatToggle />
<div className="fixed top-4 ltr:right-4 rtl:left-4">
<LayoutToggleWithData
layout={layout}
enabledLayouts={enabledLayouts}
onLayoutToggle={onLayoutToggle}
/>
</div>
{/*
This second layout toggle is hidden, but needed to reserve the correct spot in the DIV
for the fixed toggle above to fit into. If we wouldn't make it fixed in this view, the transition
would be really weird, because the element is positioned fixed in the month view, and then
when switching layouts wouldn't anymore, causing it to animate from the center to the top right,
while it actually already was on place. That's why we have this element twice.
*/}
<div className="pointer-events-none opacity-0" aria-hidden>
<LayoutToggleWithData
layout={layout}
enabledLayouts={enabledLayouts}
onLayoutToggle={onLayoutToggle}
/>
</div>
</div>
</div>
);
}
const LayoutToggle = ({
onLayoutToggle,
layout,
enabledLayouts,
}: {
onLayoutToggle: (layout: string) => void;
layout: string;
enabledLayouts?: BookerLayouts[];
}) => {
const isEmbed = useIsEmbed();
const isPlatform = useIsPlatform();
const { t } = useLocale();
const layoutOptions = useMemo(() => {
return [
{
value: BookerLayouts.MONTH_VIEW,
label: (
<>
<Icon name="calendar" width="16" height="16" />
<span className="sr-only">${t("switch_monthly")}</span>
</>
),
tooltip: t("switch_monthly"),
},
{
value: BookerLayouts.WEEK_VIEW,
label: (
<>
<Icon name="grid-3x3" width="16" height="16" />
<span className="sr-only">${t("switch_weekly")}</span>
</>
),
tooltip: t("switch_weekly"),
},
{
value: BookerLayouts.COLUMN_VIEW,
label: (
<>
<Icon name="columns-3" width="16" height="16" />
<span className="sr-only">${t("switch_columnview")}</span>
</>
),
tooltip: t("switch_columnview"),
},
].filter((layout) => enabledLayouts?.includes(layout.value as BookerLayouts));
}, [t, enabledLayouts]);
// We don't want to show the layout toggle in embed mode as of now as it doesn't look rightly placed when embedded.
// There is a Embed API to control the layout toggle from outside of the iframe.
if (isEmbed) {
return null;
}
// just like embed the layout toggle doesn't look rightly placed in platform
// the layout can be toggled via props in the booker atom
if (isPlatform) return null;
return <ToggleGroup onValueChange={onLayoutToggle} defaultValue={layout} options={layoutOptions} />;
};
const LayoutToggleWithData = ({
enabledLayouts,
onLayoutToggle,
layout,
}: {
enabledLayouts: BookerLayouts[];
onLayoutToggle: (layout: string) => void;
layout: string;
}) => {
return enabledLayouts.length <= 1 ? null : (
<LayoutToggle onLayoutToggle={onLayoutToggle} layout={layout} enabledLayouts={enabledLayouts} />
);
};
@@ -1,63 +0,0 @@
import type { MotionProps } from "framer-motion";
import { m } from "framer-motion";
import { forwardRef } from "react";
import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";
import classNames from "@calcom/ui/classNames";
import type { BookerAreas, BookerLayout } from "@calcom/features/bookings/Booker/types";
/**
* Define what grid area a section should be in.
* Value is either a string (in case it's always the same area), or an object
* looking like:
* {
* // Where default is the required default area.
* default: "calendar",
* // Any optional overrides for different layouts by their layout name.
* week_view: "main",
* }
*/
type GridArea = BookerAreas | ({ [key in BookerLayout]?: BookerAreas } & { default: BookerAreas });
type BookerSectionProps = {
children: React.ReactNode;
area: GridArea;
visible?: boolean;
className?: string;
} & MotionProps;
// This map with strings is needed so Tailwind generates all classnames,
// If we would concatenate them with JS, Tailwind would not generate them.
const gridAreaClassNameMap: { [key in BookerAreas]: string } = {
calendar: "[grid-area:calendar]",
main: "[grid-area:main]",
meta: "[grid-area:meta]",
timeslots: "[grid-area:timeslots]",
header: "[grid-area:header]",
};
/**
* Small helper component that renders a booker section in a specific grid area.
*/
export const BookerSection = forwardRef<HTMLDivElement, BookerSectionProps>(function BookerSection(
{ children, area, visible, className, ...props },
ref
) {
const layout = useBookerStoreContext((state) => state.layout);
let gridClassName: string;
if (typeof area === "string") {
gridClassName = gridAreaClassNameMap[area];
} else {
gridClassName = gridAreaClassNameMap[area[layout] || area.default];
}
if (!visible && typeof visible !== "undefined") return null;
return (
<m.div ref={ref} className={classNames(gridClassName, className)} layout {...props}>
{children}
</m.div>
);
});
@@ -1,26 +0,0 @@
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { TimeFormat } from "@calcom/lib/timeFormat";
import { ToggleGroup } from "@calcom/ui/components/form";
import { useTimePreferences } from "@calcom/features/bookings/lib";
export const TimeFormatToggle = ({ customClassName }: { customClassName?: string }) => {
const timeFormat = useTimePreferences((state) => state.timeFormat);
const setTimeFormat = useTimePreferences((state) => state.setTimeFormat);
const { t } = useLocale();
return (
<ToggleGroup
customClassNames={customClassName}
onValueChange={(newFormat) => {
if (newFormat && newFormat !== timeFormat) setTimeFormat(newFormat as TimeFormat);
}}
defaultValue={timeFormat}
value={timeFormat}
options={[
{ value: TimeFormat.TWELVE_HOUR, label: t("12_hour_short") },
{ value: TimeFormat.TWENTY_FOUR_HOUR, label: t("24_hour_short") },
]}
/>
);
};
@@ -1,5 +1,5 @@
import { vi } from "vitest";
// Mock layout components
vi.mock("../Header", () => ({
vi.mock("@calcom/features/bookings/components/Header", () => ({
Header: ({ children }: { children: React.ReactNode }) => <div data-testid="header">{children}</div>,
}));
@@ -1,7 +1,7 @@
import type React from "react";
import { vi } from "vitest";
vi.mock("../Section", () => {
vi.mock("@calcom/features/bookings/components/Section", () => {
const BookerSection = ({
children,
className = "",
@@ -13,7 +13,7 @@ import { EventDetailBlocks } from "@calcom/features/bookings/types";
import { AvailableEventLocations } from "./AvailableEventLocations";
import { EventDuration } from "./Duration";
import { EventOccurences } from "./Occurences";
import { Price } from "./Price";
import { Price } from "@calcom/features/bookings/components/event-meta/Price";
type EventDetailsPropsBase = {
event: Pick<
@@ -1,6 +0,0 @@
import { Icon } from "@calcom/ui/components/icon";
export function PayIcon(props: { currency: string; className?: string }) {
const { className, currency } = props;
return <Icon name={currency !== "BTC" ? "credit-card" : "zap"} className={className} />;
}
@@ -1,28 +0,0 @@
import dynamic from "next/dynamic";
import { formatPrice } from "@calcom/lib/currencyConversions";
import type { EventPrice } from "@calcom/features/bookings/types";
const AlbyPriceComponent = dynamic(
() => import("@calcom/app-store/alby/components/AlbyPriceComponent").then((m) => m.AlbyPriceComponent),
{
ssr: false,
}
);
export const Price = ({ price, currency, displayAlternateSymbol = true }: EventPrice) => {
if (price === 0) return null;
const formattedPrice = formatPrice(price, currency);
return currency !== "BTC" ? (
<>{formattedPrice}</>
) : (
<AlbyPriceComponent
displaySymbol={displayAlternateSymbol}
price={price}
formattedPrice={formattedPrice}
/>
);
};
@@ -3,4 +3,4 @@ export { EventTitle } from "./Title";
export { EventMetaSkeleton } from "./Skeleton";
export { EventMembers } from "./Members";
export { PriceIcon } from "./PriceIcon";
export { PayIcon } from "./PayIcon";
export { PayIcon } from "@calcom/features/bookings/components/event-meta/PayIcon";
@@ -1,23 +0,0 @@
import { useEffect } from "react";
import dayjs from "@calcom/dayjs";
import { useSlotsViewOnSmallScreen } from "@calcom/embed-core/embed-iframe";
import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";
export const useInitializeWeekStart = (isPlatform: boolean, isCalendarView: boolean) => {
const slotsViewOnSmallScreen = useSlotsViewOnSmallScreen();
const today = dayjs();
const weekStart = today.startOf("week").format("YYYY-MM-DD");
const setSelectedDate = useBookerStoreContext((state) => state.setSelectedDate);
useEffect(() => {
// don't auto-select date if slots view on small screen is enabled
// auto-selecting would open the slots modal in that case which the user would most probably have to close
if (slotsViewOnSmallScreen) return;
if (isPlatform && isCalendarView) {
setSelectedDate({ date: weekStart, omitUpdatingParams: true });
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
};
@@ -21,7 +21,7 @@ import {
useIsBackgroundTransparent,
useIsEmbed,
} from "@calcom/embed-core/embed-iframe";
import { Price } from "@calcom/web/modules/bookings/components/event-meta/Price";
import { Price } from "@calcom/features/bookings/components/event-meta/Price";
import { getCalendarLinks, CalendarLinkType } from "@calcom/features/bookings/lib/getCalendarLinks";
import { RATING_OPTIONS, validateRating } from "@calcom/features/bookings/lib/rating";
import { isWithinMinimumRescheduleNotice as isWithinMinimumRescheduleNoticeUtil } from "@calcom/features/bookings/lib/reschedule/isWithinMinimumRescheduleNotice";
@@ -1,164 +0,0 @@
import type { ReactNode } 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 { useLocale } from "@calcom/lib/hooks/useLocale";
import slugify from "@calcom/lib/slugify";
import { SchedulingType } from "@calcom/prisma/enums";
import classNames from "@calcom/ui/classNames";
import { Alert } from "@calcom/ui/components/alert";
import { Form } from "@calcom/ui/components/form";
import { TextField } from "@calcom/ui/components/form";
import { RadioAreaGroup as RadioArea } from "@calcom/ui/components/radio";
import { Tooltip } from "@calcom/ui/components/tooltip";
type props = {
permissions: {
canCreateEventType: boolean;
};
teamSlug?: string | null;
teamId: number;
isPending: boolean;
urlPrefix?: string;
form: UseFormReturn<CreateEventTypeFormValues>;
handleSubmit: (values: CreateEventTypeFormValues) => void;
isManagedEventType: boolean;
SubmitButton: (isPending: boolean) => ReactNode;
};
export const TeamEventTypeForm = ({
permissions,
teamSlug,
teamId,
form,
urlPrefix,
isPending,
handleSubmit,
isManagedEventType,
SubmitButton,
}: props) => {
const isPlatform = useIsPlatform();
const { t } = useLocale();
const { register, setValue, formState } = form;
const { canCreateEventType } = permissions;
return (
<Form form={form} handleSubmit={handleSubmit}>
<div className="mb-6 mt-1 stack-y-6">
<TextField
type="hidden"
labelProps={{ style: { display: "none" } }}
{...register("teamId", { valueAsNumber: true })}
value={teamId}
/>
<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 (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 ? (
<Tooltip content={!isManagedEventType ? `team/${teamSlug}` : t("username_placeholder")}>
<span className="max-w-24 md:max-w-56">
/{!isManagedEventType ? `team/${teamSlug}` : t("username_placeholder")}/
</span>
</Tooltip>
) : undefined
}
{...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 ? `team/${teamSlug}` : t("username_placeholder")
}/`}>
<span className="max-w-24 md:max-w-56">
{urlPrefix}/{!isManagedEventType ? `team/${teamSlug}` : t("username_placeholder")}/
</span>
</Tooltip>
) : undefined
}
{...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 className="mb-4">
<label htmlFor="schedulingType" className="text-default block text-sm font-bold">
{t("assignment")}
</label>
{formState.errors.schedulingType && (
<Alert className="mt-1" severity="error" message={formState.errors.schedulingType.message} />
)}
<RadioArea.Group
onValueChange={(val: SchedulingType) => {
setValue("schedulingType", val);
}}
className={classNames("mt-1 flex gap-4", canCreateEventType && "flex-col")}>
<RadioArea.Item
{...register("schedulingType")}
value={SchedulingType.COLLECTIVE}
className={classNames("w-full text-sm", !canCreateEventType && "w-1/2")}
classNames={{ container: classNames(canCreateEventType && "w-full") }}>
<strong className="mb-1 block">{t("collective")}</strong>
<p>{t("collective_description")}</p>
</RadioArea.Item>
<RadioArea.Item
{...register("schedulingType")}
value={SchedulingType.ROUND_ROBIN}
className={classNames("text-sm", !canCreateEventType && "w-1/2")}
classNames={{ container: classNames(canCreateEventType && "w-full") }}>
<strong className="mb-1 block">{t("round_robin")}</strong>
<p>{t("round_robin_description")}</p>
</RadioArea.Item>
{canCreateEventType && (
<RadioArea.Item
{...register("schedulingType")}
value={SchedulingType.MANAGED}
className={classNames("text-sm", !canCreateEventType && "w-1/2")}
classNames={{ container: classNames(canCreateEventType && "w-full") }}
data-testid="managed-event-type">
<strong className="mb-1 block">{t("managed_event")}</strong>
<p>{t("managed_event_description")}</p>
</RadioArea.Item>
)}
</RadioArea.Group>
</div>
</div>
{SubmitButton(isPending)}
</Form>
);
};
@@ -21,7 +21,7 @@ import { SettingsToggle } from "@calcom/ui/components/form";
import { CheckboxField } from "@calcom/ui/components/form";
import { showToast } from "@calcom/ui/components/toast";
import { revalidateTeamDataCache } from "@calcom/web/app/(booking-page-wrapper)/team/[slug]/[type]/actions";
import { IntervalLimitsManager } from "@calcom/web/modules/event-types/components/tabs/limits/EventLimitsTab";
import { IntervalLimitsManager } from "@calcom/features/eventtypes/components/tabs/limits/EventLimitsTab";
import DisableTeamImpersonation from "../components/DisableTeamImpersonation";
import { default as InternalNotePresetsView } from "../components/InternalNotePresetsView";
@@ -15,9 +15,9 @@ import { Controller, useFormContext } from "react-hook-form";
import type { Options } from "react-select";
import { AddMembersWithSwitchWebWrapper } from "./AddMembersWithSwitchWebWrapper";
import AssignAllTeamMembers from "./AssignAllTeamMembers";
import type { CheckedSelectOption, CheckedTeamSelectCustomClassNames } from "./CheckedTeamSelect";
import CheckedTeamSelect from "./CheckedTeamSelect";
import AssignAllTeamMembers from "@calcom/features/eventtypes/components/AssignAllTeamMembers";
import type { CheckedSelectOption, CheckedTeamSelectCustomClassNames } from "@calcom/features/eventtypes/components/CheckedTeamSelect";
import CheckedTeamSelect from "@calcom/features/eventtypes/components/CheckedTeamSelect";
interface IUserToValue {
id: number | null;
@@ -1,50 +0,0 @@
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;
@@ -1,107 +0,0 @@
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>
);
}
@@ -1,228 +0,0 @@
"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 "./HostEditDialogs";
import { PriorityDialog, WeightDialog } from "./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;
@@ -1,198 +0,0 @@
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;
@@ -4,7 +4,7 @@ import { z } from "zod";
import { Dialog } from "@calcom/features/components/controlled-dialog";
import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider";
import CreateEventTypeForm from "@calcom/web/modules/event-types/components/CreateEventTypeForm";
import CreateEventTypeForm from "@calcom/features/eventtypes/components/CreateEventTypeForm";
import { useCreateEventType } from "@calcom/features/eventtypes/hooks/useCreateEventType";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { useTypedQuery } from "@calcom/lib/hooks/useTypedQuery";
@@ -15,7 +15,7 @@ import { trpc } from "@calcom/trpc/react";
import { Button } from "@calcom/ui/components/button";
import { DialogContent, DialogFooter, DialogClose } from "@calcom/ui/components/dialog";
import { showToast } from "@calcom/ui/components/toast";
import { TeamEventTypeForm } from "@calcom/web/modules/ee/teams/components/TeamEventTypeForm";
import { TeamEventTypeForm } from "@calcom/features/ee/teams/components/TeamEventTypeForm";
// this describes the uniform data needed to create a new event type on Profile or Team
export interface EventTypeParent {
@@ -1,155 +0,0 @@
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>
);
}
@@ -5,7 +5,7 @@ import { useAutoAnimate } from "@formkit/auto-animate/react";
import type { UseFormReturn } from "react-hook-form";
import type { Workflow } from "@calcom/features/ee/workflows/lib/types";
import type { ChildrenEventType } from "@calcom/web/modules/event-types/components/ChildrenEventTypeSelect";
import type { ChildrenEventType } from "@calcom/features/eventtypes/components/ChildrenEventTypeSelect";
import type {
TabMap,
EventTypeSetupProps,
@@ -2,7 +2,7 @@ import { useMemo } from "react";
import { getPaymentAppData } from "@calcom/app-store/_utils/payments/getPaymentAppData";
import { eventTypeMetaDataSchemaWithTypedApps } from "@calcom/app-store/zod-utils";
import { Price } from "@calcom/web/modules/bookings/components/event-meta/Price";
import { Price } from "@calcom/features/bookings/components/event-meta/Price";
import { PriceIcon } from "@calcom/web/modules/bookings/components/event-meta/PriceIcon";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { parseRecurringEvent } from "@calcom/lib/isRecurringEvent";
@@ -24,7 +24,7 @@ import { TRPCClientError } from "@trpc/react-query";
import { revalidateTeamEventTypeCache } from "@calcom/web/app/(booking-page-wrapper)/team/[slug]/[type]/actions";
import { revalidateEventTypeEditPage } from "@calcom/web/app/(use-page-wrapper)/event-types/[type]/actions";
import type { ChildrenEventType } from "./ChildrenEventTypeSelect";
import type { ChildrenEventType } from "@calcom/features/eventtypes/components/ChildrenEventTypeSelect";
import { EventType as EventTypeComponent } from "./EventType";
import { useEventTypeForm } from "@calcom/atoms/event-types/hooks/useEventTypeForm";
import { useHandleRouteChange } from "@calcom/atoms/event-types/hooks/useHandleRouteChange";
@@ -45,7 +45,9 @@ type EventPermissions = {
};
};
const ManagedEventTypeDialog = dynamic(() => import("./dialogs/ManagedEventDialog"));
const ManagedEventTypeDialog = dynamic(() =>
import("@calcom/features/eventtypes/components/dialogs/ManagedEventDialog")
);
const AssignmentWarningDialog = dynamic(() => import("./dialogs/AssignmentWarningDialog"));
@@ -1,244 +0,0 @@
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 "./CheckedTeamSelect";
import WeightDescription from "./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>
);
};
@@ -1,37 +0,0 @@
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>,
]}
/>
);
};
@@ -1,22 +0,0 @@
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>,
]}
/>
);
}
@@ -1,55 +0,0 @@
import type { ChildrenEventType } from "@calcom/web/modules/event-types/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>
);
}
@@ -1,7 +1,7 @@
import dynamic from "next/dynamic";
export { default as CheckedTeamSelect } from "./CheckedTeamSelect";
export { default as CheckedTeamSelect } from "@calcom/features/eventtypes/components/CheckedTeamSelect";
export { default as EventTypeDescription } from "./EventTypeDescription";
export { LearnMoreLink } from "./LearnMoreLink";
export { LearnMoreLink } from "@calcom/features/eventtypes/components/LearnMoreLink";
export { MultiplePrivateLinksController } from "./MultiplePrivateLinksController";
export const EventTypeDescriptionLazy = dynamic(() => import("./EventTypeDescription"));
@@ -2,14 +2,14 @@ import { ErrorMessage } from "@hookform/error-message";
import { useFieldArray, useFormContext } from "react-hook-form";
import { getEventLocationType } from "@calcom/app-store/locations";
import type { LocationCustomClassNames } from "./types";
import type { LocationCustomClassNames } from "@calcom/features/eventtypes/components/locations/types";
import type { LocationFormValues, FormValues } from "@calcom/features/eventtypes/lib/types";
import CheckboxField from "@calcom/features/form/components/CheckboxField";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import classNames from "@calcom/ui/classNames";
import { TextField } from "@calcom/ui/components/form";
import LocationInput from "./LocationInput";
import LocationInput from "@calcom/features/eventtypes/components/locations/LocationInput";
import LocationOptionContainer from "./LocationSettingsContainer";
const DefaultLocationSettings = ({
@@ -1,76 +0,0 @@
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;
@@ -8,7 +8,7 @@ import type { UseFormGetValues, UseFormSetValue, Control, FormState } from "reac
import type { EventLocationType } from "@calcom/app-store/locations";
import { getEventLocationType, MeetLocationType } from "@calcom/app-store/locations";
import { useIsPlatform } from "@calcom/atoms/hooks/useIsPlatform";
import type { LocationCustomClassNames } from "./types";
import type { LocationCustomClassNames } from "@calcom/features/eventtypes/components/locations/types";
import type { LocationFormValues, EventTypeSetupProps } from "@calcom/features/eventtypes/lib/types";
import CheckboxField from "@calcom/features/form/components/CheckboxField";
import type { SingleValueLocationOption } from "@calcom/features/form/components/LocationSelect";
@@ -23,7 +23,7 @@ import { showToast } from "@calcom/ui/components/toast";
import CalVideoSettings from "./CalVideoSettings";
import DefaultLocationSettings from "./DefaultLocationSettings";
import LocationInput from "./LocationInput";
import LocationInput from "@calcom/features/eventtypes/components/locations/LocationInput";
export type TEventTypeLocation = Pick<EventTypeSetupProps["eventType"], "locations" | "calVideoSettings">;
export type TLocationOptions = Pick<EventTypeSetupProps, "locationOptions">["locationOptions"];
@@ -1,25 +0,0 @@
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;
};
@@ -3,7 +3,7 @@ import { useEffect, useRef, useState } from "react";
import { Controller, useFormContext } from "react-hook-form";
import useLockedFieldsManager from "@calcom/features/ee/managed-event-types/hooks/useLockedFieldsManager";
import { LearnMoreLink } from "@calcom/web/modules/event-types/components/LearnMoreLink";
import { LearnMoreLink } from "@calcom/features/eventtypes/components/LearnMoreLink";
import type { EventTypeSetup, SettingsToggleClassNames } from "@calcom/features/eventtypes/lib/types";
import type { FormValues } from "@calcom/features/eventtypes/lib/types";
import ServerTrans from "@calcom/lib/components/ServerTrans";
@@ -22,7 +22,7 @@ import {
} from "@calcom/features/ee/workflows/lib/allowDisablingStandardEmails";
import { MultiplePrivateLinksController } from "@calcom/web/modules/event-types/components";
import AddVerifiedEmail from "@calcom/web/modules/event-types/components/AddVerifiedEmail";
import { LearnMoreLink } from "@calcom/web/modules/event-types/components/LearnMoreLink";
import { LearnMoreLink } from "@calcom/features/eventtypes/components/LearnMoreLink";
import type { EventNameObjectType } from "@calcom/features/eventtypes/lib/eventNaming";
import { getEventName } from "@calcom/features/eventtypes/lib/eventNaming";
import type {
@@ -7,7 +7,7 @@ import { ZodError } from "zod";
import { useIsPlatform } from "@calcom/atoms/hooks/useIsPlatform";
import { Dialog } from "@calcom/features/components/controlled-dialog";
import { LearnMoreLink } from "@calcom/web/modules/event-types/components/LearnMoreLink";
import { LearnMoreLink } from "@calcom/features/eventtypes/components/LearnMoreLink";
import { getCurrencySymbol } from "@calcom/lib/currencyConversions";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { md } from "@calcom/lib/markdownIt";
@@ -6,7 +6,7 @@ import { Controller, useFormContext } from "react-hook-form";
import type z from "zod";
import useLockedFieldsManager from "@calcom/features/ee/managed-event-types/hooks/useLockedFieldsManager";
import { LearnMoreLink } from "@calcom/web/modules/event-types/components/LearnMoreLink";
import { LearnMoreLink } from "@calcom/features/eventtypes/components/LearnMoreLink";
import type { EventTypeSetup, SettingsToggleClassNames } from "@calcom/features/eventtypes/lib/types";
import type { FormValues } from "@calcom/features/eventtypes/lib/types";
import ServerTrans from "@calcom/lib/components/ServerTrans";
@@ -20,12 +20,12 @@ import type { AddMembersWithSwitchCustomClassNames } from "@calcom/web/modules/e
import AddMembersWithSwitch, {
mapUserToValue,
} from "@calcom/web/modules/event-types/components/AddMembersWithSwitch";
import AssignAllTeamMembers from "@calcom/web/modules/event-types/components/AssignAllTeamMembers";
import type { ChildrenEventTypeSelectCustomClassNames } from "@calcom/web/modules/event-types/components/ChildrenEventTypeSelect";
import ChildrenEventTypeSelect from "@calcom/web/modules/event-types/components/ChildrenEventTypeSelect";
import AssignAllTeamMembers from "@calcom/features/eventtypes/components/AssignAllTeamMembers";
import type { ChildrenEventTypeSelectCustomClassNames } from "@calcom/features/eventtypes/components/ChildrenEventTypeSelect";
import ChildrenEventTypeSelect from "@calcom/features/eventtypes/components/ChildrenEventTypeSelect";
import { EditWeightsForAllTeamMembers } from "@calcom/web/modules/event-types/components/EditWeightsForAllTeamMembers";
import { LearnMoreLink } from "@calcom/web/modules/event-types/components/LearnMoreLink";
import WeightDescription from "@calcom/web/modules/event-types/components/WeightDescription";
import { LearnMoreLink } from "@calcom/features/eventtypes/components/LearnMoreLink";
import WeightDescription from "@calcom/features/eventtypes/components/WeightDescription";
import type { TFunction } from "i18next";
import Link from "next/link";
import type { ComponentProps, Dispatch, SetStateAction } from "react";
File diff suppressed because it is too large. Load diff
@@ -1,5 +1,5 @@
import { EventLimitsTab } from "@calcom/web/modules/event-types/components/tabs/limits/EventLimitsTab";
import type { EventLimitsTabProps } from "@calcom/web/modules/event-types/components/tabs/limits/EventLimitsTab";
import { EventLimitsTab } from "@calcom/features/eventtypes/components/tabs/limits/EventLimitsTab";
import type { EventLimitsTabProps } from "@calcom/features/eventtypes/components/tabs/limits/EventLimitsTab";
const EventLimitsTabWebWrapper = (props: EventLimitsTabProps) => {
return <EventLimitsTab {...props} />;
@@ -1,100 +0,0 @@
import { useState } from "react";
import { Controller, useFormContext } from "react-hook-form";
import { LearnMoreLink } from "@calcom/web/modules/event-types/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>
);
}}
/>
);
}
@@ -1,24 +0,0 @@
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}
/>
);
};
@@ -1,5 +1,5 @@
import type { EventRecurringTabProps } from "@calcom/web/modules/event-types/components/tabs/recurring/EventRecurringTab";
import { EventRecurringTab } from "@calcom/web/modules/event-types/components/tabs/recurring/EventRecurringTab";
import type { EventRecurringTabProps } from "@calcom/features/eventtypes/components/tabs/recurring/EventRecurringTab";
import { EventRecurringTab } from "@calcom/features/eventtypes/components/tabs/recurring/EventRecurringTab";
const EventRecurringWebWrapper = (props: EventRecurringTabProps) => {
return <EventRecurringTab {...props} />;
@@ -1,220 +0,0 @@
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/web/modules/event-types/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>
);
}
@@ -26,7 +26,7 @@ import { useState } from "react";
import type { Control, FormState, UseFormGetValues, UseFormSetValue } from "react-hook-form";
import { Controller, useFormContext } from "react-hook-form";
import type { MultiValue } from "react-select";
import type { LocationCustomClassNames } from "../../locations/types";
import type { LocationCustomClassNames } from "@calcom/features/eventtypes/components/locations/types";
export type EventSetupTabCustomClassNames = {
wrapper?: string;
@@ -10,7 +10,7 @@ import { trpc } from "@calcom/trpc/react";
import { Button } from "@calcom/ui/components/button";
import { WizardLayout } from "@calcom/ui/components/layout";
import { showToast } from "@calcom/ui/components/toast";
import { TeamEventTypeForm } from "@calcom/web/modules/ee/teams/components/TeamEventTypeForm";
import { TeamEventTypeForm } from "@calcom/features/ee/teams/components/TeamEventTypeForm";
type CreateTeamEventTypeProps = {
permissions: { canCreateEventType: boolean };