2022-08-31 19:42:37 +00:00
|
|
|
/**
|
|
|
|
* @deprecated file
|
|
|
|
* All new changes should be made to the V2 file in
|
|
|
|
* `/packages/features/ee/common/components/v2/LicenseRequired.tsx`
|
|
|
|
*/
|
2022-05-26 17:07:14 +00:00
|
|
|
import { useSession } from "next-auth/react";
|
2022-07-28 19:58:26 +00:00
|
|
|
import React, { AriaRole, ComponentType, Fragment } from "react";
|
2022-05-26 17:07:14 +00:00
|
|
|
|
|
|
|
import { CONSOLE_URL } from "@calcom/lib/constants";
|
2022-11-23 02:55:25 +00:00
|
|
|
import { EmptyScreen, Icon } from "@calcom/ui";
|
2022-05-26 17:07:14 +00:00
|
|
|
|
|
|
|
type LicenseRequiredProps = {
|
|
|
|
as?: keyof JSX.IntrinsicElements | "";
|
|
|
|
className?: string;
|
|
|
|
role?: AriaRole | undefined;
|
|
|
|
children: React.ReactNode;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2022-08-31 19:42:37 +00:00
|
|
|
* @deprecated file
|
|
|
|
* All new changes should be made to the V2 file in
|
|
|
|
* `/packages/features/ee/common/components/v2/LicenseRequired.tsx`
|
2022-05-26 17:07:14 +00:00
|
|
|
* This component will only render it's children if the installation has a valid
|
|
|
|
* license.
|
|
|
|
*/
|
2022-07-28 19:58:26 +00:00
|
|
|
const LicenseRequired = ({ children, as = "", ...rest }: LicenseRequiredProps) => {
|
2022-05-26 17:07:14 +00:00
|
|
|
const session = useSession();
|
|
|
|
const Component = as || Fragment;
|
|
|
|
return (
|
|
|
|
<Component {...rest}>
|
|
|
|
{session.data?.hasValidLicense ? (
|
|
|
|
children
|
|
|
|
) : (
|
|
|
|
<EmptyScreen
|
2022-08-03 16:01:29 +00:00
|
|
|
Icon={Icon.FiAlertTriangle}
|
2022-05-26 17:07:14 +00:00
|
|
|
headline="This is an enterprise feature"
|
|
|
|
description={
|
|
|
|
<>
|
|
|
|
To enable this feature, get a deployment key at{" "}
|
|
|
|
<a href={CONSOLE_URL} target="_blank" rel="noopener noreferrer" className="underline">
|
|
|
|
Cal.com console
|
2022-07-14 20:48:50 +00:00
|
|
|
</a>{" "}
|
|
|
|
and add it to your .env as <code>CALCOM_LICENSE_KEY</code>. If your team already has a license,
|
|
|
|
please contact{" "}
|
2022-06-03 19:59:40 +00:00
|
|
|
<a href="mailto:peer@cal.com" className="underline">
|
|
|
|
peer@cal.com
|
|
|
|
</a>{" "}
|
|
|
|
for help.
|
2022-05-26 17:07:14 +00:00
|
|
|
</>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</Component>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-07-28 19:58:26 +00:00
|
|
|
export const withLicenseRequired =
|
|
|
|
<T,>(Component: ComponentType<T>) =>
|
2022-05-26 17:07:14 +00:00
|
|
|
// eslint-disable-next-line react/display-name
|
2022-07-28 19:58:26 +00:00
|
|
|
(hocProps: T) =>
|
|
|
|
(
|
2022-05-26 17:07:14 +00:00
|
|
|
<LicenseRequired>
|
2022-07-28 19:58:26 +00:00
|
|
|
<Component {...hocProps} />
|
2022-05-26 17:07:14 +00:00
|
|
|
</LicenseRequired>
|
|
|
|
);
|
|
|
|
|
|
|
|
export default LicenseRequired;
|