Skip to content

Commit

Permalink
fix: small subtitle fix (#1262)
Browse files Browse the repository at this point in the history
  • Loading branch information
kiram15 authored Jul 3, 2024
1 parent 3ab0a21 commit a09ff73
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions src/components/learner-credit-management/BudgetStatusSubtitle.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import isEmpty from 'lodash/isEmpty';

import PropTypes from 'prop-types';
import {
Expand All @@ -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: {
Expand All @@ -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: <Icon size="xs" src={GroupAdd} className="ml-1 d-inline-flex" svgAttrs={{ transform: 'translate(0,2)' }} />,
},
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',
}),
Expand All @@ -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 {
Expand Down Expand Up @@ -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,
};
Expand Down

0 comments on commit a09ff73

Please sign in to comment.