Debian Codegraph @

addons/website_sale_slides/static/src/js/slides_course_join.js

raw
1 import CourseJoin from "@website_slides/js/slides_course_join";
2
3 const CourseJoinWidget = CourseJoin.courseJoinWidget;
4
5 CourseJoinWidget.include({
6 init: function (parent, options) {
7 this._super.apply(this, arguments);
8 this.productId = options.channel.productId || false;
9 },
10
11 //--------------------------------------------------------------------------
12 // Handlers
13 //--------------------------------------------------------------------------
14
15 /**
16 * When the user joins the course, if it's set as "on payment" and the user is logged in,
17 * we redirect to the shop page for this course.
18 *
19 * @param {MouseEvent} ev
20 * @override
21 * @private
22 */
23 _onClickJoin: function (ev) {
24 ev.preventDefault();
25
26 if (this.channel.channelEnroll === 'payment' && !this.publicUser) {
27 const self = this;
28 this.beforeJoin().then(function () {
29 self.call('cart', 'add',
30 {
31 // TODO VCR Ensure productTemplateId is always provided to `addToCart`.
32 // Currently, this works because the product configurator check is bypassed
33 // when the `isBuyNow` option is `True`.
34 productTemplateId: false,
35 productId: self.productId,
36 },
37 {
38 isBuyNow: true,
39 },
40 );
41 });
42 } else {
43 this._super.apply(this, arguments);
44 }
45 },
46 });
47
48 export default CourseJoinWidget;