|
1 | 1 | "use client"; |
2 | 2 |
|
3 | 3 | import Link from "next/link"; |
4 | | -import { useRouter } from "next/navigation"; |
5 | | -import { useEffect, useRef } from "react"; |
6 | 4 |
|
7 | 5 | import type { UseAddAppMutationOptions } from "@calcom/app-store/_utils/useAddAppMutation"; |
8 | 6 | import useAddAppMutation from "@calcom/app-store/_utils/useAddAppMutation"; |
9 | 7 | import { WEBAPP_URL } from "@calcom/lib/constants"; |
10 | 8 | import { deriveAppDictKeyFromType } from "@calcom/lib/deriveAppDictKeyFromType"; |
11 | | -import { useHasTeamPlan } from "@calcom/lib/hooks/useHasPaidPlan"; |
12 | 9 | import { useLocale } from "@calcom/lib/hooks/useLocale"; |
13 | | -import { trpc } from "@calcom/trpc/react"; |
14 | 10 | import type { RouterOutputs } from "@calcom/trpc/react"; |
15 | 11 | import type { App } from "@calcom/types/App"; |
16 | | -import { Icon } from "@calcom/ui/components/icon"; |
17 | 12 | import classNames from "@calcom/ui/classNames"; |
| 13 | +import { Icon } from "@calcom/ui/components/icon"; |
18 | 14 |
|
19 | 15 | import { InstallAppButtonMap } from "./apps.browser.generated"; |
20 | 16 | import type { InstallAppButtonProps } from "./types"; |
@@ -59,44 +55,8 @@ export const InstallAppButton = ( |
59 | 55 | disableInstall?: boolean; |
60 | 56 | } & InstallAppButtonProps |
61 | 57 | ) => { |
62 | | - const { isPending: isUserLoading, data: user } = trpc.viewer.me.get.useQuery(); |
63 | | - const router = useRouter(); |
64 | | - const proProtectionElementRef = useRef<HTMLDivElement | null>(null); |
65 | | - const { isPending: isTeamPlanStatusLoading, hasTeamPlan } = useHasTeamPlan(); |
66 | | - |
67 | | - useEffect(() => { |
68 | | - const el = proProtectionElementRef.current; |
69 | | - if (!el) { |
70 | | - return; |
71 | | - } |
72 | | - el.addEventListener( |
73 | | - "click", |
74 | | - (e) => { |
75 | | - if (!user) { |
76 | | - router.push( |
77 | | - `${WEBAPP_URL}/auth/login?callbackUrl=${WEBAPP_URL + location.pathname + location.search}` |
78 | | - ); |
79 | | - e.stopPropagation(); |
80 | | - return; |
81 | | - } |
82 | | - |
83 | | - if (props.teamsPlanRequired && !hasTeamPlan) { |
84 | | - // TODO: I think we should show the UpgradeTip in a Dialog here. This would solve the problem of no way to go back to the App page from the UpgradeTip page(except browser's back button) |
85 | | - router.push(props.teamsPlanRequired.upgradeUrl); |
86 | | - e.stopPropagation(); |
87 | | - return; |
88 | | - } |
89 | | - }, |
90 | | - true |
91 | | - ); |
92 | | - }, [isUserLoading, user, router, hasTeamPlan, props.teamsPlanRequired]); |
93 | | - |
94 | | - if (isUserLoading || isTeamPlanStatusLoading) { |
95 | | - return null; |
96 | | - } |
97 | | - |
98 | 58 | return ( |
99 | | - <div ref={proProtectionElementRef} className={props.wrapperClassName}> |
| 59 | + <div className={props.wrapperClassName}> |
100 | 60 | <InstallAppButtonWithoutPlanCheck {...props} /> |
101 | 61 | </div> |
102 | 62 | ); |
|
0 commit comments