Skip to content

Commit

Permalink
Fix start date test on course info card (#1932)
Browse files Browse the repository at this point in the history
  • Loading branch information
annagav authored Sep 29, 2023
1 parent e4f7956 commit 806a310
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions frontend/public/src/components/CourseInfoBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ type CourseInfoBoxProps = {
}

const getStartDateText = (run: BaseCourseRun, isArchived: boolean = false) => {
if (isArchived) {
return "Course content available anytime"
}
return run && !emptyOrNil(run.start_date) && !run.is_self_paced
? formatPrettyDate(moment(new Date(run.start_date)))
: isArchived
? "Course content available anytime"
: "Start Anytime"
? (run.start_date > moment() ? "Starts: " : "Started: ") +
formatPrettyDate(moment(new Date(run.start_date)))
: "Start Anytime"
}

export default class CourseInfoBox extends React.PureComponent<CourseInfoBoxProps> {
Expand Down Expand Up @@ -120,7 +122,6 @@ export default class CourseInfoBox extends React.PureComponent<CourseInfoBoxProp
}
})
}
const startedText = run.start_date > moment() ? "Starts: " : "Started: "
return (
<>
<div className="enrollment-info-box componentized">
Expand All @@ -141,21 +142,20 @@ export default class CourseInfoBox extends React.PureComponent<CourseInfoBoxProp
/>
</div>
<div className="enrollment-info-text">
{startedText}
{getStartDateText(run, isArchived)}
</div>
<button
className="more-enrollment-info"
onClick={() => this.toggleShowMoreEnrollDates()}
>
{moreEnrollableCourseRuns
? this.state.showMoreEnrollDates
? "Show Less"
: "More Dates"
: null}
</button>
{this.state.showMoreEnrollDates ? (
<ul className="more-dates-enrollment-list">{startDates}</ul>
{!isArchived && moreEnrollableCourseRuns ? (
<>
<button
className="more-enrollment-info"
onClick={() => this.toggleShowMoreEnrollDates()}
>
{this.state.showMoreEnrollDates ? "Show Less" : "More Dates"}
</button>
{this.state.showMoreEnrollDates ? (
<ul className="more-dates-enrollment-list">{startDates}</ul>
) : null}
</>
) : null}
</div>
{course && course.page ? (
Expand Down

0 comments on commit 806a310

Please sign in to comment.