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)}}/> +