MCPcopy Index your code
hub / github.com/codecombat/codecombat / constructor

Method constructor

app/views/core/SubscribeModal.js:45–85  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

43 }
44
45 constructor (options) {
46 // if document.location.host is 'br.codecombat.com'
47 // document.location.href = 'http://codecombat.net.br/'
48
49 if (options == null) { options = {} }
50 super(options)
51 this.onPayPalPaymentStarted = this.onPayPalPaymentStarted.bind(this)
52 this.onPayPalPaymentComplete = this.onPayPalPaymentComplete.bind(this)
53 // Path check due to modal refresh when user isn't signed in.
54 this.hideMonthlySub = (options != null ? options.hideMonthlySub : undefined) || window.location.pathname.startsWith('/parents') || (me.get('country') === 'japan') || null
55 if (options != null ? options.forceShowMonthlySub : undefined) {
56 this.hideMonthlySub = false
57 }
58 this.state = 'standby'
59 this.couponID = utils.getQueryVariable('coupon')
60 this.subModalContinue = options.subModalContinue
61 if (options.products) {
62 // this is just to get the test demo to work
63 this.products = options.products
64 this.onLoaded()
65 } else {
66 this.products = new Products()
67 const data = {}
68
69 // Attempt to get the coupon associated with the user's country.
70 // If coupon doesn't exist nothing is returned.
71 if (this.couponID == null) { this.couponID = typeof me !== 'undefined' && me !== null ? me.get('country') : undefined }
72 if (this.couponID === 'brazil') {
73 // Edge case due to misconfigured brazil coupon in stripe that is immutable
74 this.couponID = 'brazil-annual'
75 }
76
77 if (this.couponID) {
78 data.coupon = this.couponID
79 }
80 this.supermodel.trackRequest(this.products.fetch({ data }))
81 }
82 this.trackTimeVisible({ trackViewLifecycle: true })
83 payPal.loadPayPal().then(() => this.render())
84 this.purchasingForId = options?.purchasingForId
85 }
86
87 onLoaded () {
88 this.basicProduct = this.products.getBasicSubscriptionForUser(me)

Callers

nothing calls this directly

Calls 4

onLoadedMethod · 0.95
renderMethod · 0.95
getMethod · 0.45
fetchMethod · 0.45

Tested by

no test coverage detected