diff --git a/src/pages/SignUpPage.tsx b/src/pages/SignUpPage.tsx index 1308aee..26a4132 100644 --- a/src/pages/SignUpPage.tsx +++ b/src/pages/SignUpPage.tsx @@ -9,33 +9,36 @@ import { AxiosError } from 'axios'; import { checkEmailAPI, joinAPI } from '@/apis/user'; import { BlurBackground } from '@/styles/modals/common.style'; -import Calendar from "@/components/Calendar"; -import ImageSlider from "@/components/ImageSlider"; +import Calendar from '@/components/Calendar'; +import ImageSlider from '@/components/ImageSlider'; import PhoneCheck from '@/components/PhoneCheck'; import { Link } from 'react-router-dom'; - const SignUp = () => { - const [name, setName] = useState(""); - const [year, setYear] = useState(""); - const [month, setMonth] = useState(""); - const [date, setDate] = useState(""); + const [name, setName] = useState(''); + const [year, setYear] = useState(''); + const [month, setMonth] = useState(''); + const [date, setDate] = useState(''); const [selectedSex, setSelectedSex] = useState(''); - const [phonenumber, setPhonenumber] = useState(""); - const [email, setEmail] = useState(""); - const [password, setPassword] = useState(""); - const [passwordCheck, setPasswordCheck] = useState(""); + const [phonenumber, setPhonenumber] = useState(''); + const [email, setEmail] = useState(''); + const [password, setPassword] = useState(''); + const [passwordCheck, setPasswordCheck] = useState(''); const [isEmail, setIsEmail] = useState(false); - const [isPassword, setIsPassword] = useState(""); + const [isPassword, setIsPassword] = useState(''); const [isCertify, setIsCertify] = useState(false); - const [emailMessage, setEmailMessage] = useState(""); - const [avaMessage, setAvaMessage] = useState(""); - const [passwordMessage, setPasswordMessage] = useState("*8자 이상으로 입력 *대문자 사용 *숫자 사용 *특수문자 사용"); - const [passwordcheckMessage, setPasswordCheckMessage] = useState("비밀번호 확인을 위해 다시 한 번 입력해주세요"); + const [emailMessage, setEmailMessage] = useState(''); + const [avaMessage, setAvaMessage] = useState(''); + const [passwordMessage, setPasswordMessage] = useState( + '*8자 이상으로 입력 *대문자 사용 *숫자 사용 *특수문자 사용', + ); + const [passwordcheckMessage, setPasswordCheckMessage] = useState( + '비밀번호 확인을 위해 다시 한 번 입력해주세요', + ); const [mismatchError, setMismatchError] = useState(false); const [isEmailSuccess, setIsEmailSuccess] = useState(false); - + const [isOpenOverlapModal, setIsOpenOverlapModal] = useState(false); const onChangeName = (e: React.ChangeEvent) => { @@ -64,17 +67,17 @@ const SignUp = () => { const id_overlap_check = async () => { try { const { code } = (await checkEmailAPI({ email })).data; - console.log(code) + console.log(code); setAvaMessage('사용 가능한 이메일이에요!'); setIsEmailSuccess(true); } catch (e) { if (e instanceof AxiosError) { - console.log(e.response?.data.code) - setIsOpenOverlapModal(true) + console.log(e.response?.data.code); + setIsOpenOverlapModal(true); setIsEmailSuccess(false); } } - } + }; const onChangePassword = (e: React.ChangeEvent) => { const passwordRegex = @@ -116,7 +119,18 @@ const SignUp = () => { const navigate = useNavigate(); const onApply = () => { - if (name && year && month && date && isCertify && selectedSex && email && password && passwordCheck && !mismatchError) { + if ( + name && + year && + month && + date && + isCertify && + selectedSex && + email && + password && + passwordCheck && + !mismatchError + ) { // 서버에 데이터 전송 onRegisterUserInfo(); console.log('정보 등록 완료'); @@ -128,15 +142,17 @@ const SignUp = () => { const onRegisterUserInfo = async () => { try { - const response = (await joinAPI({ - name : name, - email : email, - password : password, - check_password: passwordCheck, - birth_date: year + month + date, - gender: selectedSex === '미표기' ? null : selectedSex, - phone_number: phonenumber, - })).data + const response = ( + await joinAPI({ + name: name, + email: email, + password: password, + check_password: passwordCheck, + birth_date: [year, month, date].join('-'), + gender: selectedSex === '미표기' ? null : selectedSex, + phone_number: phonenumber, + }) + ).data; console.log(response); } catch (err) { console.log(err); @@ -146,7 +162,7 @@ const SignUp = () => { return ( - + @@ -194,7 +210,11 @@ const SignUp = () => { placeholder="DD" readOnly={true} > - + @@ -222,35 +242,40 @@ const SignUp = () => { 여자 - - - - - + + + + + 이메일 주소 - - - 중복 확인하기 - + + + 중복 확인하기 + {!isEmail && ( {emailMessage} )} {avaMessage} - - + + 비밀번호 { ))} - - - {name && year && month && date && selectedSex && isEmail && avaMessage && isPassword && passwordCheck && !mismatchError ? ( + + + {name && + year && + month && + date && + selectedSex && + isEmail && + avaMessage && + isPassword && + passwordCheck && + !mismatchError ? ( 가입하기 @@ -300,12 +334,12 @@ const SignUp = () => { 이미 계정이 있으신가요? 로그인 - - - - {isOpenOverlapModal && ( - - + + + + {isOpenOverlapModal && ( + +