From 731cc282c2e6c113603a92ab452d866dd9112789 Mon Sep 17 00:00:00 2001 From: han gyu min Date: Wed, 4 Aug 2021 16:56:37 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9D=B8=EC=A6=9D=EB=B2=88=ED=98=B8=20?= =?UTF-8?q?=EC=A3=BC=EC=84=9D=20=ED=92=80=EC=A7=80=20=EB=A7=88=EC=84=B8?= =?UTF-8?q?=EC=9A=94=20=EB=8F=88=20=EB=82=98=EA=B0=80=EC=9A=94=E3=85=A0?= =?UTF-8?q?=E3=85=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +- client/src/apis/auth.api.js | 11 +- client/src/components/MyInfo/MyInfo.js | 113 ++++++++++++--- .../src/components/MyInfo/my-info.module.scss | 8 +- .../ReservationDetails/ReservationDetails.js | 28 +++- .../reservation-details.module.scss | 12 +- client/src/components/Signup/Signup.js | 30 +++- client/src/pages/TicketingSeatPage.js | 2 +- server/config/app.config.js | 1 + server/controllers/user.controller.js | 130 ++++++++++-------- server/db/index.js | 5 +- server/index.js | 1 + server/models/confirmnum.model.js | 33 +++++ server/models/user.model.js | 4 + server/routes/user.route.js | 8 +- upload/7940cc48ad085961f79c68512dbd5126 | Bin 0 -> 7022 bytes upload/d08dd6186c9c0f2e3aa3bca35c0d9cbf | Bin 0 -> 7022 bytes 17 files changed, 287 insertions(+), 102 deletions(-) create mode 100644 server/models/confirmnum.model.js create mode 100644 upload/7940cc48ad085961f79c68512dbd5126 create mode 100644 upload/d08dd6186c9c0f2e3aa3bca35c0d9cbf diff --git a/.gitignore b/.gitignore index 362797a..dbb01d8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /node_modules .env.development -.env \ No newline at end of file +.env +./upload \ No newline at end of file diff --git a/client/src/apis/auth.api.js b/client/src/apis/auth.api.js index 2bc5dc9..b197f88 100644 --- a/client/src/apis/auth.api.js +++ b/client/src/apis/auth.api.js @@ -32,13 +32,13 @@ const compareId = async (userId) => { const confirmMbnum = async (phone) => { const url = `${baseUrl}/api/auth/phone/${phone}` - const { data } = await axios.post(url) + const { data } = await axios.post(url); return data } -const confirmNum = async (num) => { - const url = `${baseUrl}/api/auth/num/${num}` - const { data } = await axios.get(url) +const confirmNum = async (confirmNum) => { + const url = `${baseUrl}/api/auth/num` + const { data } = await axios.post(url, confirmNum); return data } @@ -61,7 +61,8 @@ const comparePw = async (pw) => { const modifyUser = async (user) => { const url = `${baseUrl}/api/auth/modify` - await axios.post(url, user) + const { data } = await axios.post(url, user) + return data } const authApi = { diff --git a/client/src/components/MyInfo/MyInfo.js b/client/src/components/MyInfo/MyInfo.js index dbe435a..29edd96 100644 --- a/client/src/components/MyInfo/MyInfo.js +++ b/client/src/components/MyInfo/MyInfo.js @@ -8,6 +8,7 @@ const MyInfo = () => { const [img, setImg] = useState(""); const [profile, setProfile] = useState(""); + const [startTime, setStartTime] = useState(""); // 사용자 이름 가져오는 함수 const getMember = async () => { const member = await authApi.getMember(); @@ -22,16 +23,21 @@ const MyInfo = () => { //변경할 데이터 입력받는 state const [userRe, setUserRe] = useState({ + userName: "", userEmail: "", userNickName: "", userMbnum: "", userPassword: "", userRePassword: "" }) + const [confirmMb, setConfirmMb] = useState(false); + const [number, setNumber] = useState(null); //각 타입별 error 유무 state + const [mbError,setMbError] = useState(false); const [error, setError] = useState(""); const [errorMsg, setErrorMsg] = useState({ + errorName: false, errorEmail: false, errorNickName: false, errorMbnum: false, @@ -62,7 +68,6 @@ const MyInfo = () => { } const enterKey = (e) => { if (e.key === "Enter") { - handleOnSummitVerify(e); } } @@ -105,6 +110,55 @@ const MyInfo = () => { } } + const handleOnClickMbnum = async (e) => { + e.preventDefault(); + try { + setStartTime(""); + setError(""); + setLoading(true); + const phone = userRe.userMbnum; + console.log("phone : ", phone); + const message = await authApi.confirmMbnum(phone); + console.log("message : ", message); + + if(message.isSuccess){ + console.log("mberror: "+mbError); + setMbError("보냄"); + setStartTime(message.startTime); + } + } catch (error) { + console.log('error'+ error) + }finally { + setLoading(false); + } + } + + const handleOnChangeMb = (e) => { + setNumber(String(e.target.value)); + } + + const handleOnClickMbConfirm = async (e) => { + e.preventDefault(); + try { + setError(""); + setLoading(true); + console.log("startTime : ", startTime); + const confirmNum = {userMbnum : userRe.userMbnum, number : number, startTime : startTime}; + console.log(confirmNum); + const message = await authApi.confirmNum(confirmNum); + console.log(message); + setMbError(message); + if(message === "성공"){ + setConfirmMb(true); + console.log("인증완료"); + } + } catch (error) { + catchErrors(error, setError); + }finally { + setLoading(false); + } + } + //비교하여 error메세지 반환 const vaildationData = (text, compareValue, error) => { if (text !== compareValue) { @@ -121,8 +175,11 @@ const MyInfo = () => { setErrorMsg(errorMsg => ({ ...errorMsg, [error]: false })); } } + //유효성 검사 const validation = () => { + //이름 유효성 검사 + vaildationData((userRe.userName.length === 0), false, "errorName"); //별명 유효성 검사 vaildationData((userRe.userNickName.length === 0), false, "errorNickName"); // 휴대폰 유효성 검사 @@ -133,31 +190,29 @@ const MyInfo = () => { vaildationData(userRe.userPassword, userRe.userRePassword, "errorRePassword"); // 최종 유효성 검사 - if ((Object.values(errorMsg).some((element) => (element)) === false)) { + if (!(Object.values(errorMsg).some((element) => (element)))) { return true } else { return false } } - - const handleOnSummit = async (e) => { e.preventDefault(); try { + console.log('handle ?????') setError(() => ("")); //처리가 될때까지 버튼(가입하기)이 안눌리게 지정 setLoading(() => (true)); - console.log("userRe : " + userRe.userEmail); //유효성 검사 let valid = validation(); - console.log("valid :" + valid); + console.log('handle on submit', valid) if (valid) { const userData = userRe; console.log(userData); //서버로 전송 - const process = await authApi.modifyUser(userData); - console.log("process : " + process); + const result = await authApi.modifyUser(userData); + console.log("result : " + result); alert("회원정보 수정 완료"); valid = false; } else { throw new Error("유효하지 않은 데이터입니다.") } @@ -190,8 +245,8 @@ const MyInfo = () => { - -