feat: show existing UX for purchased program on program details (#32374)
This commit is contained in:
@@ -38,10 +38,6 @@ class ProgramDetailsView extends Backbone.View {
|
||||
} else {
|
||||
this.tpl = HtmlUtils.template(pageTpl);
|
||||
}
|
||||
this.options.isSubscriptionEligible = (
|
||||
this.options.isUserB2CSubscriptionsEnabled
|
||||
&& this.options.programData.subscription_eligible
|
||||
);
|
||||
this.programModel = new Backbone.Model(this.options.programData);
|
||||
this.courseData = new Backbone.Model(this.options.courseData);
|
||||
this.certificateCollection = new Backbone.Collection(
|
||||
@@ -66,6 +62,7 @@ class ProgramDetailsView extends Backbone.View {
|
||||
label: this.options.programData.title,
|
||||
program_uuid: this.options.programData.uuid,
|
||||
};
|
||||
this.options.isSubscriptionEligible = this.getIsSubscriptionEligible();
|
||||
|
||||
this.render();
|
||||
|
||||
@@ -190,6 +187,30 @@ class ProgramDetailsView extends Backbone.View {
|
||||
}).bind(this);
|
||||
}
|
||||
|
||||
getIsSubscriptionEligible() {
|
||||
const courseCollections = [
|
||||
this.completedCourseCollection,
|
||||
this.inProgressCourseCollection,
|
||||
];
|
||||
const isSomeCoursePurchasable = courseCollections.some((collection) => (
|
||||
collection.some((course) => (
|
||||
course.get('upgrade_url') &&
|
||||
!(course.get('expired') === true)
|
||||
))
|
||||
));
|
||||
const programPurchasedWithoutSubscription = (
|
||||
this.subscriptionModel.get('subscriptionState') !== 'active'
|
||||
&& !isSomeCoursePurchasable
|
||||
&& this.remainingCourseCollection.length === 0
|
||||
);
|
||||
|
||||
return (
|
||||
this.options.isUserB2CSubscriptionsEnabled
|
||||
&& this.options.programData.subscription_eligible
|
||||
&& !programPurchasedWithoutSubscription
|
||||
);
|
||||
}
|
||||
|
||||
getAlerts() {
|
||||
const alerts = {
|
||||
enrollmentAlerts: [],
|
||||
|
||||
Reference in New Issue
Block a user