-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "feat: subsidy box points to learner credit (#810)"
This reverts commit 3637bed.
- Loading branch information
1 parent
eea0ba4
commit 72d4359
Showing
13 changed files
with
145 additions
and
285 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
src/components/dashboard/sidebar/EnterpriseOffersSummaryCard.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Badge, Row, Col } from '@edx/paragon'; | ||
import dayjs from 'dayjs'; | ||
import { | ||
ENTERPRISE_OFFER_SUMMARY_CARD_TITLE, | ||
ENTERPRISE_OFFER_ACTIVE_BADGE_LABEL, | ||
ENTERPRISE_OFFER_ACTIVE_BADGE_VARIANT, | ||
} from './data/constants'; | ||
import SidebarCard from './SidebarCard'; | ||
|
||
function getOfferExpiringFirst(offers) { | ||
return offers | ||
.filter(offer => offer.isCurrent) | ||
.sort((a, b) => new Date(a.endDatetime) - new Date(b.endDatetime))[0]; | ||
} | ||
|
||
const EnterpriseOffersSummaryCard = ({ | ||
className, offers, searchCoursesCta, | ||
}) => { | ||
const offerExpiringFirst = getOfferExpiringFirst(offers); | ||
|
||
return ( | ||
<SidebarCard | ||
title={ | ||
( | ||
<div className="d-flex align-items-center justify-content-between"> | ||
<h3 className="m-0">{ENTERPRISE_OFFER_SUMMARY_CARD_TITLE}</h3> | ||
<Badge | ||
variant={ENTERPRISE_OFFER_ACTIVE_BADGE_VARIANT} | ||
className="ml-2" | ||
data-testid="enterprise-offer-status-badge" | ||
> | ||
{ENTERPRISE_OFFER_ACTIVE_BADGE_LABEL} | ||
</Badge> | ||
</div> | ||
) | ||
} | ||
cardClassNames={className} | ||
> | ||
<p data-testid="offer-summary-text"> | ||
Apply your organization's Learner Credit balance to enroll into courses with no out of pocket cost. | ||
</p> | ||
{offerExpiringFirst?.endDatetime && ( | ||
<p data-testid="offer-summary-end-date-text"> | ||
Available until <b>{dayjs(offerExpiringFirst.endDatetime).format('MMM D, YYYY')}</b> | ||
</p> | ||
)} | ||
{searchCoursesCta && ( | ||
<Row className="mt-3 d-flex justify-content-end"> | ||
<Col xl={12}>{searchCoursesCta}</Col> | ||
</Row> | ||
)} | ||
</SidebarCard> | ||
); | ||
}; | ||
|
||
EnterpriseOffersSummaryCard.propTypes = { | ||
offers: PropTypes.arrayOf(PropTypes.shape({ | ||
endDatetime: PropTypes.string, | ||
remainingBalanceForUser: PropTypes.number, | ||
})).isRequired, | ||
className: PropTypes.string, | ||
searchCoursesCta: PropTypes.node, | ||
}; | ||
|
||
EnterpriseOffersSummaryCard.defaultProps = { | ||
className: undefined, | ||
searchCoursesCta: undefined, | ||
}; | ||
|
||
export default EnterpriseOffersSummaryCard; |
62 changes: 0 additions & 62 deletions
62
src/components/dashboard/sidebar/LearnerCreditSummaryCard.jsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/components/dashboard/sidebar/tests/EnterpriseOffersSummaryCard.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import React from 'react'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import { screen, render } from '@testing-library/react'; | ||
|
||
import EnterpriseOffersSummaryCard from '../EnterpriseOffersSummaryCard'; | ||
import { ENTERPRISE_OFFER_SUMMARY_CARD_TITLE } from '../data/constants'; | ||
|
||
const mockEnterpriseOffer = { | ||
isCurrent: true, | ||
uuid: 'test-enterprise-offer-uuid', | ||
status: 'Open', | ||
enterpriseCatalogUuid: 'test-enterprise-catalog-uuid', | ||
startDatetime: '2022-06-01T00:00:00Z', | ||
endDatetime: '2023-06-01T00:00:00Z', | ||
maxDiscount: 5000, | ||
remainingBalance: 4500, | ||
remainingBalanceForUser: null, | ||
}; | ||
|
||
describe('<EnterpriseOffersSummaryCard />', () => { | ||
it('should render searchCoursesCta', () => { | ||
const cta = 'Search Courses'; | ||
render( | ||
<EnterpriseOffersSummaryCard | ||
offers={[mockEnterpriseOffer]} | ||
searchCoursesCta={ | ||
<button type="button">{cta}</button> | ||
} | ||
/>, | ||
); | ||
|
||
expect(screen.getByText(ENTERPRISE_OFFER_SUMMARY_CARD_TITLE)).toBeInTheDocument(); | ||
expect(screen.getByText(cta)).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render default summary text if remainingBalanceForUser is null', () => { | ||
render( | ||
<EnterpriseOffersSummaryCard | ||
offers={[mockEnterpriseOffer]} | ||
/>, | ||
); | ||
|
||
expect(screen.getByTestId('offer-summary-text')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render earliest, current offer end date, if applicable', () => { | ||
render( | ||
<EnterpriseOffersSummaryCard | ||
offers={[ | ||
{ | ||
...mockEnterpriseOffer, | ||
isCurrent: false, | ||
endDatetime: '2022-04-01T00:00:00Z', // earliest, non-current start date | ||
}, | ||
{ | ||
...mockEnterpriseOffer, | ||
endDatetime: '2023-12-01T00:00:00Z', // earliest, current start date | ||
}, | ||
]} | ||
/>, | ||
); | ||
expect(screen.getByTestId('offer-summary-end-date-text')).toBeInTheDocument(); | ||
expect(screen.getByText('Dec 1, 2023')).toBeInTheDocument(); | ||
}); | ||
}); |
42 changes: 0 additions & 42 deletions
42
src/components/dashboard/sidebar/tests/LearnerCreditSummaryCard.test.jsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.