-
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.
feat: subsidy box points to learner credit (#810)
- Loading branch information
1 parent
6fc25f0
commit 3637bed
Showing
13 changed files
with
285 additions
and
145 deletions.
There are no files selected for viewing
72 changes: 0 additions & 72 deletions
72
src/components/dashboard/sidebar/EnterpriseOffersSummaryCard.jsx
This file was deleted.
Oops, something went wrong.
62 changes: 62 additions & 0 deletions
62
src/components/dashboard/sidebar/LearnerCreditSummaryCard.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,62 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Badge, Row, Col } from '@edx/paragon'; | ||
import dayjs from 'dayjs'; | ||
import { | ||
LEARNER_CREDIT_SUMMARY_CARD_TITLE, | ||
LEARNER_CREDIT_ACTIVE_BADGE_LABEL, | ||
LEARNER_CREDIT_ACTIVE_BADGE_VARIANT, | ||
LEARNER_CREDIT_CARD_SUMMARY, | ||
} from './data/constants'; | ||
import SidebarCard from './SidebarCard'; | ||
|
||
const LearnerCreditSummaryCard = ({ | ||
className, expirationDate, searchCoursesCta, | ||
}) => ( | ||
<SidebarCard | ||
title={ | ||
( | ||
<div className="d-flex align-items-center justify-content-between"> | ||
<h3 className="m-0">{LEARNER_CREDIT_SUMMARY_CARD_TITLE}</h3> | ||
<Badge | ||
variant={LEARNER_CREDIT_ACTIVE_BADGE_VARIANT} | ||
className="ml-2" | ||
data-testid="learner-credit-status-badge" | ||
> | ||
{LEARNER_CREDIT_ACTIVE_BADGE_LABEL} | ||
</Badge> | ||
</div> | ||
) | ||
} | ||
cardClassNames={className} | ||
> | ||
<p data-testid="learner-credit-summary-text"> | ||
{ LEARNER_CREDIT_CARD_SUMMARY } | ||
</p> | ||
|
||
{expirationDate && ( | ||
<p data-testid="learner-credit-summary-end-date-text"> | ||
Available until <b>{dayjs(expirationDate).format('MMM D, YYYY')}</b> | ||
</p> | ||
)} | ||
|
||
{searchCoursesCta && ( | ||
<Row className="mt-3 d-flex justify-content-end"> | ||
<Col xl={12}>{searchCoursesCta}</Col> | ||
</Row> | ||
)} | ||
</SidebarCard> | ||
); | ||
|
||
LearnerCreditSummaryCard.propTypes = { | ||
expirationDate: PropTypes.string.isRequired, | ||
className: PropTypes.string, | ||
searchCoursesCta: PropTypes.node, | ||
}; | ||
|
||
LearnerCreditSummaryCard.defaultProps = { | ||
className: undefined, | ||
searchCoursesCta: undefined, | ||
}; | ||
|
||
export default LearnerCreditSummaryCard; |
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: 0 additions & 65 deletions
65
src/components/dashboard/sidebar/tests/EnterpriseOffersSummaryCard.test.jsx
This file was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
src/components/dashboard/sidebar/tests/LearnerCreditSummaryCard.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,42 @@ | ||
import React from 'react'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import { screen, render } from '@testing-library/react'; | ||
import LearnerCreditSummaryCard from '../LearnerCreditSummaryCard'; | ||
import { LEARNER_CREDIT_SUMMARY_CARD_TITLE } from '../data/constants'; | ||
|
||
const TEST_EXPIRATION_DATE = '2022-06-01T00:00:00Z'; | ||
|
||
describe('<LearnerCreditSummaryCard />', () => { | ||
it('should render searchCoursesCta', () => { | ||
const cta = 'Search Courses'; | ||
render( | ||
<LearnerCreditSummaryCard | ||
expirationDate={TEST_EXPIRATION_DATE} | ||
searchCoursesCta={ | ||
<button type="button">{cta}</button> | ||
} | ||
/>, | ||
); | ||
expect(screen.getByText(LEARNER_CREDIT_SUMMARY_CARD_TITLE)).toBeInTheDocument(); | ||
expect(screen.getByText(cta)).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render default summary text', () => { | ||
render( | ||
<LearnerCreditSummaryCard | ||
expirationDate={TEST_EXPIRATION_DATE} | ||
/>, | ||
); | ||
expect(screen.getByTestId('learner-credit-summary-text')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render the expiration date passed as prop', () => { | ||
render( | ||
<LearnerCreditSummaryCard | ||
expirationDate={TEST_EXPIRATION_DATE} | ||
/>, | ||
); | ||
expect(screen.getByTestId('learner-credit-summary-end-date-text')).toBeInTheDocument(); | ||
expect(screen.getByText('2022', { exact: false })).toBeInTheDocument(); | ||
}); | ||
}); |
Oops, something went wrong.