From d6a068588f6e8884a5f007c2df1ed6d0b7986521 Mon Sep 17 00:00:00 2001 From: benidene <111226162+benidene@users.noreply.github.com> Date: Sat, 12 Aug 2023 15:00:49 +0900 Subject: [PATCH] Signup (#12) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * : 회원가입 페이지 추가 * : 로고부분 클릭시 메인페이지로 이동 추가와 input 수정 * : id, email, phoneNumber 체크 기능 추가 * #10 : 회원가입 페이지 1차 완성 * #10 : 로그인, 회원가입 로직 완성 * #10 : 회원가입 버튼 이벤트 수정 --- src/pages/SignUp/SignUp.jsx | 9 ++- src/util/useLoginLogic.js | 113 ++++++++++++++++++------------------ 2 files changed, 64 insertions(+), 58 deletions(-) diff --git a/src/pages/SignUp/SignUp.jsx b/src/pages/SignUp/SignUp.jsx index 899d2e8..165d766 100644 --- a/src/pages/SignUp/SignUp.jsx +++ b/src/pages/SignUp/SignUp.jsx @@ -13,10 +13,11 @@ function SignUp() { phoneNumber: '', phoneNumberCheck: '' }; - const SIGNUP_POST_URL = `${process.env.REACT_APP_URL}/join`; + + const SIGNUP_POST_URL = `${process.env.REACT_APP_URL}/member1/join`; const msg = '모든 칸이 채워져야 합니다.'; - const [inputs, onChange, onSubmit, clickCheckId, clickPhoneNumber, clickAuthPhoneNumber] = + const [inputs, onChange, onClick, clickCheckId, clickPhoneNumber, clickAuthPhoneNumber] = useLoginLogic( initialInputs, SIGNUP_POST_URL, @@ -113,7 +114,9 @@ function SignUp() { 확인 - + + + 회원가입 diff --git a/src/util/useLoginLogic.js b/src/util/useLoginLogic.js index d1ee888..3f55b38 100644 --- a/src/util/useLoginLogic.js +++ b/src/util/useLoginLogic.js @@ -7,8 +7,10 @@ import { checkPassword, checkId, checkEmail, checkPhoneNumber } from './checkPas function useLoginLogic(initialInputs, url, alertMsg, key1, key2, key3, key4, key5, key6, key7) { const navigate = useNavigate(); const [inputs, setInputs] = useState(initialInputs); - const [usableId, setUsableId] = useState(false); - const [auth, setAuth] = useState(false); + + // const [usableId, setUsableId] = useState(false); + // const [auth, setAuth] = useState(false); + const { setIsLoggedIn, setTokens } = useContext(userContext); const onChange = (e) => { @@ -16,57 +18,58 @@ function useLoginLogic(initialInputs, url, alertMsg, key1, key2, key3, key4, key setInputs({ ...inputs, [name]: value }); }; - const clickCheckId = async (e) => { - e.preventDefault(); - const resultId = checkId(inputs.userIdentifier); - if (!resultId) return; + // const clickCheckId = async (e) => { + // e.preventDefault(); + // const resultId = checkId(inputs.userIdentifier); + // if (!resultId) return; - const res = await usePost(url, inputs.userIdentifier); - if (res.status === 400) { - alert('이미 사용중인 아이디입니다'); - setUsableId(false); - } - if (res.ok) { - alert('사용 가능한 아이디입니다'); - setUsableId(true); - } - }; + // const res = await usePost(url, inputs.userIdentifier); + // if (res.status === 400) { + // alert('이미 사용중인 아이디입니다'); + // setUsableId(false); + // } + // if (res.ok) { + // alert('사용 가능한 아이디입니다'); + // setUsableId(true); + // } + // }; - const clickPhoneNumber = async (e) => { - e.preventDefault(); - const resultPhoneNumber = checkPhoneNumber(inputs.phoneNumber); - if (!resultPhoneNumber) return; + // const clickPhoneNumber = async (e) => { + // e.preventDefault(); + // const resultPhoneNumber = checkPhoneNumber(inputs.phoneNumber); + // if (!resultPhoneNumber) return; - const res = await usePost(url, inputs.phoneNumber); - if (res.status === 400) { - alert('인증번호가 발송되지 않았습니다'); - } - if (res.ok) { - alert('인증번호 발송되었습니다'); - } - }; + // const res = await usePost(url, inputs.phoneNumber); + // if (res.status === 400) { + // alert('인증번호가 발송되지 않았습니다'); + // } + // if (res.ok) { + // alert('인증번호 발송되었습니다'); + // } + // }; - const clickAuthPhoneNumber = async (e) => { - e.preventDefault(); - if (inputs.phoneNumberCheck === '') { - alert('인증번호를 입력하시오'); - return; - } + // const clickAuthPhoneNumber = async (e) => { + // e.preventDefault(); + // if (inputs.phoneNumberCheck === '') { + // alert('인증번호를 입력하시오'); + // return; + // } - const res = await usePost(url, inputs.phoneNumberCheck); - if (res.status === 400) { - alert('인증번호가 일치하지않습니다'); - setAuth(false); - } - if (res.ok) { - alert('인증번호 확인되었습니다'); - setAuth(true); - } - }; + // const res = await usePost(url, inputs.phoneNumberCheck); + // if (res.status === 400) { + // alert('인증번호가 일치하지않습니다'); + // setAuth(false); + // } + // if (res.ok) { + // alert('인증번호 확인되었습니다'); + // setAuth(true); + // } + // }; - const onSubmit = async (e) => { + const onClick = async (e) => { e.preventDefault(); - + const resultId = checkId(inputs.userIdentifier); + if (!resultId) return; if ( inputs[key1] === '' || inputs[key2] === '' || @@ -79,14 +82,14 @@ function useLoginLogic(initialInputs, url, alertMsg, key1, key2, key3, key4, key alert(alertMsg); return; } - if (usableId === false) { - alert('아이디 중복체크 하세요'); - return; - } - if (auth === false) { - alert('인증번호를 확인하세요'); - return; - } + // if (usableId === false) { + // alert('아이디 중복체크 하세요'); + // return; + // } + // if (auth === false) { + // alert('인증번호를 확인하세요'); + // return; + // } const resultId = checkId(inputs.userIdentifier); if (!resultId) return; const resultPassword = checkPassword(inputs.password); @@ -121,5 +124,5 @@ function useLoginLogic(initialInputs, url, alertMsg, key1, key2, key3, key4, key return [inputs, onChange, onSubmit, clickCheckId, clickPhoneNumber, clickAuthPhoneNumber]; } - +// , clickCheckId, clickPhoneNumber, clickAuthPhoneNumber export default useLoginLogic;