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: update redirect logic to take into account available coupon codes #906

Merged
merged 4 commits into from
Dec 14, 2023

Conversation

brobro10000
Copy link
Member

Updates my favorite function, isDisableCourseSearch, to take into account existing coupon codes before redirecting. If there exists an available coupon code, then we will not redirect away from the course about page.

We also refactor the isDisableCourseSearch to return out of the function as false (can view the course page) in the following order.

  • If a nonAssignablePolicyType exist where a nonAssignablePolicyType is not 'AssignedLearnerCreditAccessPolicy'
  • If a user hasActiveSubPlan where a subscription plan is active AND the subscription license status is 'activated'
  • If a user hasCouponCodes where a coupon code is available (active defined as the current date/time falls between a coupon start/end date)
  • If a user does NOT have a allocatedOrAcceptedAssignment where an assignment state is either 'accepted' OR 'allocated'

A user is redirected away from the course about page if either of the following conditions are true

  • There exist an activeOffer where an active offer is defined as a current offer
  • There exist an allocatedOrAcceptedAssignment where an assignment assignment state is either 'accepted' OR 'allocated'

For all changes

  • Ensure adequate tests are in place (or reviewed existing tests cover changes)

Only if submitting a visual change

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

Copy link

codecov bot commented Dec 14, 2023

Codecov Report

Attention: 143 lines in your changes are missing coverage. Please review.

Comparison is base (d36b78a) 84.87% compared to head (b30f6a0) 84.96%.
Report is 107 commits behind head on master.

Files Patch % Lines
src/components/search/Search.jsx 0.00% 29 Missing ⚠️
...ntent/course-enrollments/CourseAssignmentAlert.jsx 27.27% 8 Missing ⚠️
src/components/course/data/hooks.jsx 88.70% 7 Missing ⚠️
...course-enrollments/course-cards/BaseCourseCard.jsx 89.85% 7 Missing ⚠️
src/components/my-career/VisualizeCareer.jsx 74.07% 6 Missing and 1 partial ⚠️
src/components/my-career/data/service.js 56.25% 7 Missing ⚠️
src/components/course/data/utils.jsx 95.89% 6 Missing ⚠️
src/components/my-career/AddJobRole.jsx 60.00% 5 Missing and 1 partial ⚠️
src/components/my-career/data/hooks.jsx 50.00% 6 Missing ⚠️
...rc/components/search/AssignmentsOnlyEmptyState.jsx 0.00% 6 Missing ⚠️
... and 28 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #906      +/-   ##
==========================================
+ Coverage   84.87%   84.96%   +0.09%     
==========================================
  Files         320      338      +18     
  Lines        6399     7091     +692     
  Branches     1552     1734     +182     
==========================================
+ Hits         5431     6025     +594     
- Misses        941     1035      +94     
- Partials       27       31       +4     

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

Comment on lines +152 to 154
if (allocatedOrAcceptedAssignments?.length === 0) {
return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this check redundant considering the next line already checks allocatedOrAcceptedAssignments?.length > 0 ? Perhaps the last line of this function can be simplified to just return activeOffers?.length > 0;?

@brobro10000 brobro10000 merged commit 12b1c2c into master Dec 14, 2023
6 checks passed
@brobro10000 brobro10000 deleted the hu/ent-that-darn-function-1 branch December 14, 2023 21:51
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.

5 participants