Skip to content

Commit

Permalink
feat: enabled the usage of resumeCourseRunUrl (#875)
Browse files Browse the repository at this point in the history
  • Loading branch information
mahamakifdar19 authored Nov 30, 2023
1 parent 3f285f0 commit b434492
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const CompletedCourseCard = (props) => {
startDate,
endDate,
mode,
resumeCourseRunUrl,
} = props;
const config = getConfig();

Expand All @@ -34,6 +35,7 @@ const CompletedCourseCard = (props) => {
courseRunId={courseRunId}
mode={mode}
startDate={startDate}
resumeCourseRunUrl={resumeCourseRunUrl}
/>
);
};
Expand Down Expand Up @@ -86,13 +88,15 @@ CompletedCourseCard.propTypes = {
endDate: PropTypes.string,
startDate: PropTypes.string,
mode: PropTypes.string,
resumeCourseRunUrl: PropTypes.string,
};

CompletedCourseCard.defaultProps = {
linkToCertificate: null,
endDate: null,
startDate: null,
mode: null,
resumeCourseRunUrl: null,
};

export default CompletedCourseCard;
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const ContinueLearningButton = ({
courseRunId,
startDate,
mode,
resumeCourseRunUrl,
}) => {
const { enterpriseConfig } = useContext(AppContext);

Expand All @@ -43,7 +44,10 @@ const ContinueLearningButton = ({
const variant = isExecutiveEducation2UCourse ? 'inverse-primary' : 'outline-primary';

const renderContent = () => {
if (!isCourseStarted() && startDate) {
// resumeCourseRunUrl indicates that learner has made progress, available only if the learner has started learning.
// The "Start Course" is visible either when the course has not started or when the course has started but the
// learner has not yet begun the learning.
if ((!isCourseStarted() && startDate) || (isCourseStarted && !resumeCourseRunUrl)) {
return 'Start course';
}
return 'Resume';
Expand All @@ -67,6 +71,7 @@ ContinueLearningButton.defaultProps = {
className: null,
startDate: null,
mode: null,
resumeCourseRunUrl: null,
};

ContinueLearningButton.propTypes = {
Expand All @@ -76,6 +81,7 @@ ContinueLearningButton.propTypes = {
courseRunId: PropTypes.string.isRequired,
startDate: PropTypes.string,
mode: PropTypes.string,
resumeCourseRunUrl: PropTypes.string,
};

export default ContinueLearningButton;
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const InProgressCourseCard = ({
courseRunStatus,
startDate,
mode,
resumeCourseRunUrl,
...rest
}) => {
const {
Expand Down Expand Up @@ -49,6 +50,7 @@ export const InProgressCourseCard = ({
courseRunId={courseRunId}
mode={mode}
startDate={startDate}
resumeCourseRunUrl={resumeCourseRunUrl}
/>
{shouldShowUpgradeButton && <UpgradeCourseButton className="ml-1" title={title} />}
</>
Expand Down Expand Up @@ -185,11 +187,13 @@ InProgressCourseCard.propTypes = {
courseRunStatus: PropTypes.string.isRequired,
startDate: PropTypes.string,
mode: PropTypes.string,
resumeCourseRunUrl: PropTypes.string,
};

InProgressCourseCard.defaultProps = {
startDate: null,
mode: null,
resumeCourseRunUrl: null,
};

export default InProgressCourseCard;
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const SavedForLaterCourseCard = (props) => {
isRevoked,
startDate,
mode,
resumeCourseRunUrl,
} = props;
const {
updateCourseEnrollmentStatus,
Expand Down Expand Up @@ -104,6 +105,7 @@ const SavedForLaterCourseCard = (props) => {
courseRunId={courseRunId}
mode={mode}
startDate={startDate}
resumeCourseRunUrl={resumeCourseRunUrl}
/>
);
};
Expand Down Expand Up @@ -140,13 +142,15 @@ SavedForLaterCourseCard.propTypes = {
endDate: PropTypes.string,
startDate: PropTypes.string,
mode: PropTypes.string,
resumeCourseRunUrl: PropTypes.string,
};

SavedForLaterCourseCard.defaultProps = {
linkToCertificate: null,
endDate: null,
startDate: null,
mode: null,
resumeCourseRunUrl: null,
};

export default SavedForLaterCourseCard;
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('transformCourseEnrollment', () => {
isRevoked: originalCourseEnrollment.isRevoked,
notifications: originalCourseEnrollment.dueDates,
canUnenroll: false,
resumeCourseRunUrl: 'http://www.resumecourserun.com',
};
expect(transformCourseEnrollment(originalCourseEnrollment)).toEqual(transformedCourseEnrollment);
});
Expand Down Expand Up @@ -52,6 +53,7 @@ describe('transformCourseEnrollment', () => {
isRevoked: originalCourseEnrollment.isRevoked,
notifications: originalCourseEnrollment.dueDates,
canUnenroll,
resumeCourseRunUrl: 'http://www.resumecourserun.com',
};
expect(transformCourseEnrollment(originalCourseEnrollment)).toEqual(transformedCourseEnrollment);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export const transformCourseEnrollment = (rawCourseEnrollment) => {
// Delete renamed/unused fields
delete courseEnrollment.displayName;
delete courseEnrollment.micromastersTitle;
delete courseEnrollment.resumeCourseRunUrl;
delete courseEnrollment.courseRunUrl;
delete courseEnrollment.certificateDownloadUrl;
delete courseEnrollment.emailsEnabled;
Expand Down

0 comments on commit b434492

Please sign in to comment.