From e2cfc6984e1b14110f030aa73b225ac10568ce6f Mon Sep 17 00:00:00 2001 From: bytesparallel Date: Tue, 21 Dec 2021 12:27:20 -0600 Subject: [PATCH] saving draft changes to profile form --- src/components/profile/ProfileForm.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/components/profile/ProfileForm.js b/src/components/profile/ProfileForm.js index e13629b..e6af57d 100644 --- a/src/components/profile/ProfileForm.js +++ b/src/components/profile/ProfileForm.js @@ -6,16 +6,17 @@ export const ProfileForm = () => { const[usertoedit, setediteduser ] = useState(localStorage.getItem("graphicsbaytracker_customer")) const [userpool, setuserpool] = useState([]) const [ founduser, setfounduser] = useState({}) + const [ editedusername, seteditedusername ] = useState("") + const [ editeduseremail, setediteduseremail ] = useState("") const history = useHistory() - const editprofileinfocall = (editedprofileinfo) => { - fetch('https://localhost:8088/users', { + const editprofileinfocall = () => { + fetch(`https://localhost:8088/users/${founduser.id}`, { method: 'PUT', body: JSON.stringify({ - id: founduser.id, - name: editedprofileinfo.name, - email: editedprofileinfo.email, + name: editedusername, + email: editeduseremail, }), headers: { @@ -35,8 +36,7 @@ export const ProfileForm = () => { () => { const desireduser = userpool.find((userobj) => userobj.id === parseInt(usertoedit)) return setfounduser(desireduser) - } - ) + }, ) useEffect( () => { fetch("http://localhost:8088/users") @@ -46,12 +46,12 @@ export const ProfileForm = () => { return ( <>

Edit Profile Data

-
+
-
+ {seteditedusername(e.target.editedusername)}}/>

- - editprofileinfocall(editedprofileinfo)}/> + { setediteduseremail(e.target.editeduseremail)}}/> +