diff --git a/src/components/ContentHighlights/ContentHighlights.jsx b/src/components/ContentHighlights/ContentHighlights.jsx index 9dcd792768..626910eeb0 100644 --- a/src/components/ContentHighlights/ContentHighlights.jsx +++ b/src/components/ContentHighlights/ContentHighlights.jsx @@ -22,7 +22,7 @@ const ContentHighlights = ({ location, enterpriseGroupsV1 }) => { const { state: locationState } = location; const [toasts, setToasts] = useState([]); const isEdxStaff = getAuthenticatedUser().administrator; - const [isSubGroup, setIsSubGroup] = useState(false); + const [hasBudgetGroup, setHasBudgetGroup] = useState(false); const { enterpriseCuration: { enterpriseCuration } } = useContext(EnterpriseAppContext); const intl = useIntl(); @@ -31,8 +31,8 @@ const ContentHighlights = ({ location, enterpriseGroupsV1 }) => { try { const response = await LmsApiService.fetchEnterpriseGroups(); response.data.results.forEach((group) => { - if (group.applies_to_all_contexts === false) { - setIsSubGroup(true); + if (group.group_type === 'budget') { + setHasBudgetGroup(true); } }); } catch (error) { @@ -102,7 +102,7 @@ const ContentHighlights = ({ location, enterpriseGroupsV1 }) => { description: 'Hero title for the highlights page.', })} /> - {isSubGroup && ( + {hasBudgetGroup && ( ', () => { }); it('Displays the alert if custom groups is enabled and user is staff', () => { LmsApiService.fetchEnterpriseGroups.mockImplementation(() => Promise.resolve({ - data: { results: [{ applies_to_all_contexts: true }] }, + data: { results: [{ group_type: 'budget' }] }, })); renderWithRouter(); }); diff --git a/src/components/Sidebar/index.jsx b/src/components/Sidebar/index.jsx index 110f1ffb34..8fbc8083aa 100644 --- a/src/components/Sidebar/index.jsx +++ b/src/components/Sidebar/index.jsx @@ -48,8 +48,8 @@ const Sidebar = ({ const { canManageLearnerCredit } = useContext(EnterpriseSubsidiesContext); const { FEATURE_CONTENT_HIGHLIGHTS } = getConfig(); const isEdxStaff = getAuthenticatedUser().administrator; - const [isSubGroup, setIsSubGroup] = useState(false); - const hideHighlightsForGroups = enterpriseGroupsV1 && isSubGroup && !isEdxStaff; + const [hasBudgetGroup, setHasBudgetGroup] = useState(false); + const hideHighlightsForGroups = enterpriseGroupsV1 && hasBudgetGroup && !isEdxStaff; const intl = useIntl(); const getSidebarWidth = useCallback(() => { @@ -89,8 +89,8 @@ const Sidebar = ({ // we only want to hide the feature if a customer has a group this does not // apply to all contexts/include all users response.data.results.forEach((group) => { - if (group.applies_to_all_contexts === false) { - setIsSubGroup(true); + if (group.group_type === 'budget') { + setHasBudgetGroup(true); } }); } catch (error) { diff --git a/src/containers/Sidebar/Sidebar.test.jsx b/src/containers/Sidebar/Sidebar.test.jsx index 35b9550ae0..080d608164 100644 --- a/src/containers/Sidebar/Sidebar.test.jsx +++ b/src/containers/Sidebar/Sidebar.test.jsx @@ -444,9 +444,9 @@ describe('', () => { }); it.each([ - { appliesToAllContexts: true }, - { appliesToAllContexts: false }, - ])('hides highlights when we have groups with a subset of all learners (%s)', async ({ appliesToAllContexts }) => { + { groupType: 'budget' }, + { groupType: 'flex' }, + ])('hides highlights when we have budget groups (%s)', async ({ groupType }) => { getAuthenticatedUser.mockReturnValue({ administrator: false, }); @@ -460,12 +460,12 @@ describe('', () => { }, }); LmsApiService.fetchEnterpriseGroups.mockImplementation(() => Promise.resolve({ - data: { results: [{ applies_to_all_contexts: appliesToAllContexts }] }, + data: { results: [{ group_type: groupType }] }, })); render(); const highlightsLink = screen.queryByRole('link', { name: 'Highlights' }); await waitFor(() => { - if (appliesToAllContexts) { + if (groupType === 'flex') { expect(highlightsLink).toBeInTheDocument(); } else { expect(highlightsLink).not.toBeInTheDocument();