From c35369a6bdee0de466765bb08f3bd27c6c93ce17 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 21 Oct 2020 18:56:42 +0200 Subject: style subscription form --- .../app/views/viewer/forms/subscription.form.js | 72 ++++++++++++++++------ 1 file changed, 52 insertions(+), 20 deletions(-) (limited to 'animism-align/frontend/app/views/viewer/forms/subscription.form.js') diff --git a/animism-align/frontend/app/views/viewer/forms/subscription.form.js b/animism-align/frontend/app/views/viewer/forms/subscription.form.js index 9353e3e..8107358 100644 --- a/animism-align/frontend/app/views/viewer/forms/subscription.form.js +++ b/animism-align/frontend/app/views/viewer/forms/subscription.form.js @@ -2,19 +2,30 @@ import React, { Component } from 'react' import { Arrow } from '../nav/viewer.icons' +const initialState = { + email: "", + agreed: false, + subscribed: false, +} + export default class SubscriptionForm extends Component { state = { - email: "", + ...initialState } constructor(props) { super(props) this.handleChange = this.handleChange.bind(this) this.handleKeyDown = this.handleKeyDown.bind(this) this.handleSubmit = this.handleSubmit.bind(this) + this.handleCheckbox = this.handleCheckbox.bind(this) + this.handleReset = this.handleReset.bind(this) } handleChange(e) { this.setState({ email: e.target.value }) } + handleCheckbox(e) { + this.setState({ agreed: e.target.checked }) + } handleKeyDown(e) { // disable tab if (e.keyCode === 9) { @@ -23,26 +34,46 @@ export default class SubscriptionForm extends Component { } handleSubmit(e) { e.preventDefault() + if (!this.state.agreed) { + return + } + this.setState({ subscribed: true }) + } + handleReset(e) { + this.setState({ ...initialState }) } render() { return ( -
+
Stay up to date and get notified when the next episode is available
- -