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:
61 files changed
+77
-76
No files matched your search
@@ -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";
|
||||
|
||||
Reference in new issue
Block a user