diff --git a/frontend/public/src/components/CourseProductDetailEnroll.js b/frontend/public/src/components/CourseProductDetailEnroll.js index e5b906d661..f719d0b656 100644 --- a/frontend/public/src/components/CourseProductDetailEnroll.js +++ b/frontend/public/src/components/CourseProductDetailEnroll.js @@ -32,7 +32,6 @@ import moment from "moment-timezone" import { getFirstRelevantRun, isRunArchived, - isEnrollmentFuture, isFinancialAssistanceAvailable } from "../lib/courseApi" import { getCookie } from "../lib/api" @@ -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 ? ( @@ -195,13 +198,12 @@ export class CourseProductDetailEnroll extends React.Component< - {courseRuns && - courseRuns.map((elem: EnrollmentFlaggedCourseRun) => ( + {enrollableCourseRuns && + enrollableCourseRuns.map((elem: EnrollmentFlaggedCourseRun) => ( ))} diff --git a/frontend/public/src/components/CourseProductDetailEnroll_test.js b/frontend/public/src/components/CourseProductDetailEnroll_test.js index f2ffde20f3..831d4c4f7a 100644 --- a/frontend/public/src/components/CourseProductDetailEnroll_test.js +++ b/frontend/public/src/components/CourseProductDetailEnroll_test.js @@ -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) diff --git a/frontend/public/src/lib/courseApi.js b/frontend/public/src/lib/courseApi.js index dbcdc26b42..f67284c408 100644 --- a/frontend/public/src/lib/courseApi.js +++ b/frontend/public/src/lib/courseApi.js @@ -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) {