diff --git a/src/component/EditMyPage.js b/src/component/EditMyPage.js index de84f43..790e4c8 100644 --- a/src/component/EditMyPage.js +++ b/src/component/EditMyPage.js @@ -2,6 +2,7 @@ import "../EditMyPage.css" import React , {useState, useEffect,useCallback} from 'react'; import axios from "axios"; import { RiEdit2Fill } from "react-icons/ri"; +import { FaCrown } from "react-icons/fa"; export default function EditMyPage({location}){ @@ -10,10 +11,29 @@ export default function EditMyPage({location}){ const pw=location.state.pw; const email=location.state.email; const major=location.state.major; + const tel=location.state.tel; + const [boolChangePw,setBoolChangePw]=useState(false); + const [newPw, setNewPw]=useState(pw); const [newEmail, setNewEmail]=useState(email); const [newMajor, setNewMajor]=useState(major); + const [newTel, setNewTel]=useState(tel); + const newUser ={ + id:id, + name: name, + email:newEmail, + major:newMajor, + pw: boolChangePw ? newPw : pw , + tel:newTel + } + + const changePw=useCallback( + (e) => { + setNewPw(e.target.value); + }, + [] + ); const changeEmail=useCallback( (e) => { setNewEmail(e.target.value); @@ -26,24 +46,42 @@ export default function EditMyPage({location}){ }, [] ); + const changeTel=useCallback( + (e) => { + setNewTel(e.target.value); + }, + [] + ); + - const editEmail=(id, {data})=>{ - console.log(data); + const editPw=(id ,name, newPw)=>{ + setBoolChangePw(true); + axios.post('/mypage/changePw',{ + id:id, + name: name, + newPw: newPw + }) + } + + const editEmail=(id, newUser)=>{ axios.post('/mypage/changeEmail',{ id:id, - newEmail:data, + newEmail:newUser, }) - - } - const editMajor=(id, {data})=>{ + const editMajor=(id,newUser )=>{ axios.post('/mypage/changeMajor',{ id:id, - newMajor:data, + newMajor:newUser, + }) + } + const editTel=(id, newUser)=>{ + axios.post('/mypage/changeTel',{ + id:id, + newTel:newUser, }) } - return(