Skip to content

fix: prioritize the redemption over request #1398

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

Merged
merged 1 commit into from
Jul 10, 2025

Conversation

ahmad-hassan-dev
Copy link
Contributor

@ahmad-hassan-dev ahmad-hassan-dev commented Jul 9, 2025

Description

Previously, the enrollment logic was hiding the "Enroll" button if a learner was eligible to request a subsidy, even when they also had a direct, redeemable subsidy (like a course assignment) available. This prevented learners from immediately enrolling in courses they already had access to.

This change adjusts the priority of the enrollment actions. The logic now checks for any applicable, redeemable subsidy before it checks for the ability to request one.

As a result, if a learner has any subsidy that allows for direct enrollment, the "Enroll" button will now be correctly displayed, taking precedence over the "Request" flow.

For all changes

  • Ensure adequate tests are in place (or reviewed existing tests cover changes)
  • Ensure English strings are marked for translation. See documentation for more details.

Only if submitting a visual change

  • Ensure to attach screenshots
  • Ensure to have UX team confirm screenshots

Copy link

codecov bot commented Jul 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.35%. Comparing base (9b33e37) to head (3b3ec33).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1398   +/-   ##
=======================================
  Coverage   90.35%   90.35%           
=======================================
  Files         419      419           
  Lines        9475     9475           
  Branches     2210     2210           
=======================================
  Hits         8561     8561           
  Misses        880      880           
  Partials       34       34           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines 91 to 114
if (userSubsidyApplicableToCourse) {
// If a user has a direct subsidy (i.e., an assignment), show the "Enroll" button.
// This takes priority over any "Request" functionality.
if (externalCourseEnrollmentUrl) {
return (
<ToExecutiveEducation2UEnrollment enrollmentUrl={externalCourseEnrollmentUrl} />
);
}
// User is not enrolled, but has a redeemable subsidy access policy applicable to the course.
return (
<Stack gap={2}>
<StatefulEnroll
contentKey={contentKey}
onClick={handleRedeemClick}
onSuccess={handleRedemptionSuccess}
onError={handleRedeemError}
options={{
trackSearchConversionEventName: EVENT_NAMES.sucessfulEnrollment,
}}
/>
<RedemptionStatusText redemptionStatus={redemptionStatus} />
</Stack>
);
}
Copy link
Member

Choose a reason for hiding this comment

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

Just one concern over giving priority to redemption over request, we need to verify what happens in case of Subscriptions B&R?

Copy link
Member

Choose a reason for hiding this comment

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

Also, what if we simply add this additional condition to the existing code:

Original:

if (userCanRequestSubsidyForCourse) {
    // User can request a subsidy for the course, but is not enrolled so
    // hide the "Enroll" CTA in favor of the "Request enrollment" CTA below
    // the course run cards.
    return null;
  }

Proposed:

if (userCanRequestSubsidyForCourse && !userSubsidyApplicableToCourse) {
    // User can request a subsidy for the course, and no existing subsidy is applicable to the course so
    // hide the "Enroll" CTA in favor of the "Request enrollment" CTA below
    // the course run cards.
    return null;
  }

@ahmad-hassan-dev ahmad-hassan-dev merged commit bc0ecec into master Jul 10, 2025
9 checks passed
@ahmad-hassan-dev ahmad-hassan-dev deleted the ahmad-hassan-dev/ENT-10643 branch July 10, 2025 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants