From a09ff73908bec685aba698a4c641e77dbc9c792f Mon Sep 17 00:00:00 2001 From: Kira Miller <31229189+kiram15@users.noreply.github.com> Date: Wed, 3 Jul 2024 12:55:05 -0600 Subject: [PATCH] fix: small subtitle fix (#1262) --- .../BudgetStatusSubtitle.jsx | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/components/learner-credit-management/BudgetStatusSubtitle.jsx b/src/components/learner-credit-management/BudgetStatusSubtitle.jsx index a380b4b83d..a30e7b7b27 100644 --- a/src/components/learner-credit-management/BudgetStatusSubtitle.jsx +++ b/src/components/learner-credit-management/BudgetStatusSubtitle.jsx @@ -1,4 +1,5 @@ import React from 'react'; +import isEmpty from 'lodash/isEmpty'; import PropTypes from 'prop-types'; import { @@ -8,19 +9,15 @@ import { GroupAdd, Groups, ManageAccounts } from '@openedx/paragon/icons'; import { useIntl } from '@edx/frontend-platform/i18n'; import { - formatDate, - useEnterpriseCustomer, - useEnterpriseGroup, - isLmsBudget, + formatDate, useEnterpriseCustomer, useEnterpriseGroup, isLmsBudget, } from './data'; const BudgetStatusSubtitle = ({ badgeVariant, status, isAssignable, term, date, policy, enterpriseUUID, isRetired, }) => { const { data: enterpriseGroup } = useEnterpriseGroup(policy); + const customGroup = !isEmpty(policy?.groupAssociations) && !enterpriseGroup?.appliesToAllContexts; const { data: enterpriseCustomer } = useEnterpriseCustomer(enterpriseUUID); - // universal group = all members of the organization are automatically in a group - const universalGroup = enterpriseGroup?.appliesToAllContexts; const intl = useIntl(); const budgetType = { lms: { @@ -46,31 +43,31 @@ const BudgetStatusSubtitle = ({ description: 'Enrollment type for budgets that are assignable', }), }, - browseAndEnroll: { + groupsBrowseAndEnroll: { enrollmentType: intl.formatMessage({ - id: 'lcm.budget.detail.page.overview.enroll.browse.and.enroll', + id: 'lcm.budget.detail.page.overview.enroll.groups.browse.and.enroll', defaultMessage: 'Browse & Enroll', description: 'Enrollment type for budgets that are browsable and enrollable', }), popoverText: intl.formatMessage({ - id: 'lcm.budget.detail.page.overview.enroll.browse.and.enroll.popover', + id: 'lcm.budget.detail.page.overview.enroll.groups.browse.and.enroll.popover', defaultMessage: 'Available to members added to this budget', description: 'Popover text for budgets that are browsable and enrollable', }), icon: , }, - orgBrowseAndEnroll: { + browseAndEnroll: { enrollmentType: intl.formatMessage({ - id: 'lcm.budget.detail.page.overview.enroll.org.browse.and.enroll', + id: 'lcm.budget.detail.page.overview.enroll.browse.and.enroll', defaultMessage: 'Browse & Enroll', description: 'Enrollment type for budgets that are browsable and enrollable', }), popoverText: intl.formatMessage({ - id: 'lcm.budget.detail.page.overview.enroll.org.browse.and.enroll.popover', + id: 'lcm.budget.detail.page.overview.enroll.browse.and.enroll.popover', defaultMessage: 'Available to all people in your organization', description: 'Popover text for budgets that are browsable and enrollable', }), @@ -79,10 +76,10 @@ const BudgetStatusSubtitle = ({ }; let budgetTypeToRender; - if (isLmsBudget(enterpriseCustomer?.activeIntegrations.length, universalGroup)) { + if (isLmsBudget(enterpriseCustomer?.activeIntegrations.length, enterpriseGroup?.appliesToAllContexts)) { budgetTypeToRender = budgetType.lms; - } else if (universalGroup) { - budgetTypeToRender = budgetType.orgBrowseAndEnroll; + } else if (customGroup) { + budgetTypeToRender = budgetType.groupsBrowseAndEnroll; } else if (isAssignable) { budgetTypeToRender = budgetType.assignable; } else { @@ -130,7 +127,9 @@ BudgetStatusSubtitle.propTypes = { isAssignable: PropTypes.bool.isRequired, term: PropTypes.string, date: PropTypes.string, - policy: PropTypes.shape({}).isRequired, + policy: PropTypes.shape({ + groupAssociations: PropTypes.shape({}), + }).isRequired, enterpriseUUID: PropTypes.string.isRequired, isRetired: PropTypes.bool.isRequired, };