Skip to content

Commit

Permalink
fix: ensure multiple subs work properly when 1 has previously expired (
Browse files Browse the repository at this point in the history
  • Loading branch information
adamstankiewicz authored Jul 20, 2023
1 parent e1a4753 commit df27b82
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/components/course/data/tests/utils.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,6 @@ describe('getSubscriptionDisabledEnrollmentReasonType', () => {
},
],
};

const reasonType = getSubscriptionDisabledEnrollmentReasonType({
customerAgreementConfig,
catalogsWithCourse,
Expand Down
10 changes: 6 additions & 4 deletions src/components/course/data/utils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -679,12 +679,14 @@ export const getSubscriptionDisabledEnrollmentReasonType = ({
const subscriptionsApplicableToCourse = customerAgreementConfig?.subscriptions?.filter(
subscription => catalogsWithCourse.includes(subscription?.enterpriseCatalogUuid),
);
const hasExpiredSubscriptions = subscriptionsApplicableToCourse?.filter(
const hasApplicableSubscriptions = subscriptionsApplicableToCourse.length > 0;

const hasExpiredSubscriptions = hasApplicableSubscriptions && subscriptionsApplicableToCourse.every(
subscription => subscription.daysUntilExpirationIncludingRenewals < 0,
)?.length > 0;
const hasExhaustedSubscriptions = subscriptionsApplicableToCourse?.filter(
);
const hasExhaustedSubscriptions = hasApplicableSubscriptions && subscriptionsApplicableToCourse.every(
subscription => subscription?.licenses?.unassigned === 0,
)?.length > 0;
);
const applicableSubscriptionNonExpiredNonExhausted = subscriptionsApplicableToCourse?.find(
subscription => subscription.daysUntilExpirationIncludingRenewals >= 0 && subscription?.licenses?.unassigned > 0,
);
Expand Down

0 comments on commit df27b82

Please sign in to comment.