refactor: move useAppsData to features (#28098)
* refactor: move useAppsData to features + replace useIsPlatform with isPlatform prop in DisconnectIntegrationModal Co-Authored-By: [email protected] <[email protected]> * refactor: remove old useAppsData from web (moved to features) Co-Authored-By: [email protected] <[email protected]> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
6 files changed
+15
-20
No files matched your search
@@ -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<
|
||||
|
||||
@@ -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"];
|
||||
|
||||
@@ -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
|
||||
|
||||
+3
-4
@@ -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];
|
||||
+2
-1
@@ -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
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in new issue
Block a user