From 70398ce2c016cf68bc7c2fdecf4619f426696356 Mon Sep 17 00:00:00 2001 From: Matt Huntington Date: Sat, 27 Feb 2021 19:43:14 -0500 Subject: [PATCH] update functionality --- src/components/person.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/components/person.js b/src/components/person.js index b2773cf..437a905 100644 --- a/src/components/person.js +++ b/src/components/person.js @@ -11,10 +11,42 @@ class Person extends React.Component { this.props.refreshCallback(); }) } + + updatePerson = (event)=>{ + event.preventDefault(); + axios + .put( + `https://desolate-thicket-29906.herokuapp.com/api/contacts/${this.props.data.id}`, + { + name:this.state.name, + age:this.state.age + } + ).then(()=>{ + this.props.refreshCallback(); + }) + } + + changeName = (event)=>{ + this.setState({ + name:event.target.value + }) + } + + changeAge = (event)=>{ + this.setState({ + age:event.target.value + }) + } + render = ()=>{ return
  • {this.props.data.name} is {this.props.data.age} years old +
    + + + +
  • } }