Skip to content

Scheduling infrastructure for absolutely everyone.

refactor: Move integration attribute async components to /web (#27341)

Benny Joo1a31f9136b6f
diff --git a/apps/web/app/(use-page-wrapper)/settings/(settings-layout)/organizations/(org-admin-only)/attributes/sync/page.tsx b/apps/web/app/(use-page-wrapper)/settings/(settings-layout)/organizations/(org-admin-only)/attributes/sync/page.tsx
index a43c7512a8f..044dffc9396 100644
--- a/apps/web/app/(use-page-wrapper)/settings/(settings-layout)/organizations/(org-admin-only)/attributes/sync/page.tsx
+++ b/apps/web/app/(use-page-wrapper)/settings/(settings-layout)/organizations/(org-admin-only)/attributes/sync/page.tsx
@@ -1,11 +1,11 @@
import { _generateMetadata, getTranslate } from "app/_utils";
-import IntegrationAttributeSyncView from "@calcom/features/ee/integration-attribute-sync/IntegrationAttributeSyncView";
import { getIntegrationAttributeSyncService } from "@calcom/features/ee/integration-attribute-sync/di/IntegrationAttributeSyncService.container";
import { TeamRepository } from "@calcom/features/ee/teams/repositories/TeamRepository";
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
import { PrismaAttributeRepository } from "@calcom/features/attributes/repositories/PrismaAttributeRepository";
import { prisma } from "@calcom/prisma";
+import IntegrationAttributeSyncView from "@calcom/web/modules/integration-attribute-sync/components/IntegrationAttributeSyncView";
import { validateUserHasOrgPerms } from "../../../actions/validateUserHasOrgPerms";
diff --git a/apps/web/components/getting-started/components/ConnectedCalendarItem.tsx b/apps/web/components/getting-started/components/ConnectedCalendarItem.tsx
index e41883bdcdc..01b6628c04f 100644
--- a/apps/web/components/getting-started/components/ConnectedCalendarItem.tsx
+++ b/apps/web/components/getting-started/components/ConnectedCalendarItem.tsx
@@ -1,4 +1,4 @@
-import { UserCalendarSwitch } from "@calcom/features/calendars/CalendarSwitch";
+import { UserCalendarSwitch } from "@calcom/web/modules/calendars/components/CalendarSwitch";
interface IConnectedCalendarItem {
name: string;
diff --git a/packages/features/calendars/AdditionalCalendarSelector.tsx b/apps/web/modules/calendars/components/AdditionalCalendarSelector.tsx
similarity index 100%
rename from packages/features/calendars/AdditionalCalendarSelector.tsx
rename to apps/web/modules/calendars/components/AdditionalCalendarSelector.tsx
diff --git a/packages/features/calendars/CalendarSwitch.tsx b/apps/web/modules/calendars/components/CalendarSwitch.tsx
similarity index 92%
rename from packages/features/calendars/CalendarSwitch.tsx
rename to apps/web/modules/calendars/components/CalendarSwitch.tsx
index 462feda8cc5..f545d127d37 100644
--- a/packages/features/calendars/CalendarSwitch.tsx
+++ b/apps/web/modules/calendars/components/CalendarSwitch.tsx
@@ -9,20 +9,7 @@ import classNames from "@calcom/ui/classNames";
import { Switch } from "@calcom/ui/components/form";
import { Icon } from "@calcom/ui/components/icon";
import { showToast } from "@calcom/ui/components/toast";
-
-export type ICalendarSwitchProps = {
- title: string;
- externalId: string;
- type: string;
- isChecked: boolean;
- name: string;
- isLastItemInList?: boolean;
- destination?: boolean;
- credentialId: number;
- delegationCredentialId: string | null;
- eventTypeId: number | null;
- disabled?: boolean;
-};
+import type { ICalendarSwitchProps } from "@calcom/ui/components/calendar-switch";
type UserCalendarSwitchProps = Omit<ICalendarSwitchProps, "eventTypeId">;
diff --git a/apps/web/modules/calendars/components/SelectedCalendarsSettingsWebWrapper.tsx b/apps/web/modules/calendars/components/SelectedCalendarsSettingsWebWrapper.tsx
index 678e5603ce8..86a9eb2765b 100644
--- a/apps/web/modules/calendars/components/SelectedCalendarsSettingsWebWrapper.tsx
+++ b/apps/web/modules/calendars/components/SelectedCalendarsSettingsWebWrapper.tsx
@@ -1,6 +1,4 @@
import { SelectedCalendarsSettings } from "@calcom/atoms/selected-calendars/SelectedCalendarsSettings";
-import AdditionalCalendarSelector from "@calcom/features/calendars/AdditionalCalendarSelector";
-import { CalendarSwitch } from "@calcom/features/calendars/CalendarSwitch";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import type { RouterOutputs } from "@calcom/trpc/react";
import { trpc } from "@calcom/trpc/react";
@@ -9,6 +7,8 @@ import { Select } from "@calcom/ui/components/form";
import { List } from "@calcom/ui/components/list";
import AppListCard from "@calcom/web/modules/apps/components/AppListCard";
import CredentialActionsDropdown from "@calcom/web/modules/apps/components/CredentialActionsDropdown";
+import { CalendarSwitch } from "@calcom/web/modules/calendars/components/CalendarSwitch";
+import AdditionalCalendarSelector from "@calcom/web/modules/calendars/components/AdditionalCalendarSelector";
import Link from "next/link";
import React from "react";
diff --git a/packages/features/ee/integration-attribute-sync/components/EditIntegrationAttributeSyncCard.tsx b/apps/web/modules/integration-attribute-sync/components/EditIntegrationAttributeSyncCard.tsx
similarity index 91%
rename from packages/features/ee/integration-attribute-sync/components/EditIntegrationAttributeSyncCard.tsx
rename to apps/web/modules/integration-attribute-sync/components/EditIntegrationAttributeSyncCard.tsx
index 0a5f2b90fc9..e25361a7d8d 100644
--- a/packages/features/ee/integration-attribute-sync/components/EditIntegrationAttributeSyncCard.tsx
+++ b/apps/web/modules/integration-attribute-sync/components/EditIntegrationAttributeSyncCard.tsx
@@ -2,7 +2,7 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import { showToast } from "@calcom/ui/components/toast";
-import type { IntegrationAttributeSync, ISyncFormData } from "../repositories/IIntegrationAttributeSyncRepository";
+import type { IntegrationAttributeSync, ISyncFormData } from "@calcom/features/ee/integration-attribute-sync/repositories/IIntegrationAttributeSyncRepository";
import IntegrationAttributeSyncCard from "./IntegrationAttributeSyncCard";
import type { IIntegrationAttributeSyncCardProps } from "./IntegrationAttributeSyncCard";
diff --git a/packages/features/ee/integration-attribute-sync/components/FieldMappingBuilder.tsx b/apps/web/modules/integration-attribute-sync/components/FieldMappingBuilder.tsx
similarity index 92%
rename from packages/features/ee/integration-attribute-sync/components/FieldMappingBuilder.tsx
rename to apps/web/modules/integration-attribute-sync/components/FieldMappingBuilder.tsx
index 22e8a2db272..e5b2dca7de9 100644
--- a/packages/features/ee/integration-attribute-sync/components/FieldMappingBuilder.tsx
+++ b/apps/web/modules/integration-attribute-sync/components/FieldMappingBuilder.tsx
@@ -3,11 +3,11 @@ import { Button } from "@calcom/ui/components/button";
import { Input, Select, Switch } from "@calcom/ui/components/form";
import { Icon } from "@calcom/ui/components/icon";
-import { getDefaultFieldMapping } from "../lib/fieldMappingHelpers";
+import { getDefaultFieldMapping } from "@calcom/features/ee/integration-attribute-sync/lib/fieldMappingHelpers";
import type {
IFieldMappingFormState,
IFieldMappingWithOptionalId,
-} from "../repositories/IIntegrationAttributeSyncRepository";
+} from "@calcom/features/ee/integration-attribute-sync/repositories/IIntegrationAttributeSyncRepository";
type AttributeOptions = {
label: string;
@@ -115,7 +115,7 @@ export const FieldMappingBuilder = ({
// Find indices of rows with duplicate attribute mappings
const duplicateIndices = new Set<number>();
const seenAttributes = new Map<string, number>(); // attributeId -> first index
- value.mappings.forEach((mapping, index) => {
+ value.mappings.forEach((mapping: IFieldMappingWithOptionalId, index: number) => {
if (mapping.attributeId) {
const firstIndex = seenAttributes.get(mapping.attributeId);
if (firstIndex !== undefined) {
@@ -147,7 +147,7 @@ export const FieldMappingBuilder = ({
const handleRemoveMapping = (index: number) => {
onChange({
...value,
- mappings: value.mappings.filter((_, i) => i !== index),
+ mappings: value.mappings.filter((_: IFieldMappingWithOptionalId, i: number) => i !== index),
});
};
@@ -164,7 +164,7 @@ export const FieldMappingBuilder = ({
{value.mappings.length === 0 ? (
<div className="text-subtle py-6 text-center text-sm">{t("attribute_sync_no_mappings")}</div>
) : (
- value.mappings.map((mapping, index) => (
+ value.mappings.map((mapping: IFieldMappingWithOptionalId, index: number) => (
<MappingRow
key={mapping.id || `new-${index}`}
mapping={mapping}
diff --git a/packages/features/ee/integration-attribute-sync/components/IntegrationAttributeSyncCard.tsx b/apps/web/modules/integration-attribute-sync/components/IntegrationAttributeSyncCard.tsx
similarity index 98%
rename from packages/features/ee/integration-attribute-sync/components/IntegrationAttributeSyncCard.tsx
rename to apps/web/modules/integration-attribute-sync/components/IntegrationAttributeSyncCard.tsx
index 215e144ed80..7420c70f97f 100644
--- a/packages/features/ee/integration-attribute-sync/components/IntegrationAttributeSyncCard.tsx
+++ b/apps/web/modules/integration-attribute-sync/components/IntegrationAttributeSyncCard.tsx
@@ -14,7 +14,7 @@ import {
type IntegrationAttributeSync,
type ISyncFormData,
RuleOperatorEnum,
-} from "../repositories/IIntegrationAttributeSyncRepository";
+} from "@calcom/features/ee/integration-attribute-sync/repositories/IIntegrationAttributeSyncRepository";
import { FieldMappingBuilder } from "./FieldMappingBuilder";
import { RuleBuilder } from "./RuleBuilder";
diff --git a/packages/features/ee/integration-attribute-sync/IntegrationAttributeSyncView.tsx b/apps/web/modules/integration-attribute-sync/components/IntegrationAttributeSyncView.tsx
similarity index 89%
rename from packages/features/ee/integration-attribute-sync/IntegrationAttributeSyncView.tsx
rename to apps/web/modules/integration-attribute-sync/components/IntegrationAttributeSyncView.tsx
index 89afb4982bb..4619716810a 100644
--- a/packages/features/ee/integration-attribute-sync/IntegrationAttributeSyncView.tsx
+++ b/apps/web/modules/integration-attribute-sync/components/IntegrationAttributeSyncView.tsx
@@ -7,9 +7,9 @@ import type { Attribute } from "@calcom/app-store/routing-forms/types/types";
import { trpc } from "@calcom/trpc/react";
import { Button } from "@calcom/ui/components/button";
-import EditIntegrationAttributeSyncCard from "./components/EditIntegrationAttributeSyncCard";
-import NewIntegrationAttributeSyncCard from "./components/NewIntegrationAttributeSyncCard";
-import type { IntegrationAttributeSync } from "./repositories/IIntegrationAttributeSyncRepository";
+import EditIntegrationAttributeSyncCard from "./EditIntegrationAttributeSyncCard";
+import NewIntegrationAttributeSyncCard from "./NewIntegrationAttributeSyncCard";
+import type { IntegrationAttributeSync } from "@calcom/features/ee/integration-attribute-sync/repositories/IIntegrationAttributeSyncRepository";
interface IIntegrationAttributeSyncViewProps {
credentialsData: {
diff --git a/packages/features/ee/integration-attribute-sync/components/NewIntegrationAttributeSyncCard.tsx b/apps/web/modules/integration-attribute-sync/components/NewIntegrationAttributeSyncCard.tsx
similarity index 92%
rename from packages/features/ee/integration-attribute-sync/components/NewIntegrationAttributeSyncCard.tsx
rename to apps/web/modules/integration-attribute-sync/components/NewIntegrationAttributeSyncCard.tsx
index e2c4e0c516c..7deb9dd27d3 100644
--- a/packages/features/ee/integration-attribute-sync/components/NewIntegrationAttributeSyncCard.tsx
+++ b/apps/web/modules/integration-attribute-sync/components/NewIntegrationAttributeSyncCard.tsx
@@ -2,7 +2,7 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import { showToast } from "@calcom/ui/components/toast";
-import type { ISyncFormData } from "../repositories/IIntegrationAttributeSyncRepository";
+import type { ISyncFormData } from "@calcom/features/ee/integration-attribute-sync/repositories/IIntegrationAttributeSyncRepository";
import IntegrationAttributeSyncCard from "./IntegrationAttributeSyncCard";
import type { IIntegrationAttributeSyncCardProps } from "./IntegrationAttributeSyncCard";
diff --git a/packages/features/ee/integration-attribute-sync/components/RuleBuilder.tsx b/apps/web/modules/integration-attribute-sync/components/RuleBuilder.tsx
similarity index 93%
rename from packages/features/ee/integration-attribute-sync/components/RuleBuilder.tsx
rename to apps/web/modules/integration-attribute-sync/components/RuleBuilder.tsx
index 9aec9ac07c2..d68733a57f5 100644
--- a/packages/features/ee/integration-attribute-sync/components/RuleBuilder.tsx
+++ b/apps/web/modules/integration-attribute-sync/components/RuleBuilder.tsx
@@ -18,7 +18,7 @@ import {
isArrayOperator,
isTeamCondition,
type TAttributeSyncRuleConditionWithId,
-} from "../lib/ruleHelpers";
+} from "@calcom/features/ee/integration-attribute-sync/lib/ruleHelpers";
import {
ConditionIdentifierEnum,
type ConditionOperatorEnum,
@@ -27,7 +27,7 @@ import {
type ITeamCondition,
type RuleOperatorEnum,
type TAttributeSyncRuleCondition,
-} from "../repositories/IIntegrationAttributeSyncRepository";
+} from "@calcom/features/ee/integration-attribute-sync/repositories/IIntegrationAttributeSyncRepository";
const ensureConditionHasId = (condition: TAttributeSyncRuleCondition): TAttributeSyncRuleConditionWithId => {
if ("_id" in condition && condition._id) {
@@ -64,7 +64,7 @@ const ConditionComponent = ({
}: ConditionComponentProps) => {
const { t } = useLocale();
const conditionTypeOptions = getConditionTypeOptions(t);
- const conditionTypeOption = conditionTypeOptions.find((opt) => opt.value === condition.identifier);
+ const conditionTypeOption = conditionTypeOptions.find((opt: { value: ConditionIdentifierEnum; label: string }) => opt.value === condition.identifier);
const handleTypeChange = (newType: { value: ConditionIdentifierEnum; label: string } | null) => {
if (!newType) return;
@@ -127,7 +127,7 @@ interface TeamConditionFieldsProps {
const TeamConditionFields = ({ condition, onChange, teamOptions, isLoading }: TeamConditionFieldsProps) => {
const { t } = useLocale();
const teamOperatorOptions = getTeamOperatorOptions(t);
- const operatorOption = teamOperatorOptions.find((opt) => opt.value === condition.operator);
+ const operatorOption = teamOperatorOptions.find((opt: { value: ConditionOperatorEnum; label: string }) => opt.value === condition.operator);
const isMulti = isArrayOperator(condition.operator);
const selectedTeams = isMulti
@@ -222,7 +222,7 @@ const AttributeConditionFields = ({
? getOperatorOptionsForAttributeType(selectedAttribute.type, t)
: [];
- const operatorOption = operatorOptions.find((opt) => opt.value === condition.operator);
+ const operatorOption = operatorOptions.find((opt: { value: ConditionOperatorEnum; label: string }) => opt.value === condition.operator);
const handleAttributeChange = (selected: { value: string; label: string } | null) => {
if (!selected) return;
@@ -402,7 +402,7 @@ export const RuleBuilder = ({
}: RuleBuilderProps) => {
const { t } = useLocale();
const parentOperatorOptions = getParentOperatorOptions(t);
- const parentOperatorOption = parentOperatorOptions.find((opt) => opt.value === value.operator);
+ const parentOperatorOption = parentOperatorOptions.find((opt: { value: RuleOperatorEnum; label: string }) => opt.value === value.operator);
const isLoading = isLoadingTeams || isLoadingAttributes;
const handleOperatorChange = (newOperator: { value: RuleOperatorEnum; label: string } | null) => {
@@ -432,7 +432,7 @@ export const RuleBuilder = ({
const handleRemoveCondition = (index: number) => {
onChange({
...value,
- conditions: value.conditions.filter((_, i) => i !== index),
+ conditions: value.conditions.filter((_: TAttributeSyncRuleCondition, i: number) => i !== index),
});
};
@@ -464,7 +464,7 @@ export const RuleBuilder = ({
{t("attribute_sync_no_conditions")}
</div>
) : (
- value.conditions.map((condition, index) => {
+ value.conditions.map((condition: TAttributeSyncRuleCondition, index: number) => {
const conditionWithId = ensureConditionHasId(condition);
return (
<ConditionComponent
diff --git a/packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsPlatformWrapper.tsx b/packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsPlatformWrapper.tsx
index ee9f8ab6c12..7b3c50f0672 100644
--- a/packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsPlatformWrapper.tsx
+++ b/packages/platform/atoms/selected-calendars/wrappers/SelectedCalendarsSettingsPlatformWrapper.tsx
@@ -1,6 +1,5 @@
import { useState } from "react";
-import type { ICalendarSwitchProps } from "@calcom/features/calendars/CalendarSwitch";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import type { CALENDARS } from "@calcom/platform-constants";
import { QueryCell } from "@calcom/trpc/components/QueryCell";
@@ -9,7 +8,7 @@ import { Alert } from "@calcom/ui/components/alert";
import { AppListCard } from "@calcom/ui/components/app-list-card";
import type { ButtonProps } from "@calcom/ui/components/button";
import { Button } from "@calcom/ui/components/button";
-import { CalendarSwitchComponent } from "@calcom/ui/components/calendar-switch";
+import { CalendarSwitchComponent, type ICalendarSwitchProps } from "@calcom/ui/components/calendar-switch";
import { DisconnectIntegrationComponent } from "@calcom/ui/components/disconnect-calendar-integration";
import { Dropdown, DropdownMenuContent, DropdownMenuTrigger } from "@calcom/ui/components/dropdown";
import { Switch } from "@calcom/ui/components/form";
diff --git a/packages/ui/components/calendar-switch/CalendarSwitch.tsx b/packages/ui/components/calendar-switch/CalendarSwitch.tsx
index 1dc616de1d8..919a9dc5379 100644
--- a/packages/ui/components/calendar-switch/CalendarSwitch.tsx
+++ b/packages/ui/components/calendar-switch/CalendarSwitch.tsx
@@ -1,12 +1,24 @@
"use client";
import type { ReactNode } from "react";
-
-import { type ICalendarSwitchProps } from "@calcom/features/calendars/CalendarSwitch";
import classNames from "@calcom/ui/classNames";
import { Icon } from "../icon";
+export type ICalendarSwitchProps = {
+ title: string;
+ externalId: string;
+ type: string;
+ isChecked: boolean;
+ name: string;
+ isLastItemInList?: boolean;
+ destination?: boolean;
+ credentialId: number;
+ delegationCredentialId: string | null;
+ eventTypeId: number | null;
+ disabled?: boolean;
+};
+
export function CalendarSwitchComponent(
props: ICalendarSwitchProps & {
isLoading: boolean;
diff --git a/packages/ui/components/calendar-switch/index.ts b/packages/ui/components/calendar-switch/index.ts
index 942d6f9d355..b5c8adb4400 100644
--- a/packages/ui/components/calendar-switch/index.ts
+++ b/packages/ui/components/calendar-switch/index.ts
@@ -1 +1 @@
-export { CalendarSwitchComponent } from "./CalendarSwitch";
+export { CalendarSwitchComponent, type ICalendarSwitchProps } from "./CalendarSwitch";