Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent NotFoundPage on successful redemption while still on ExternalCourseEnrollment #1197

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/course/routes/ExternalCourseEnrollment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const ExternalCourseEnrollment = () => {
// current date is outside the enrollment window of the run.
if (userSubsidyApplicableToCourse.subsidyType === LEARNER_CREDIT_SUBSIDY_TYPE) {
const canRedeemDataCourseRun = redeemabilityPerContentKey.find(r => r.contentKey === courseRunKey);
if (!canRedeemDataCourseRun?.canRedeem) {
if (!canRedeemDataCourseRun?.canRedeem && !canRedeemDataCourseRun?.hasSuccessfulRedemption) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upon successful redemption of an Exec Ed course, the API calls to can-redeem, credits_available, and enterprise_course_enrollments are invalidated/re-fetched in parallel.

When the can-redeem API resolves first, it's response will update to have canRedeem: false and hasSuccessfulRedemption: true; however, this code path would handle this case as showing the <NotFoundPage /> component, which isn't correct.

Once the other API calls resolve, the user is navigated to the complete route for the enrollment confirmation screen as intended.

This fix ensures we don't show the <NotFoundPage /> while resolving the other API calls.

return <NotFoundPage />;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,21 @@ describe('ExternalCourseEnrollment', () => {
},
LEARNER_CREDIT_SUBSIDY_TYPE,
],
// The auto-selected subsidy type is learner credit, and the specific requested run is already redeemed.
[
{
contentKey: mockCourseRunKey,
hasSuccessfulRedemption: true,
canRedeem: false,
},
LEARNER_CREDIT_SUBSIDY_TYPE,
],
// The specific run is not redeemable via LC, but that's okay because we're not using learner credit anyway.
[
{
contentKey: mockCourseRunKey,
hasSuccessfulRedemption: false,
canRedeem: false, // Not redeemable!?
canRedeem: false, // Not redeemable
},
LICENSE_SUBSIDY_TYPE, // Auto-selected subsidy type is not learner credit anyway, so allow the page to render.
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const RegistrationSummaryCard = ({ priceDetails }) => (
</del>
</div>
<div className="d-flex justify-content-end mr-2.5">
${priceDetails?.price ? `${String(0).padStart(priceDetails.price.toString().length, '0') }.00` : '0.00'} {priceDetails?.currency ? priceDetails.currency : CURRENCY_USD}
{priceDetails?.price ? `$${numberWithPrecision(0)} ${priceDetails?.currency ? priceDetails.currency : CURRENCY_USD}` : '-'}
</div>
<div className="d-flex justify-content-end small font-weight-light text-gray-500 mr-2.5">
<FormattedMessage
Expand Down
Loading