import Link from "next/link"; import { useRouter } from "next/router"; import React, { useState } from "react"; import useAddAppMutation from "@calcom/app-store/_utils/useAddAppMutation"; import { InstallAppButton } from "@calcom/app-store/components"; import LicenseRequired from "@calcom/features/ee/common/components/v2/LicenseRequired"; import classNames from "@calcom/lib/classNames"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc/react"; import { App as AppType } from "@calcom/types/App"; import { Icon } from "@calcom/ui/Icon"; import { Button } from "@calcom/ui/components"; import { showToast, SkeletonText } from "@calcom/ui/v2"; import { SkeletonButton, Shell } from "@calcom/ui/v2"; import DisconnectIntegration from "@calcom/ui/v2/modules/integrations/DisconnectIntegration"; import HeadSeo from "@components/seo/head-seo"; const Component = ({ name, type, logo, slug, variant, body, categories, author, price = 0, commission, isGlobal = false, feeType, docs, website, email, tos, privacy, isProOnly, images, }: Parameters[0]) => { const { t } = useLocale(); const hasImages = images && images.length > 0; const router = useRouter(); const mutation = useAddAppMutation(null, { onSuccess: () => { showToast(t("app_successfully_installed"), "success"); }, onError: (error) => { if (error instanceof Error) showToast(error.message || t("app_could_not_be_installed"), "error"); }, }); const priceInDollar = Intl.NumberFormat("en-US", { style: "currency", currency: "USD", useGrouping: false, }).format(price); const [existingCredentials, setExistingCredentials] = useState([]); const appCredentials = trpc.viewer.appCredentialsByType.useQuery( { appType: type }, { onSuccess(data) { setExistingCredentials(data); }, } ); const allowedMultipleInstalls = categories.indexOf("calendar") > -1; return (
{hasImages && (
{images ? ( images.map((img) => ( {`Screenshot )) ) : ( )}
)}
{name}

{name}

{categories[0]} {" "} • {t("published_by", { author })}

{!appCredentials.isLoading ? ( isGlobal || (existingCredentials.length > 0 && allowedMultipleInstalls ? (
{!isGlobal && ( { if (useDefaultComponent) { props = { onClick: () => { mutation.mutate({ type, variant, slug }); }, loading: mutation.isLoading, }; } return ( ); }} /> )}
) : existingCredentials.length > 0 ? ( { router.replace("/apps/installed"); }} /> ) : ( { if (useDefaultComponent) { props = { onClick: () => { mutation.mutate({ type, variant, slug }); }, loading: mutation.isLoading, }; } return ( ); }} /> )) ) : ( )} {price !== 0 && ( {feeType === "usage-based" ? commission + "% + " + priceInDollar + "/booking" : priceInDollar} {feeType === "monthly" && "/" + t("month")} )}
{body}

{t("pricing")}

{price === 0 ? ( "Free" ) : ( <> {Intl.NumberFormat("en-US", { style: "currency", currency: "USD", useGrouping: false, }).format(price)} {feeType === "monthly" && "/" + t("month")} )}

{t("learn_more")}


{t("every_app_published")} {t("report_app")}
); }; export default function App(props: { name: string; description: AppType["description"]; type: AppType["type"]; isGlobal?: AppType["isGlobal"]; logo: string; slug: string; variant: string; body: React.ReactNode; categories: string[]; author: string; pro?: boolean; price?: number; commission?: number; feeType?: AppType["feeType"]; docs?: string; website?: string; email: string; // required tos?: string; privacy?: string; licenseRequired: AppType["licenseRequired"]; isProOnly: AppType["isProOnly"]; images?: string[]; }) { const { t } = useLocale(); return ( {props.licenseRequired ? ( ) : ( )} ); }