import type { ReactNode } from "react"; import { classNames } from "@calcom/lib"; import { useHasTeamPlan } from "@calcom/lib/hooks/useHasPaidPlan"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { useGetTheme } from "@calcom/lib/hooks/useTheme"; import { trpc } from "@calcom/trpc"; export function UpgradeTip({ title, description, background, features, buttons, isParentLoading, children, plan, }: { title: string; description: string; /* overwrite EmptyScreen text */ 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; plan: "team" | "enterprise"; }) { const { activeTheme } = useGetTheme(); const { t } = useLocale(); const { isPending, hasTeamPlan } = useHasTeamPlan(); const { data } = trpc.viewer.teams.getUpgradeable.useQuery(); const imageSrc = `${background}${activeTheme === "dark" ? "-dark" : ""}.jpg`; const hasEnterprisePlan = false; //const { isPending , hasEnterprisePlan } = useHasEnterprisePlan(); const hasUnpublishedTeam = !!data?.[0]; if (plan === "team" && (hasTeamPlan || hasUnpublishedTeam)) return children; if (plan === "enterprise" && hasEnterprisePlan) return children; if (isPending) return <>{isParentLoading}; return ( <>
{title}

{t(title)}

{t(description)}

{buttons}
{features.map((feature) => (
{feature.icon}

{feature.title}

{feature.description}

))}
); }