diff --git a/src/components/EnterpriseSubsidiesContext/data/hooks.js b/src/components/EnterpriseSubsidiesContext/data/hooks.js
index 123d022df1..d699098cd0 100644
--- a/src/components/EnterpriseSubsidiesContext/data/hooks.js
+++ b/src/components/EnterpriseSubsidiesContext/data/hooks.js
@@ -41,26 +41,26 @@ export const useEnterpriseOffers = ({ enablePortalLearnerCreditManagementScreen,
let activeSubsidyFound = false;
if (results.length !== 0) {
let subsidy = results[0];
+ const offerData = [];
+ let activeSubsidyData = {};
for (let i = 0; i < results.length; i++) {
subsidy = results[i];
activeSubsidyFound = source === 'ecommerceApi'
? subsidy.isCurrent
: subsidy.isActive;
if (activeSubsidyFound === true) {
- break;
+ activeSubsidyData = {
+ id: subsidy.uuid || subsidy.id,
+ name: subsidy.title || subsidy.displayName,
+ start: subsidy.activeDatetime || subsidy.startDatetime,
+ end: subsidy.expirationDatetime || subsidy.endDatetime,
+ isCurrent: activeSubsidyFound,
+ };
+ offerData.push(activeSubsidyData);
+ setCanManageLearnerCredit(true);
}
}
- if (activeSubsidyFound === true) {
- const offerData = {
- id: subsidy.uuid || subsidy.id,
- name: subsidy.title || subsidy.displayName,
- start: subsidy.activeDatetime || subsidy.startDatetime,
- end: subsidy.expirationDatetime || subsidy.endDatetime,
- isCurrent: activeSubsidyFound,
- };
- setOffers([offerData]);
- setCanManageLearnerCredit(true);
- }
+ setOffers(offerData);
}
} catch (error) {
logError(error);
diff --git a/src/components/learner-credit-management/BudgetCard.jsx b/src/components/learner-credit-management/BudgetCard.jsx
index 138113f964..247769c715 100644
--- a/src/components/learner-credit-management/BudgetCard.jsx
+++ b/src/components/learner-credit-management/BudgetCard.jsx
@@ -15,6 +15,7 @@ import { useOfferRedemptions, useOfferSummary } from './data/hooks';
import LearnerCreditAggregateCards from './LearnerCreditAggregateCards';
import LearnerCreditAllocationTable from './LearnerCreditAllocationTable';
import { ROUTE_NAMES } from '../EnterpriseApp/data/constants';
+import { EXEC_ED_OFFER_TYPE } from './data/constants';
const BudgetCard = ({
offer,
@@ -136,16 +137,19 @@ const BudgetCard = ({
-
-
-
- {renderCardHeader('Executive Education')}
- {renderCardSection(offerSummary?.remainingFunds, offerSummary?.redeemedFundsExecEd)}
-
-
-
+ {offerSummary?.offerType === EXEC_ED_OFFER_TYPE
+ && (
+
+
+
+ {renderCardHeader('Executive Education')}
+ {renderCardSection(offerSummary?.remainingFunds, offerSummary?.redeemedFundsExecEd)}
+
+
+
+ )}
>
)
: (
diff --git a/src/components/learner-credit-management/data/constants.js b/src/components/learner-credit-management/data/constants.js
index 6c11820c1c..2e27404dee 100644
--- a/src/components/learner-credit-management/data/constants.js
+++ b/src/components/learner-credit-management/data/constants.js
@@ -14,3 +14,5 @@ export const LOW_REMAINING_BALANCE_PERCENT_THRESHOLD = 0.75;
export const NO_BALANCE_REMAINING_DOLLAR_THRESHOLD = 100;
export const DATE_FORMAT = 'MMMM DD, YYYY';
+
+export const EXEC_ED_OFFER_TYPE = 'learner_credit';
diff --git a/src/components/learner-credit-management/data/tests/utils.test.js b/src/components/learner-credit-management/data/tests/utils.test.js
index 88773efbcc..33902d40fe 100644
--- a/src/components/learner-credit-management/data/tests/utils.test.js
+++ b/src/components/learner-credit-management/data/tests/utils.test.js
@@ -1,4 +1,5 @@
import { transformOfferSummary } from '../utils';
+import { EXEC_ED_OFFER_TYPE } from '../constants';
describe('transformOfferSummary', () => {
it('should return null if there is no offerSummary', () => {
@@ -11,6 +12,7 @@ describe('transformOfferSummary', () => {
amountOfOfferSpent: 1.34,
remainingBalance: -0.34,
percentOfOfferSpent: 1.34,
+ offerType: EXEC_ED_OFFER_TYPE,
};
expect(transformOfferSummary(offerSummary)).toEqual({
@@ -20,6 +22,7 @@ describe('transformOfferSummary', () => {
redeemedFundsOcm: NaN,
remainingFunds: 0.0,
percentUtilized: 1.0,
+ offerType: EXEC_ED_OFFER_TYPE,
});
});
@@ -29,6 +32,7 @@ describe('transformOfferSummary', () => {
amountOfOfferSpent: 100,
remainingBalance: null,
percentOfOfferSpent: null,
+ offerType: 'Site',
};
expect(transformOfferSummary(offerSummary)).toEqual({
@@ -36,6 +40,7 @@ describe('transformOfferSummary', () => {
redeemedFunds: 100,
remainingFunds: null,
percentUtilized: null,
+ offerType: 'Site',
});
});
});
diff --git a/src/components/learner-credit-management/data/utils.js b/src/components/learner-credit-management/data/utils.js
index 22cff6cd3a..30b0efba01 100644
--- a/src/components/learner-credit-management/data/utils.js
+++ b/src/components/learner-credit-management/data/utils.js
@@ -37,6 +37,7 @@ export const transformOfferSummary = (offerSummary) => {
if (percentUtilized) {
percentUtilized = Math.min(percentUtilized, 1.0);
}
+ const { offerType } = offerSummary;
return {
totalFunds,
@@ -45,6 +46,7 @@ export const transformOfferSummary = (offerSummary) => {
redeemedFundsExecEd,
remainingFunds,
percentUtilized,
+ offerType,
};
};
diff --git a/src/components/learner-credit-management/tests/BudgetCard.test.jsx b/src/components/learner-credit-management/tests/BudgetCard.test.jsx
index afa6c60620..49350821d1 100644
--- a/src/components/learner-credit-management/tests/BudgetCard.test.jsx
+++ b/src/components/learner-credit-management/tests/BudgetCard.test.jsx
@@ -15,6 +15,7 @@ import '@testing-library/jest-dom/extend-expect';
import { IntlProvider } from '@edx/frontend-platform/i18n';
import BudgetCard from '../BudgetCard';
import { useOfferSummary, useOfferRedemptions } from '../data/hooks';
+import { EXEC_ED_OFFER_TYPE } from '../data/constants';
jest.mock('../data/hooks');
useOfferSummary.mockReturnValue({
@@ -51,6 +52,7 @@ const mockOfferSummary = {
redeemedFunds: 200,
remainingFunds: 4800,
percentUtilized: 0.04,
+ offerType: EXEC_ED_OFFER_TYPE,
};
const BudgetCardWrapper = ({ ...rest }) => (
@@ -67,7 +69,7 @@ describe('', () => {
jest.clearAllMocks();
});
- it('displays correctly', () => {
+ it('displays correctly for all offers', () => {
const mockOffer = {
id: mockEnterpriseOfferId,
name: mockOfferDisplayName,
@@ -105,6 +107,50 @@ describe('', () => {
expect(firstElementWithTestId).toHaveTextContent(formattedString);
});
+ it('displays correctly for Offer type Site', () => {
+ const mockOffer = {
+ id: mockEnterpriseOfferId,
+ name: mockOfferDisplayName,
+ start: '2022-01-01',
+ end: '2023-01-01',
+ };
+ const mockOfferRedemption = {
+ created: '2022-02-01',
+ enterpriseEnrollmentId: mockEnterpriseOfferEnrollmentId,
+ };
+ useOfferSummary.mockReturnValue({
+ isLoading: false,
+ offerSummary: {
+ totalFunds: 5000,
+ redeemedFunds: 200,
+ remainingFunds: 4800,
+ percentUtilized: 0.04,
+ offerType: 'Site',
+ },
+ });
+ useOfferRedemptions.mockReturnValue({
+ isLoading: false,
+ offerRedemptions: {
+ results: [mockOfferRedemption],
+ itemCount: 1,
+ pageCount: 1,
+ },
+ fetchOfferRedemptions: jest.fn(),
+ });
+ render();
+ expect(screen.getByText('Open Courses Marketplace'));
+ expect(screen.queryByText('Executive Education')).not.toBeInTheDocument();
+ expect(screen.getByText(`$${mockOfferSummary.redeemedFunds.toLocaleString()}`));
+ const formattedString = `${dayjs(mockOffer.start).format('MMMM D, YYYY')} - ${dayjs(mockOffer.end).format('MMMM D, YYYY')}`;
+ const elementsWithTestId = screen.getAllByTestId('offer-date');
+ const firstElementWithTestId = elementsWithTestId[0];
+ expect(firstElementWithTestId).toHaveTextContent(formattedString);
+ });
+
it('displays table on clicking view budget', async () => {
const mockOffer = {
id: mockEnterpriseOfferId,