import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; import { Grid, Row, Col, Button, FormGroup, ControlLabel, Checkbox } from 'react-bootstrap'; import Helmet from 'react-helmet'; import Layout from '../components/Layout'; import { ButtonSpacer, Spacer } from '../components/helpers'; import { acceptTerms, userSelector } from '../redux'; import { createSelector } from 'reselect'; import { navigateTo } from 'gatsby'; const propTypes = { acceptTerms: PropTypes.func.isRequired, acceptedPrivacyTerms: PropTypes.bool, isSignedIn: PropTypes.bool }; const mapStateToProps = createSelector( userSelector, ({ acceptedPrivacyTerms }) => ({ acceptedPrivacyTerms }) ); const mapDispatchToProps = dispatch => bindActionCreators({ acceptTerms }, dispatch); class AcceptPrivacyTerms extends Component { constructor(props) { super(props); this.state = { privacyPolicy: false, termsOfService: false, quincyEmail: true }; this.createHandleChange = this.createHandleChange.bind(this); this.handleSubmit = this.handleSubmit.bind(this); } createHandleChange(prop) { return () => this.setState(prevState => ({ [prop]: !prevState[prop] })); } handleSubmit(e) { e.preventDefault(); const { privacyPolicy, termsOfService, quincyEmail } = this.state; if (!privacyPolicy || !termsOfService) { return null; } return this.props.acceptTerms(quincyEmail); } render() { const { acceptedPrivacyTerms } = this.props; if (acceptedPrivacyTerms) { navigateTo('/welcome'); return null; } const { privacyPolicy, termsOfService, quincyEmail } = this.state; return ( Privacy Policy and Terms of Service

Please review our updated privacy policy and the terms of service.

Terms of Service I accept the{' '} terms of service {' '} (required) Privacy Policy I accept the{' '} privacy policy {' '} (required) Quincy's Emails I want weekly emails from Quincy, freeCodeCamp.org's founder.
); } } AcceptPrivacyTerms.propTypes = propTypes; export default connect( mapStateToProps, mapDispatchToProps )(AcceptPrivacyTerms);