codecombat/app/views/core/CreateAccountModal/CoppaDenyView.coffee

34 lines
1.1 KiB
CoffeeScript
Raw Normal View History

2016-06-30 18:32:58 -04:00
CocoView = require 'views/core/CocoView'
2016-06-07 17:51:41 -04:00
State = require 'models/State'
template = require 'templates/core/create-account-modal/coppa-deny-view'
forms = require 'core/forms'
2016-06-30 18:32:58 -04:00
contact = require 'core/contact'
2016-06-07 17:51:41 -04:00
2016-06-30 18:32:58 -04:00
module.exports = class CoppaDenyView extends CocoView
2016-06-07 17:51:41 -04:00
id: 'coppa-deny-view'
template: template
events:
'click .send-parent-email-button': 'onClickSendParentEmailButton'
2016-06-30 18:32:58 -04:00
'change input[name="parentEmail"]': 'onChangeParentEmail'
'click .back-btn': 'onClickBackButton'
initialize: ({ @signupState } = {}) ->
2016-06-07 17:51:41 -04:00
@state = new State({ parentEmail: '' })
2016-06-30 18:32:58 -04:00
@listenTo @state, 'all', _.debounce(@render)
2016-06-07 17:51:41 -04:00
2016-06-30 18:32:58 -04:00
onChangeParentEmail: (e) ->
2016-06-07 17:51:41 -04:00
@state.set { parentEmail: $(e.currentTarget).val() }, { silent: true }
onClickSendParentEmailButton: (e) ->
e.preventDefault()
@state.set({ parentEmailSending: true })
2016-06-30 18:32:58 -04:00
contact.sendParentSignupInstructions(@state.get('parentEmail'))
.then =>
2016-06-07 17:51:41 -04:00
@state.set({ error: false, parentEmailSent: true, parentEmailSending: false })
2016-06-30 18:32:58 -04:00
.catch =>
2016-06-07 17:51:41 -04:00
@state.set({ error: true, parentEmailSent: false, parentEmailSending: false })
2016-06-30 18:32:58 -04:00
onClickBackButton: ->
@trigger 'nav-back'