From 88ac21d9dde6033a3ae03bc9c597d57f2cf33562 Mon Sep 17 00:00:00 2001 From: Maham Akif Date: Mon, 5 Aug 2024 13:59:42 +0500 Subject: [PATCH] feat: show video section to only those learners who have active subscription --- src/components/search/Search.jsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/components/search/Search.jsx b/src/components/search/Search.jsx index bf96bb8e45..ee9f92ec1a 100644 --- a/src/components/search/Search.jsx +++ b/src/components/search/Search.jsx @@ -27,10 +27,12 @@ import { useEnterpriseFeatures, useEnterpriseOffers, useIsAssignmentsOnlyLearner, + useSubscriptions, } from '../app/data'; import { useAlgoliaSearch } from '../../utils/hooks'; import ContentTypeSearchResultsContainer from './ContentTypeSearchResultsContainer'; import SearchVideo from './SearchVideo'; +import { LICENSE_STATUS } from '../enterprise-user-subsidy/data/constants'; export const sendPushEvent = (isPreQueryEnabled, courseKeyMetadata) => { if (isPreQueryEnabled) { @@ -91,6 +93,17 @@ const Search = () => { config.PREQUERY_SEARCH_EXPERIMENT_VARIANT_ID, ); + const { data: { subscriptionLicense } } = useSubscriptions(); + const hasActiveSubscription = ( + subscriptionLicense?.status === LICENSE_STATUS.ACTIVATED + && subscriptionLicense?.subscriptionPlan.isCurrent + ); + const enableVideoCatalog = ( + canOnlyViewHighlightSets === false + && features.FEATURE_ENABLE_VIDEO_CATALOG + && hasActiveSubscription + ); + const PAGE_TITLE = intl.formatMessage({ id: 'enterprise.search.page.title', defaultMessage: 'Search Courses and Programs - {enterpriseName}', @@ -175,8 +188,7 @@ const Search = () => { {features.ENABLE_PATHWAYS && (canOnlyViewHighlightSets === false) && } {features.ENABLE_PROGRAMS && (canOnlyViewHighlightSets === false) && } {canOnlyViewHighlightSets === false && } - {canOnlyViewHighlightSets === false - && (features.FEATURE_ENABLE_VIDEO_CATALOG) && } + {enableVideoCatalog && } )} {/* render a single contentType if the refinement exist and is either a course, program or learnerpathway */}