Skip to content

Commit

Permalink
#10 <fix> : 회원가입 버튼 이벤트 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
benidene committed Aug 12, 2023
1 parent 0b5c417 commit ba88e83
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 58 deletions.
6 changes: 3 additions & 3 deletions src/pages/SignUp/SignUp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ 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,
Expand Down Expand Up @@ -113,7 +113,7 @@ function SignUp() {
<AuthButton onClick={clickAuthPhoneNumber}>확인</AuthButton>
</InputBoxDown>
</Container>
<LoginButton type='submit' onSubmit={onSubmit}>
<LoginButton type='submit' onClick={onClick}>
회원가입
</LoginButton>
</Wrapper>
Expand Down
110 changes: 55 additions & 55 deletions src/util/useLoginLogic.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,64 +7,64 @@ 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) => {
const { name, value } = e.target;
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();

if (
Expand All @@ -79,14 +79,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);
Expand Down Expand Up @@ -119,7 +119,7 @@ function useLoginLogic(initialInputs, url, alertMsg, key1, key2, key3, key4, key
}
};

return [inputs, onChange, onSubmit, clickCheckId, clickPhoneNumber, clickAuthPhoneNumber];
return [inputs, onChange, onClick];
}

// , clickCheckId, clickPhoneNumber, clickAuthPhoneNumber
export default useLoginLogic;

0 comments on commit ba88e83

Please sign in to comment.