MCPcopy Create free account
hub / github.com/codecombat/codecombat / onClickRedeemCodeButton

Method onClickRedeemCodeButton

app/views/account/PrepaidView.js:176–199  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

174 }
175
176 onClickRedeemCodeButton (e) {
177 this.ppc = $('.input-ppc').val()
178 const options = {
179 url: '/db/subscription/-/subscribe_prepaid',
180 method: 'POST',
181 data: { ppc: this.dashedPPC() }
182 }
183 options.error = (model, res, options, foo) => {
184 let msg = model.responseText != null ? model.responseText : ''
185 if (model.status === 403) {
186 if (model.responseJSON.message === 'Activation Code has been used') {
187 msg = $.i18n.t('account_prepaid.activation_code_used')
188 }
189 }
190 return this.statusMessage($.i18n.t('account_prepaid.redeem_code_error') + msg, 'error')
191 }
192 options.success = (model, res, options) => {
193 this.statusMessage($.i18n.t('account_prepaid.prepaid_applied_success'), 'success')
194 this.codes.fetch({ cache: false })
195 me.fetch({ cache: false })
196 return this.loadPrepaid(this.dashedPPC())
197 }
198 return this.supermodel.addRequestResource('subscribe_prepaid', options, 0).load()
199 }
200
201 destroy () {
202 super.destroy()

Callers

nothing calls this directly

Calls 5

dashedPPCMethod · 0.95
statusMessageMethod · 0.95
loadPrepaidMethod · 0.95
fetchMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected