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