2023-01-23 09:58:41 +00:00
|
|
|
import type { ReactNode } from "react";
|
|
|
|
|
|
|
|
import { classNames } from "@calcom/lib";
|
2023-01-31 19:10:21 +00:00
|
|
|
import { useHasPaidPlan } from "@calcom/lib/hooks/useHasPaidPlan";
|
2023-01-23 09:58:41 +00:00
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
2023-01-24 15:27:05 +00:00
|
|
|
import isCalcom from "@calcom/lib/isCalcom";
|
2023-01-23 23:08:01 +00:00
|
|
|
import { EmptyScreen } from "@calcom/ui";
|
|
|
|
import { FiUsers } from "@calcom/ui/components/icon";
|
2023-01-23 09:58:41 +00:00
|
|
|
|
|
|
|
export function UpgradeTip({
|
|
|
|
dark,
|
|
|
|
title,
|
2023-02-01 20:41:47 +00:00
|
|
|
emptyTitle,
|
|
|
|
emptyDescription,
|
2023-01-23 09:58:41 +00:00
|
|
|
description,
|
|
|
|
background,
|
|
|
|
features,
|
|
|
|
buttons,
|
|
|
|
isParentLoading,
|
|
|
|
children,
|
|
|
|
}: {
|
|
|
|
dark?: boolean;
|
|
|
|
title: string;
|
|
|
|
description: string;
|
2023-02-01 20:41:47 +00:00
|
|
|
/* overwrite EmptyScreen text */
|
|
|
|
emptyTitle?: string;
|
|
|
|
emptyDescription?: string;
|
2023-01-23 09:58:41 +00:00
|
|
|
background: string;
|
|
|
|
features: Array<{ icon: JSX.Element; title: string; description: string }>;
|
|
|
|
buttons?: JSX.Element;
|
|
|
|
/**Chldren renders when the user is in a team */
|
|
|
|
children: JSX.Element;
|
|
|
|
isParentLoading?: ReactNode;
|
|
|
|
}) {
|
|
|
|
const { t } = useLocale();
|
2023-01-31 19:10:21 +00:00
|
|
|
const { isLoading, hasPaidPlan } = useHasPaidPlan();
|
2023-01-23 09:58:41 +00:00
|
|
|
|
2023-01-31 19:10:21 +00:00
|
|
|
if (hasPaidPlan) return children;
|
2023-01-23 09:58:41 +00:00
|
|
|
|
2023-01-24 15:27:05 +00:00
|
|
|
if (isParentLoading || isLoading) return <>{isParentLoading}</>;
|
|
|
|
|
2023-01-23 09:58:41 +00:00
|
|
|
if (!isCalcom)
|
2023-02-01 20:41:47 +00:00
|
|
|
return (
|
|
|
|
<EmptyScreen
|
|
|
|
Icon={FiUsers}
|
|
|
|
headline={emptyTitle ? t(emptyTitle) : t(title)}
|
|
|
|
description={emptyDescription ? t(emptyDescription) : t(description)}
|
|
|
|
buttonRaw={buttons}
|
|
|
|
/>
|
|
|
|
);
|
2023-01-23 09:58:41 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div className="-mt-10 rtl:ml-4 sm:mt-0 md:rtl:ml-0 lg:-mt-6">
|
|
|
|
<div
|
|
|
|
className="flex w-full justify-between overflow-hidden rounded-lg pt-4 pb-10 md:min-h-[295px] md:pt-10"
|
|
|
|
style={{
|
|
|
|
background: `url(${background})`,
|
|
|
|
backgroundSize: "cover",
|
|
|
|
backgroundRepeat: "no-repeat",
|
|
|
|
}}>
|
|
|
|
<div className="mt-3 px-8 sm:px-14">
|
|
|
|
<h1 className={classNames("font-cal text-3xl", dark && "text-white")}>{t(title)}</h1>
|
|
|
|
<p className={classNames("my-4 max-w-sm", dark ? "text-white" : "text-gray-600")}>
|
|
|
|
{t(description)}
|
|
|
|
</p>
|
|
|
|
{buttons}
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-01-24 15:27:05 +00:00
|
|
|
|
2023-01-23 09:58:41 +00:00
|
|
|
<div className="mt-4 grid-cols-3 md:grid md:gap-4">
|
2023-01-24 15:27:05 +00:00
|
|
|
{features.map((feature) => (
|
|
|
|
<div key={feature.title} className="mb-4 min-h-[180px] w-full rounded-md bg-gray-50 p-8 md:mb-0">
|
|
|
|
{feature.icon}
|
|
|
|
<h2 className="font-cal mt-4 text-lg">{feature.title}</h2>
|
|
|
|
<p className="text-gray-700">{feature.description}</p>
|
|
|
|
</div>
|
|
|
|
))}
|
2023-01-23 09:58:41 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|