import { Link, useParams } from "react-router-dom"; import React, { useEffect, useState } from "react"; import userApi from "../../apis/user.api"; const userprofile = localStorage.getItem("user"); console.log(userprofile); const INIT_PROFILE = { id: userprofile, name:"", email:"", phone:"", img: "", }; const InfoUpdate = () => { const { id } = useParams(); const [profile, setProfile] = useState(INIT_PROFILE); async function getProfile(userID) { try { const data = await userApi.getUser({ id: userID }); setProfile(data); console.log(data); } catch (error) {} } useEffect(() => { getProfile(userprofile); }, []); const handleChange = async (event) => { const { files } = event.target; let formData = new FormData(); formData.append("img", files[0]); formData.append("id", userprofile); try { const res = await userApi.profileimg(formData); console.log(res); if(files){ setProfile({...profile, img:res}) }else{ setProfile() } } catch (error) {} }; const changeinfo = async (event) => { console.log(profile); const res = await userApi.updateinfo(profile) }; const updateinfo = (event) => { const { name, value } = event.target; setProfile({ ...profile, [name]: value }); console.log(profile); }; const{email,phone,name}=profile return (
#{userprofile}

이름

전화번호

); }; export default InfoUpdate;