Skip to content

Commit

Permalink
Show only enrollable runs in the enrollment dialog (#2305)
Browse files Browse the repository at this point in the history
  • Loading branch information
annagav authored Jul 23, 2024
1 parent 050c0a6 commit 69912d6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
12 changes: 7 additions & 5 deletions frontend/public/src/components/CourseProductDetailEnroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import moment from "moment-timezone"
import {
getFirstRelevantRun,
isRunArchived,
isEnrollmentFuture,
isFinancialAssistanceAvailable
} from "../lib/courseApi"
import { getCookie } from "../lib/api"
Expand Down Expand Up @@ -178,7 +177,11 @@ export class CourseProductDetailEnroll extends React.Component<

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

const enrollableCourseRuns = courseRuns ?
courseRuns.filter(
(run: EnrollmentFlaggedCourseRun) => run.is_enrollable
) :
[]
return (
<>
{courseRuns && courseRuns.length > 1 ? (
Expand All @@ -195,13 +198,12 @@ export class CourseProductDetailEnroll extends React.Component<
<option value="default" key="default-select">
Please Select
</option>
{courseRuns &&
courseRuns.map((elem: EnrollmentFlaggedCourseRun) => (
{enrollableCourseRuns &&
enrollableCourseRuns.map((elem: EnrollmentFlaggedCourseRun) => (
<option value={elem.id} key={`courserun-selection-${elem.id}`}>
{formatPrettyDate(moment(new Date(elem.start_date)))} -{" "}
{formatPrettyDate(moment(new Date(elem.end_date)))}{" "}
{elem.is_upgradable ? "" : "(no certificate available)"}
{isEnrollmentFuture(elem) ? "(enrollment opens soon)" : ""}
</option>
))}
</select>
Expand Down
11 changes: 0 additions & 11 deletions frontend/public/src/components/CourseProductDetailEnroll_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -537,17 +537,6 @@ describe("CourseProductDetailEnrollShallowRender", () => {
it(`${showsQualifier} the course run selector for a course with ${runsQualifier} active run${
multiples ? "s" : ""
} and enables enroll buttons on selection`, async () => {
// courseRun["products"] = [
// {
// id: 1,
// price: 10,
// is_upgradable: true,
// product_flexible_price: {
// amount: 10,
// discount_type: DISCOUNT_TYPE_PERCENT_OFF
// }
// }
// ]
const courseRuns = [courseRun]
if (multiples) {
courseRuns.push(courseRun)
Expand Down
5 changes: 0 additions & 5 deletions frontend/public/src/lib/courseApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ export const isLinkableCourseRun = (
return notNil(run.start_date) && moment(run.start_date).isBefore(now)
}

export const isEnrollmentFuture = (run: CourseRunDetail): boolean => {
const enrollStart = run.enrollment_start ? moment(run.enrollment_start) : null
return !!enrollStart && moment().isBefore(enrollStart)
}

export const courseRunStatusMessage = (run: CourseRun) => {
const startDateDescription = generateStartDateText(run)
if (startDateDescription !== null) {
Expand Down

0 comments on commit 69912d6

Please sign in to comment.