import { BookOpenIcon, CheckIcon, DocumentTextIcon, ExternalLinkIcon, FlagIcon, MailIcon, PlusIcon, ShieldCheckIcon, } from "@heroicons/react/outline"; import { ChevronLeftIcon } from "@heroicons/react/solid"; import Link from "next/link"; import React, { useEffect, useState } from "react"; import useAddAppMutation from "@calcom/app-store/_utils/useAddAppMutation"; import { InstallAppButton } from "@calcom/app-store/components"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; import { trpc } from "@calcom/trpc/react"; import { App as AppType } from "@calcom/types/App"; import { Button, SkeletonButton } from "@calcom/ui"; import LicenseRequired from "@ee/components/LicenseRequired"; import Shell from "@components/Shell"; import Badge from "@components/ui/Badge"; const Component = ({ name, type, logo, body, categories, author, price = 0, commission, isGlobal = false, feeType, docs, website, email, tos, privacy, isProOnly, }: Parameters[0]) => { const { t } = useLocale(); const { data: user } = trpc.useQuery(["viewer.me"]); const mutation = useAddAppMutation(null, { onSuccess: () => { showToast("App successfully installed", "success"); }, onError: (error) => { if (error instanceof Error) showToast(error.message || "App could not be installed", "error"); }, }); const priceInDollar = Intl.NumberFormat("en-US", { style: "currency", currency: "USD", useGrouping: false, }).format(price); const [installedAppCount, setInstalledAppCount] = useState(0); const [isLoading, setIsLoading] = useState(true); useEffect(() => { async function getInstalledApp(appCredentialType: string) { const queryParam = new URLSearchParams(); queryParam.set("app-credential-type", appCredentialType); try { const result = await fetch(`/api/app-store/installed?${queryParam.toString()}`, { method: "GET", headers: { "Content-Type": "application/json", }, }).then((data) => { setIsLoading(false); return data; }); if (result.status === 200) { const res = await result.json(); setInstalledAppCount(res.count); } } catch (error) { if (error instanceof Error) { console.log(error.message); } } } getInstalledApp(type); }, [type]); const allowedMultipleInstalls = categories.indexOf("calendar") > -1; return (
{t("browse_apps")}
{name}

{name}

{isProOnly && user?.plan === "FREE" ? ( PRO ) : null}

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

{!isLoading ? ( isGlobal || (installedAppCount > 0 && allowedMultipleInstalls) ? (
{!isGlobal && ( { if (useDefaultComponent) { props = { onClick: () => { mutation.mutate({ type }); }, loading: mutation.isLoading, }; } return ( ); }} /> )}
) : installedAppCount > 0 ? ( ) : ( { if (useDefaultComponent) { props = { onClick: () => { mutation.mutate({ type }); }, loading: mutation.isLoading, }; } return ( ); }} /> ) ) : ( )} {price !== 0 && ( {feeType === "usage-based" ? commission + "% + " + priceInDollar + "/booking" : priceInDollar} {feeType === "monthly" && "/" + t("month")} )}
{/* reintroduce once we show permissions and features */}
{body}

{t("categories")}

{categories.map((category) => ( {category} ))}

{t("pricing")}

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

{t("learn_more")}


Every app published on the Cal.com App Store is open source and thoroughly tested via peer reviews. Nevertheless, Cal.com, Inc. does not endorse or certify these apps unless they are published by Cal.com. If you encounter inappropriate content or behaviour please report it. Report App
); }; export default function App(props: { name: string; type: AppType["type"]; isGlobal?: AppType["isGlobal"]; logo: 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"]; }) { return ( {props.licenseRequired ? ( ) : ( )} ); }