Files
calendar/packages/app-store/InstallAppButtonWithoutPlanCheck.tsx
T
Benny JooandGitHub 7a1c780088 refactor: Break @calcom/app-store/components into individual component files (#23637)
* wip

* get rid of app-store/components

* create independent files

* update imports
2025-09-06 09:39:26 -03:00

42 lines
1.3 KiB
TypeScript

"use client";
import type { UseAddAppMutationOptions } from "@calcom/app-store/_utils/useAddAppMutation";
import useAddAppMutation from "@calcom/app-store/_utils/useAddAppMutation";
import { deriveAppDictKeyFromType } from "@calcom/lib/deriveAppDictKeyFromType";
import type { App } from "@calcom/types/App";
import { InstallAppButtonMap } from "./apps.browser.generated";
import type { InstallAppButtonProps } from "./types";
export const InstallAppButtonWithoutPlanCheck = (
props: {
type: App["type"];
options?: UseAddAppMutationOptions;
} & InstallAppButtonProps
) => {
const mutation = useAddAppMutation(null, props.options);
const key = deriveAppDictKeyFromType(props.type, InstallAppButtonMap);
const InstallAppButtonComponent = InstallAppButtonMap[key as keyof typeof InstallAppButtonMap];
if (!InstallAppButtonComponent)
return (
<>
{props.render({
useDefaultComponent: true,
disabled: props.disableInstall,
onClick: () => {
mutation.mutate({ type: props.type });
},
loading: mutation.data?.setupPending,
})}
</>
);
return (
<InstallAppButtonComponent
render={props.render}
onChanged={props.onChanged}
disableInstall={props.disableInstall}
/>
);
};