Skip to content

Commit d2031fd

Browse files
committed
♻️(course-runs): refactor self paced course availability presentation
- Changed self paced course availability presentation - Remove the entire run component if other runs list is empty
1 parent 8f73833 commit d2031fd

File tree

2 files changed

+39
-28
lines changed
  • src/frontend/js/widgets/SyllabusCourseRunsList/components

2 files changed

+39
-28
lines changed

src/frontend/js/widgets/SyllabusCourseRunsList/components/SyllabusAsideList/index.tsx

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -108,28 +108,20 @@ export const SyllabusAsideList = ({
108108

109109
const showLanguages = CourseRunHelper.IsAllCourseRunsWithSameLanguages(courseRuns);
110110

111+
// If there are no runs to display at all, don't render anything
112+
if (openedRuns.length <= 1 && otherRuns.length === 0) {
113+
return null;
114+
}
115+
111116
return (
112117
<>
113118
<h2 className="course-detail__title">
114-
{openedRuns.length === 1 ? (
115-
<FormattedMessage {...messages.otherCourseRuns} />
116-
) : (
119+
{openedRuns.length > 1 ? (
117120
<FormattedMessage {...messages.courseRunsTitle} />
121+
) : (
122+
<FormattedMessage {...messages.otherCourseRuns} />
118123
)}
119124
</h2>
120-
{openedRuns.length <= 1 && otherRuns.length === 0 && (
121-
<div className="course-detail__row course-detail__no-runs">
122-
{openedRuns.length === 0 ? (
123-
<p>
124-
<FormattedMessage {...messages.noCourseRuns} />
125-
</p>
126-
) : (
127-
<p>
128-
<FormattedMessage {...messages.noOtherCourseRuns} />
129-
</p>
130-
)}
131-
</div>
132-
)}
133125
{openedRuns.length > 1 && (
134126
<div
135127
id="courseDetailsRunsOpen"

src/frontend/js/widgets/SyllabusCourseRunsList/components/SyllabusCourseRunCompacted/index.tsx

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,18 @@ const messages = defineMessages({
3434
selfPaceRunPeriod: {
3535
id: 'components.SyllabusCourseRunCompacted.selfPaceCoursePeriod',
3636
description: 'Course date of an opened and self paced course run block',
37-
defaultMessage: 'Available until {endDate}',
37+
defaultMessage: 'Until {endDate, select, undefined {} other {{endDate}}}',
3838
},
3939
selfPaceNoEndDate: {
4040
id: 'components.SyllabusCourseRunCompacted.selfPaceNoEndDate',
4141
description: 'Self paced course run block with no end date',
4242
defaultMessage: 'Available',
4343
},
44+
enrollment: {
45+
id: 'components.SyllabusCourseRun.enrollment',
46+
description: 'Title of the enrollment dates section of an opened course run block',
47+
defaultMessage: 'Enrollment',
48+
},
4449
coursePrice: {
4550
id: 'components.SyllabusCourseRunCompacted.coursePrice',
4651
description: 'Title of the course enrollment price section of an opened course run block',
@@ -105,6 +110,7 @@ const OpenedSelfPacedCourseRun = ({
105110
let enrollmentDiscountedPrice = '';
106111
let certificatePrice = '';
107112
let certificateDiscountedPrice = '';
113+
const enrollmentEnd = courseRun.enrollment_end ? formatDate(courseRun.enrollment_end) : '...';
108114

109115
if (courseRun.offer) {
110116
const offer = courseRun.offer.toUpperCase().replaceAll(' ', '_');
@@ -157,19 +163,32 @@ const OpenedSelfPacedCourseRun = ({
157163
<>
158164
{courseRun.title && <h3>{StringHelper.capitalizeFirst(courseRun.title)}</h3>}
159165
<dl>
160-
{!showLanguages && (
161-
<dt>
162-
<FormattedMessage {...messages.course} />
163-
</dt>
164-
)}
165166
<dd>
166167
{hasEndDate ? (
167-
<FormattedMessage
168-
{...messages.selfPaceRunPeriod}
169-
values={{
170-
endDate: end,
171-
}}
172-
/>
168+
<>
169+
<dt>
170+
<FormattedMessage {...messages.enrollment} />
171+
</dt>
172+
<dd>
173+
<FormattedMessage
174+
{...messages.selfPaceRunPeriod}
175+
values={{
176+
endDate: enrollmentEnd,
177+
}}
178+
/>
179+
</dd>
180+
<dt>
181+
<FormattedMessage {...messages.course} />
182+
</dt>
183+
<dd>
184+
<FormattedMessage
185+
{...messages.selfPaceRunPeriod}
186+
values={{
187+
endDate: end,
188+
}}
189+
/>
190+
</dd>
191+
</>
173192
) : (
174193
<FormattedMessage {...messages.selfPaceNoEndDate} />
175194
)}

0 commit comments

Comments
 (0)