diff --git a/src/components/catalogCourseInfoModal/CatalogCourseInfoModal.jsx b/src/components/catalogCourseInfoModal/CatalogCourseInfoModal.jsx
index 3d29dacc..41e53459 100644
--- a/src/components/catalogCourseInfoModal/CatalogCourseInfoModal.jsx
+++ b/src/components/catalogCourseInfoModal/CatalogCourseInfoModal.jsx
@@ -14,6 +14,12 @@ import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { Launch } from '@edx/paragon/icons';
import messages from './CatalogCourseInfoModal.messages';
+function formatDate(start, end) {
+ const startDate = (new Date(start)).toLocaleDateString();
+ const endDate = (new Date(end)).toLocaleDateString();
+ return `${startDate} - ${endDate}`;
+}
+
const CatalogCourseInfoModal = ({
intl,
isOpen,
@@ -26,7 +32,10 @@ const CatalogCourseInfoModal = ({
partnerLogoImageUrl,
bannerImageUrl,
marketingUrl,
+ startDate,
+ endDate,
}) => (
+
<>
-
-
-
-
-
-
+
+
+
+
-
-
- {courseTitle}
-
-
- {courseProvider}
-
-
-
-
- {intl.formatMessage(messages['catalogCourseInfoModal.pricingTitle'])}
+
+
+ {courseTitle}
-
- {coursePrice}
+
+ {courseProvider}
-
-
-
-
-
- {intl.formatMessage(messages['catalogCourseInfoModal.associatedCatalogsTitle'])}
-
-
- {intl.formatMessage(messages['catalogCourseInfoModal.aLaCarteBadge'])}
-
- { courseAssociatedCatalogs.includes(process.env.EDX_FOR_BUSINESS_TITLE) && (
-
- {intl.formatMessage(messages['catalogCourseInfoModal.businessBadge'])}
-
- )}
- { courseAssociatedCatalogs.includes(process.env.EDX_FOR_ONLINE_EDU_TITLE) && (
-
- {intl.formatMessage(messages['catalogCourseInfoModal.educationBadge'])}
+
+
+ {intl.formatMessage(messages['catalogCourseInfoModal.pricingTitle'])}
+
+
+ {coursePrice}
+
+
+
+
+
+ {intl.formatMessage(messages['catalogCourseInfoModal.associatedCatalogsTitle'])}
+
+
+ {intl.formatMessage(messages['catalogCourseInfoModal.aLaCarteBadge'])}
- )}
+ { courseAssociatedCatalogs.includes(process.env.EDX_FOR_BUSINESS_TITLE) && (
+
+ {intl.formatMessage(messages['catalogCourseInfoModal.businessBadge'])}
+
+ )}
+ { courseAssociatedCatalogs.includes(process.env.EDX_FOR_ONLINE_EDU_TITLE) && (
+
+ {intl.formatMessage(messages['catalogCourseInfoModal.educationBadge'])}
+
+ )}
+
+
+ {intl.formatMessage(messages['catalogCourseInfoModal.courseDescriptionTitle'])}
+
+
+ {intl.formatMessage(messages['catalogCourseInfoModal.availabilityMessage'])}
+ {formatDate(startDate, endDate)}
+
+ {/* eslint-disable-next-line react/no-danger */}
+
-
- {intl.formatMessage(messages['catalogCourseInfoModal.courseDescriptionTitle'])}
-
- {/* eslint-disable-next-line react/no-danger */}
-
@@ -124,6 +134,8 @@ CatalogCourseInfoModal.defaultProps = {
partnerLogoImageUrl: '',
bannerImageUrl: '',
marketingUrl: '',
+ startDate: '',
+ endDate: '',
onClose: () => {},
};
@@ -139,6 +151,8 @@ CatalogCourseInfoModal.propTypes = {
partnerLogoImageUrl: PropTypes.string,
bannerImageUrl: PropTypes.string,
marketingUrl: PropTypes.string,
+ startDate: PropTypes.string,
+ endDate: PropTypes.string,
};
export default injectIntl(CatalogCourseInfoModal);
diff --git a/src/components/catalogCourseInfoModal/CatalogCourseInfoModal.messages.js b/src/components/catalogCourseInfoModal/CatalogCourseInfoModal.messages.js
index f3e20894..37ff1234 100644
--- a/src/components/catalogCourseInfoModal/CatalogCourseInfoModal.messages.js
+++ b/src/components/catalogCourseInfoModal/CatalogCourseInfoModal.messages.js
@@ -26,6 +26,11 @@ const messages = defineMessages({
defaultMessage: 'A la carte course price',
description: 'Title text for the course pricing display.',
},
+ 'catalogCourseInfoModal.availabilityMessage': {
+ id: 'catalogCourseInfoModal.availabilityMessage',
+ defaultMessage: 'Availability period: ',
+ description: 'Start and end dates for course term.',
+ },
'catalogCourseInfoModal.moreInfoButton': {
id: 'catalogCourseInfoModal.moreInfoButton',
defaultMessage: 'View course details',
diff --git a/src/components/catalogCourseInfoModal/CatalogCourseInfoModal.test.jsx b/src/components/catalogCourseInfoModal/CatalogCourseInfoModal.test.jsx
index f76e9f49..c939bf9a 100644
--- a/src/components/catalogCourseInfoModal/CatalogCourseInfoModal.test.jsx
+++ b/src/components/catalogCourseInfoModal/CatalogCourseInfoModal.test.jsx
@@ -17,6 +17,8 @@ const defaultProps = {
courseDescription: descriptionHtml,
partnerLogoImageUrl: '',
bannerImageUrl: '',
+ startDate: '2021-09-15T16:00:00Z',
+ endDate: '2022-04-06T16:00:00Z',
intl: {
formatMessage: (header) => header.defaultMessage,
formatDate: () => {},
@@ -49,6 +51,15 @@ describe('Course info modal works as expected', () => {
expect(screen.queryByText(descriptionText)).toBeInTheDocument();
});
+ test('test dates format correctly', () => {
+ render(
+
+
+ ,
+ );
+ expect(screen.getByText('Availability period: 9/15/2021 - 4/6/2022')).toBeInTheDocument();
+ });
+
test('modal is hidden when expected', () => {
const defaultPropsCopy = {};
Object.assign(defaultPropsCopy, defaultProps);
diff --git a/src/components/catalogSearchResults/CatalogSearchResults.jsx b/src/components/catalogSearchResults/CatalogSearchResults.jsx
index f900f856..d657e6fc 100644
--- a/src/components/catalogSearchResults/CatalogSearchResults.jsx
+++ b/src/components/catalogSearchResults/CatalogSearchResults.jsx
@@ -94,6 +94,8 @@ export const BaseCatalogSearchResults = ({
const [bannerImageUrl, setBannerImageUrl] = useState();
const [associatedCatalogs, setAssociatedCatalogs] = useState();
const [marketingUrl, setMarketingUrl] = useState();
+ const [startDate, setStartDate] = useState();
+ const [endDate, setEndDate] = useState();
const rowClicked = (row) => {
const rowPrice = row.original.first_enrollable_paid_seat_price;
@@ -108,6 +110,8 @@ export const BaseCatalogSearchResults = ({
setDescription(row.original.full_description);
setBannerImageUrl(row.original.original_image_url);
setMarketingUrl(row.original.marketing_url);
+ setStartDate(row.original.advertised_course_run.start);
+ setEndDate(row.original.advertised_course_run.end);
open();
};
@@ -171,6 +175,8 @@ export const BaseCatalogSearchResults = ({
bannerImageUrl={bannerImageUrl}
courseAssociatedCatalogs={associatedCatalogs}
marketingUrl={marketingUrl}
+ startDate={startDate}
+ endDate={endDate}
/>