Skip to content

Commit

Permalink
Instead of grabbing the first courserun off the list, grab the first …
Browse files Browse the repository at this point in the history
…enrollable one instead
  • Loading branch information
jkachel committed Jan 4, 2024
1 parent 21f27d4 commit 59db8bb
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion frontend/public/src/components/CourseProductDetailEnroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,26 @@ export class CourseProductDetailEnroll extends React.Component<
destinationUrl: ""
}

resolveFirstEnrollableRun() {
const { courseRuns } = this.props

const enrollableRun = courseRuns.find((run: EnrollmentFlaggedCourseRun) => {
return (
(run.enrollment_start === null ||
moment(run.enrollment_start).isBefore(moment.now())) &&
(run.enrollment_end === null ||
moment(run.enrollment_end).isAfter(moment.now()))
)
})

return enrollableRun
}

resolveCurrentRun() {
const { courseRuns } = this.props

return !this.getCurrentCourseRun() && courseRuns
? courseRuns[0]
? this.resolveFirstEnrollableRun()
: this.getCurrentCourseRun()
}

Expand Down

0 comments on commit 59db8bb

Please sign in to comment.