From 5a81f5f90b34845f5b4b3bdd46acf29d04bf3987 Mon Sep 17 00:00:00 2001 From: Palash Gupta Date: Tue, 23 May 2023 19:29:24 +0530 Subject: [PATCH] fix: cloud header button is hidden when is license is not active (#2756) --- frontend/src/container/Header/index.tsx | 14 +++++++++++--- frontend/src/hooks/useLicense/constant.ts | 4 ++++ frontend/src/hooks/useLicense/index.ts | 4 ++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/frontend/src/container/Header/index.tsx b/frontend/src/container/Header/index.tsx index 8b906eab74..d3dcb52c99 100644 --- a/frontend/src/container/Header/index.tsx +++ b/frontend/src/container/Header/index.tsx @@ -8,6 +8,7 @@ import { Logout } from 'api/utils'; import ROUTES from 'constants/routes'; import Config from 'container/ConfigDropdown'; import { useIsDarkMode, useThemeMode } from 'hooks/useDarkMode'; +import useLicense, { LICENSE_PLAN_STATUS } from 'hooks/useLicense'; import { Dispatch, KeyboardEvent, @@ -95,6 +96,11 @@ function HeaderContainer(): JSX.Element { ); }; + const { data } = useLicense(); + + const isLicenseActive = + data?.payload?.find((e) => e.isCurrent)?.status === LICENSE_PLAN_STATUS.VALID; + return (
@@ -111,9 +117,11 @@ function HeaderContainer(): JSX.Element { - + {!isLicenseActive && ( + + )} diff --git a/frontend/src/hooks/useLicense/constant.ts b/frontend/src/hooks/useLicense/constant.ts index 7389df50df..03bbb7325c 100644 --- a/frontend/src/hooks/useLicense/constant.ts +++ b/frontend/src/hooks/useLicense/constant.ts @@ -1,3 +1,7 @@ export const LICENSE_PLAN_KEY = { ENTERPRISE_PLAN: 'ENTERPRISE_PLAN', }; + +export const LICENSE_PLAN_STATUS = { + VALID: 'VALID', +}; diff --git a/frontend/src/hooks/useLicense/index.ts b/frontend/src/hooks/useLicense/index.ts index ca8f821267..387e93e7d6 100644 --- a/frontend/src/hooks/useLicense/index.ts +++ b/frontend/src/hooks/useLicense/index.ts @@ -1,6 +1,6 @@ -import { LICENSE_PLAN_KEY } from './constant'; +import { LICENSE_PLAN_KEY, LICENSE_PLAN_STATUS } from './constant'; import useLicense from './useLicense'; export default useLicense; -export { LICENSE_PLAN_KEY }; +export { LICENSE_PLAN_KEY, LICENSE_PLAN_STATUS };