import { useSession } from "next-auth/react"; import React, { AriaRole, ComponentType, Fragment } from "react"; import { CONSOLE_URL } from "@calcom/lib/constants"; import { Icon } from "@calcom/ui/Icon"; import { EmptyScreen } from "@calcom/ui/v2"; type LicenseRequiredProps = { as?: keyof JSX.IntrinsicElements | ""; className?: string; role?: AriaRole | undefined; children: React.ReactNode; }; /** * This component will only render it's children if the installation has a valid * license. */ const LicenseRequired = ({ children, as = "", ...rest }: LicenseRequiredProps) => { const session = useSession(); const Component = as || Fragment; return ( {session.data?.hasValidLicense ? ( children ) : ( To enable this feature, get a deployment key at{" "} Cal.com console {" "} and add it to your .env as CALCOM_LICENSE_KEY. If your team already has a license, please contact{" "} peer@cal.com {" "} for help. } /> )} ); }; export const withLicenseRequired = (Component: ComponentType) => // eslint-disable-next-line react/display-name (hocProps: T) => ( ); export default LicenseRequired;