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

33 lines
1.1 KiB
CoffeeScript
Raw Normal View History

2016-06-07 17:51:41 -04:00
ModalView = require 'views/core/ModalView'
State = require 'models/State'
template = require 'templates/core/create-account-modal/coppa-deny-view'
forms = require 'core/forms'
module.exports = class SegmentCheckView extends ModalView
id: 'coppa-deny-view'
template: template
events:
'click .send-parent-email-button': 'onClickSendParentEmailButton'
'input input[name="parentEmail"]': 'onInputParentEmail'
initialize: ({ @sharedState } = {}) ->
@state = new State({ parentEmail: '' })
@listenTo @state, 'all', -> @renderSelectors('.render')
onInputParentEmail: (e) ->
@state.set { parentEmail: $(e.currentTarget).val() }, { silent: true }
onClickSendParentEmailButton: (e) ->
e.preventDefault()
@state.set({ parentEmailSending: true })
$.ajax('/send-parent-signup-instructions', {
method: 'POST'
data:
parentEmail: @state.get('parentEmail')
success: =>
@state.set({ error: false, parentEmailSent: true, parentEmailSending: false })
error: =>
@state.set({ error: true, parentEmailSent: false, parentEmailSending: false })
})