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-12-07 20:53:44 +00:00
|
|
|
import DOMPurify from "dompurify";
|
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
|
|
|
|
2023-01-31 20:44:14 +00:00
|
|
|
import { APP_NAME } from "@calcom/lib/constants";
|
2022-11-30 21:52:56 +00:00
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
2023-01-23 23:08:01 +00:00
|
|
|
import { EmptyScreen } from "@calcom/ui";
|
|
|
|
import { FiAlertTriangle } from "@calcom/ui/components/icon";
|
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-11-30 21:52:56 +00:00
|
|
|
const { t } = useLocale();
|
2022-05-26 17:07:14 +00:00
|
|
|
const session = useSession();
|
|
|
|
const Component = as || Fragment;
|
|
|
|
return (
|
|
|
|
<Component {...rest}>
|
|
|
|
{session.data?.hasValidLicense ? (
|
|
|
|
children
|
|
|
|
) : (
|
|
|
|
<EmptyScreen
|
2023-01-23 23:08:01 +00:00
|
|
|
Icon={FiAlertTriangle}
|
2022-12-07 20:53:44 +00:00
|
|
|
headline={t("enterprise_license")}
|
2022-05-26 17:07:14 +00:00
|
|
|
description={
|
2022-11-30 21:52:56 +00:00
|
|
|
<div
|
|
|
|
dangerouslySetInnerHTML={{
|
2022-12-07 20:53:44 +00:00
|
|
|
__html: DOMPurify.sanitize(
|
|
|
|
t("enterprise_license_description", {
|
2023-01-17 21:49:40 +00:00
|
|
|
consoleUrl: `<a href="https://go.cal.com/console" target="_blank" class="underline">
|
2022-11-30 21:52:56 +00:00
|
|
|
${APP_NAME}
|
|
|
|
</a>`,
|
2023-01-17 21:49:40 +00:00
|
|
|
supportMail: `<a href="mailto:sales@cal.com" class="underline">
|
|
|
|
sales@cal.com
|
2022-11-30 21:52:56 +00:00
|
|
|
</a>`,
|
2022-12-07 20:53:44 +00:00
|
|
|
})
|
|
|
|
),
|
2022-11-30 21:52:56 +00:00
|
|
|
}}
|
|
|
|
/>
|
2022-05-26 17:07:14 +00:00
|
|
|
}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</Component>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-07-28 19:58:26 +00:00
|
|
|
export const withLicenseRequired =
|
2023-01-27 01:50:56 +00:00
|
|
|
<T extends JSX.IntrinsicAttributes>(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;
|