Skip to content

Scheduling infrastructure for absolutely everyone.

refactor: move useAppsData to features (#28098)

Rajiv Sahal972d70379ff5
diff --git a/apps/web/components/apps/installation/EventTypeAppSettingsWrapper.tsx b/apps/web/components/apps/installation/EventTypeAppSettingsWrapper.tsx
index 7b9a984a0d8..23b6a7600d0 100644
--- a/apps/web/components/apps/installation/EventTypeAppSettingsWrapper.tsx
+++ b/apps/web/components/apps/installation/EventTypeAppSettingsWrapper.tsx
@@ -1,11 +1,8 @@
-import { useEffect, type FC } from "react";
-
import { EventTypeAppSettings } from "@calcom/app-store/_components/EventTypeAppSettingsInterface";
import type { EventTypeAppsList } from "@calcom/app-store/utils";
-import useAppsData from "@calcom/web/modules/apps/hooks/useAppsData";
-
+import useAppsData from "@calcom/features/apps/hooks/useAppsData";
import type { ConfigureStepCardProps } from "@components/apps/installation/ConfigureStepCard";
-
+import { type FC, useEffect } from "react";
import type { TEventType } from "~/apps/installation/[[...step]]/step-view";
type EventTypeAppSettingsWrapperProps = Pick<
diff --git a/apps/web/modules/event-types/components/tabs/apps/EventAppsTab.tsx b/apps/web/modules/event-types/components/tabs/apps/EventAppsTab.tsx
index 4a962fac957..fd61d75b92a 100644
--- a/apps/web/modules/event-types/components/tabs/apps/EventAppsTab.tsx
+++ b/apps/web/modules/event-types/components/tabs/apps/EventAppsTab.tsx
@@ -1,12 +1,9 @@
-import Link from "next/link";
-import { useFormContext } from "react-hook-form";
-
import { EventTypeAppCard } from "@calcom/app-store/_components/EventTypeAppCardInterface";
import type { EventTypeAppCardComponentProps } from "@calcom/app-store/types";
import type { EventTypeAppsList } from "@calcom/app-store/utils";
-import useAppsData from "@calcom/web/modules/apps/hooks/useAppsData";
+import useAppsData from "@calcom/features/apps/hooks/useAppsData";
import useLockedFieldsManager from "@calcom/features/ee/managed-event-types/hooks/useLockedFieldsManager";
-import type { FormValues, EventTypeSetupProps, EventTypeApps } from "@calcom/features/eventtypes/lib/types";
+import type { EventTypeApps, EventTypeSetupProps, FormValues } from "@calcom/features/eventtypes/lib/types";
import ServerTrans from "@calcom/lib/components/ServerTrans";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
@@ -14,6 +11,8 @@ import { Alert } from "@calcom/ui/components/alert";
import { Button } from "@calcom/ui/components/button";
import { EmptyScreen } from "@calcom/ui/components/empty-screen";
import { Section } from "@calcom/ui/components/section";
+import Link from "next/link";
+import { useFormContext } from "react-hook-form";
export type EventType = Pick<EventTypeSetupProps, "eventType">["eventType"] &
EventTypeAppCardComponentProps["eventType"];
diff --git a/packages/features/apps/components/DisconnectIntegrationModal.tsx b/packages/features/apps/components/DisconnectIntegrationModal.tsx
index 137f6f8f138..a77e07dab92 100644
--- a/packages/features/apps/components/DisconnectIntegrationModal.tsx
+++ b/packages/features/apps/components/DisconnectIntegrationModal.tsx
@@ -1,4 +1,3 @@
-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";
@@ -17,6 +16,7 @@ interface DisconnectIntegrationModalProps {
teamId?: number;
handleRemoveApp: (params: RemoveAppParams) => void;
app?: App["slug"] | null;
+ isPlatform?: boolean;
}
export default function DisconnectIntegrationModal({
@@ -26,9 +26,9 @@ export default function DisconnectIntegrationModal({
handleModelClose,
teamId,
handleRemoveApp,
+ isPlatform = false,
}: DisconnectIntegrationModalProps) {
const { t } = useLocale();
- const isPlatform = useIsPlatform();
return (
<Dialog open={isOpen} onOpenChange={handleModelClose}>
<ConfirmationDialogContent
diff --git a/apps/web/modules/apps/hooks/useAppsData.ts b/packages/features/apps/hooks/useAppsData.ts
similarity index 96%
rename from apps/web/modules/apps/hooks/useAppsData.ts
rename to packages/features/apps/hooks/useAppsData.ts
index f6b8a07a25b..7f6b66912d7 100644
--- a/apps/web/modules/apps/hooks/useAppsData.ts
+++ b/packages/features/apps/hooks/useAppsData.ts
@@ -1,8 +1,7 @@
-import { useFormContext } from "react-hook-form";
-
import type { GetAppData, SetAppData } from "@calcom/app-store/EventTypeAppContext";
import type { EventTypeAppsList } from "@calcom/app-store/utils";
import type { FormValues } from "@calcom/features/eventtypes/lib/types";
+import { useFormContext } from "react-hook-form";
const useAppsData = () => {
const formMethods = useFormContext<FormValues>();
@@ -20,7 +19,7 @@ const useAppsData = () => {
};
const getAppDataGetter = (appId: EventTypeAppsList): GetAppData => {
- return function (key) {
+ return (key) => {
const appData = allAppsData[appId as keyof typeof allAppsData] || {};
if (key) {
return appData[key as keyof typeof appData];
@@ -36,7 +35,7 @@ const useAppsData = () => {
appCategories: string[],
credentialId?: number
): SetAppData => {
- return function (key, value) {
+ return (key, value) => {
// Always get latest data available in Form because consequent calls to setData would update the Form but not allAppsData(it would update during next render)
const allAppsDataFromForm = formMethods.getValues("metadata")?.apps || {};
const appData = allAppsDataFromForm[appId];
diff --git a/packages/platform/atoms/connect/conferencing-apps/ConferencingAppsViewPlatformWrapper.tsx b/packages/platform/atoms/connect/conferencing-apps/ConferencingAppsViewPlatformWrapper.tsx
index 98de1682ae6..49c45d82a55 100644
--- a/packages/platform/atoms/connect/conferencing-apps/ConferencingAppsViewPlatformWrapper.tsx
+++ b/packages/platform/atoms/connect/conferencing-apps/ConferencingAppsViewPlatformWrapper.tsx
@@ -1,6 +1,7 @@
"use client";
import AccountDialog from "@calcom/app-store/office365video/components/AccountDialog";
+import DisconnectIntegrationModal from "@calcom/features/apps/components/DisconnectIntegrationModal";
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { GOOGLE_MEET, OFFICE_365_VIDEO, ZOOM } from "@calcom/platform-constants";
@@ -17,7 +18,6 @@ import {
import { EmptyScreen } from "@calcom/ui/components/empty-screen";
import { SkeletonContainer, SkeletonText } from "@calcom/ui/components/skeleton";
import { AppList } from "@calcom/web/modules/apps/components/AppList";
-import DisconnectIntegrationModal from "@calcom/features/apps/components/DisconnectIntegrationModal";
import { useQueryClient } from "@tanstack/react-query";
import { useReducer, useState } from "react";
import { AtomsWrapper } from "../../src/components/atoms-wrapper";
@@ -343,6 +343,7 @@ export const ConferencingAppsViewPlatformWrapper = ({
credentialId={modal.credentialId}
app={modal.app}
handleRemoveApp={handleRemoveApp}
+ isPlatform={true}
/>
<AccountDialog
diff --git a/packages/platform/atoms/event-types/wrappers/EventPaymentsTabPlatformWrapper.tsx b/packages/platform/atoms/event-types/wrappers/EventPaymentsTabPlatformWrapper.tsx
index ca562fa861b..84eb6651585 100644
--- a/packages/platform/atoms/event-types/wrappers/EventPaymentsTabPlatformWrapper.tsx
+++ b/packages/platform/atoms/event-types/wrappers/EventPaymentsTabPlatformWrapper.tsx
@@ -1,13 +1,12 @@
-import { EventTypeAppCard } from "@calcom/app-store/_components/EventTypeAppCardInterface";
import type {
EventTypeApp,
EventTypeForAppCard,
} from "@calcom/app-store/_components/EventTypeAppCardInterface";
+import { EventTypeAppCard } from "@calcom/app-store/_components/EventTypeAppCardInterface";
import type { EventTypeAppsList } from "@calcom/app-store/utils";
-import useAppsData from "@calcom/web/modules/apps/hooks/useAppsData";
+import useAppsData from "@calcom/features/apps/hooks/useAppsData";
import type { EventTypeSetupProps } from "@calcom/features/eventtypes/lib/types";
import { EmptyScreen } from "@calcom/ui/components/empty-screen";
-
import { StripeConnect } from "../../connect/stripe/StripeConnect";
import { useCheck } from "../../hooks/stripe/useCheck";
import { useAtomsEventTypeById } from "../hooks/useAtomEventTypeAppIntegration";