diff --git a/frontend/public/src/components/CourseInfoBox.js b/frontend/public/src/components/CourseInfoBox.js index eeb07e0e5..75c9568bf 100644 --- a/frontend/public/src/components/CourseInfoBox.js +++ b/frontend/public/src/components/CourseInfoBox.js @@ -9,10 +9,7 @@ import moment from "moment-timezone" import type { BaseCourseRun } from "../flow/courseTypes" import { EnrollmentFlaggedCourseRun, RunEnrollment } from "../flow/courseTypes" -import { getCookie } from "../lib/api" -import { isWithinEnrollmentPeriod } from "../lib/courseApi" import type { CurrentUser } from "../flow/authTypes" -import { routes } from "../lib/urls" type CourseInfoBoxProps = { courses: Array, @@ -53,50 +50,11 @@ export default class CourseInfoBox extends React.PureComponent 0 && run.products[0] - - return currentUser && currentUser.id ? ( - run && isWithinEnrollmentPeriod(run) ? ( - <> - {product && run.is_upgradable ? ( - - ) : ( -
- - - -
- )} - - ) : null - ) : ( - this.renderEnrollLoginDateLink(run) - ) - } - renderEnrollLoginDateLink(run: EnrollmentFlaggedCourseRun) { + renderUnenrolledDateLink(run: EnrollmentFlaggedCourseRun) { const { currentUser } = this.props return !currentUser || !currentUser.id ? ( - <> - - {getStartDateForRun(run)} - - + <>{getStartDateForRun(run)} ) : null } renderEnrolledDateLink(run: EnrollmentFlaggedCourseRun) { @@ -133,12 +91,13 @@ export default class CourseInfoBox extends React.PureComponent {courseRun.is_enrolled || - enrollments.find( - (enrollment: RunEnrollment) => - enrollment.run.id === courseRun.id - ) + (enrollments && + enrollments.find( + (enrollment: RunEnrollment) => + enrollment.run.id === courseRun.id + )) ? this.renderEnrolledDateLink(courseRun) - : this.renderEnrollNowDateLink(courseRun)} + : this.renderUnenrolledDateLink(courseRun)} ) }