import React from 'react'; import Formsy from 'formsy-react'; import { Input } from 'formsy-react-components'; import { fakeData } from '../data/fakeData.js'; export class PersonEditor extends React.Component { constructor() { super(); this.state = { savedChanges: false }; } onChange() { this.setState({ savedChanges: false }); } submit(model, reset, setErrors) { PersonEditor.sendJson('put', `/api/people/${ this.props.params.personId }`, model).then(response => { if (response.ok) { this.setState({ savedChanges: true }); } else { // Parse server-side validation errors from the response and display them response.json().then(setErrors); } }); } render() { var personId = parseInt(this.props.params.personId); var person = fakeData.filter(p => p.id === personId)[0]; var notificationBox = this.state.savedChanges &&