import { h, Component } from 'preact'; import PropTypes from 'prop-types'; import Navigation from './Navigation'; import { getContentOfToken } from '../utilities'; class BioForm extends Component { constructor(props) { super(props); this.handleChange = this.handleChange.bind(this); this.onSubmit = this.onSubmit.bind(this); this.state = { summary: '', }; } componentDidMount() { const csrfToken = getContentOfToken('csrf-token'); fetch('/onboarding_update', { method: 'PATCH', headers: { 'X-CSRF-Token': csrfToken, 'Content-Type': 'application/json', }, body: JSON.stringify({ user: { last_onboarding_page: 'bio form' } }), credentials: 'same-origin', }); } onSubmit() { const csrfToken = getContentOfToken('csrf-token'); const { summary } = this.state; fetch('/onboarding_update', { method: 'PATCH', headers: { 'X-CSRF-Token': csrfToken, 'Content-Type': 'application/json', }, body: JSON.stringify({ user: { summary } }), credentials: 'same-origin', }).then(response => { if (response.ok) { const { next } = this.props; next(); } }); } handleChange(e) { const { value } = e.target; this.setState({ summary: value, }); } render() { const { prev } = this.props; return (