forked from StudyBadge-TenTen/StudyBadge_FE
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a881f51
commit 891bd5f
Showing
2 changed files
with
120 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ import { BANK_LIST } from "../../constants/bank-list"; | |
import PageScrollTop from "../common/PageScrollTop"; | ||
import { CustomErrorType } from "@/types/common"; | ||
import axios from "axios"; | ||
import { getAccountVerification } from "@/services/auth-api"; | ||
// import { getAccountVerification } from "@/services/auth-api"; | ||
|
||
const SignUp: React.FC = () => { | ||
const formListFirst = ["이메일", "이름", "비밀번호", "비밀번호확인"]; | ||
|
@@ -14,52 +14,52 @@ const SignUp: React.FC = () => { | |
const [isSubmitted, setIsSubmitted] = useState(false); | ||
const authStore = useAuthStore(); | ||
|
||
const verifyAccount = async (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => { | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
const bank = BANK_LIST.find((bankObj) => bankObj.name === authStore.accountBank); | ||
// const verifyAccount = async (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => { | ||
// e.stopPropagation(); | ||
// e.preventDefault(); | ||
// const bank = BANK_LIST.find((bankObj) => bankObj.name === authStore.accountBank); | ||
|
||
if (!authStore.name) { | ||
alert("계좌 인증을 위해 이름을 작성해주시기 바랍니다."); | ||
return; | ||
} | ||
// if (!authStore.name) { | ||
// alert("계좌 인증을 위해 이름을 작성해주시기 바랍니다."); | ||
// return; | ||
// } | ||
|
||
if (bank && authStore.account && authStore.name) { | ||
try { | ||
const response = await getAccountVerification(bank.code, authStore.account, authStore.name); | ||
if (axios.isAxiosError(response)) { | ||
const error = response.response?.data as CustomErrorType; | ||
alert(error.message); | ||
setIsAccountVerified(() => false); | ||
} else { | ||
if (response.data.accountHolder === authStore.name) { | ||
alert("계좌번호 인증에 성공하였습니다"); | ||
setIsAccountVerified(() => true); | ||
} else { | ||
alert("본인 명의의 계좌가 아닙니다. 입력한 이름과 계좌 소유주명이 동일하지 않습니다."); | ||
setIsAccountVerified(() => false); | ||
} | ||
} | ||
} catch (error) { | ||
if (axios.isAxiosError(error)) { | ||
const customError = error.response?.data as CustomErrorType; | ||
alert(customError.message); | ||
setIsAccountVerified(() => false); | ||
} else { | ||
alert( | ||
"계좌번호 인증에 문제가 발생하였습니다. 문제가 반복될 경우 [email protected] 해당 주소로 문의 메일을 보내주시면 감사하겠습니다.", | ||
); | ||
setIsAccountVerified(() => false); | ||
} | ||
} | ||
} else if (!bank) { | ||
alert("선택한 은행이 존재하지 않습니다."); | ||
return; | ||
} else if (!authStore.account) { | ||
alert("계좌번호를 입력해주세요"); | ||
return; | ||
} | ||
}; | ||
// if (bank && authStore.account && authStore.name) { | ||
// try { | ||
// const response = await getAccountVerification(bank.code, authStore.account, authStore.name); | ||
// if (axios.isAxiosError(response)) { | ||
// const error = response.response?.data as CustomErrorType; | ||
// alert(error.message); | ||
// setIsAccountVerified(() => false); | ||
// } else { | ||
// if (response.data.accountHolder === authStore.name) { | ||
// alert("계좌번호 인증에 성공하였습니다"); | ||
// setIsAccountVerified(() => true); | ||
// } else { | ||
// alert("본인 명의의 계좌가 아닙니다. 입력한 이름과 계좌 소유주명이 동일하지 않습니다."); | ||
// setIsAccountVerified(() => false); | ||
// } | ||
// } | ||
// } catch (error) { | ||
// if (axios.isAxiosError(error)) { | ||
// const customError = error.response?.data as CustomErrorType; | ||
// alert(customError.message); | ||
// setIsAccountVerified(() => false); | ||
// } else { | ||
// alert( | ||
// "계좌번호 인증에 문제가 발생하였습니다. 문제가 반복될 경우 [email protected] 해당 주소로 문의 메일을 보내주시면 감사하겠습니다.", | ||
// ); | ||
// setIsAccountVerified(() => false); | ||
// } | ||
// } | ||
// } else if (!bank) { | ||
// alert("선택한 은행이 존재하지 않습니다."); | ||
// return; | ||
// } else if (!authStore.account) { | ||
// alert("계좌번호를 입력해주세요"); | ||
// return; | ||
// } | ||
// }; | ||
|
||
const validateForm = (): boolean => { | ||
let result = true; | ||
|
@@ -78,9 +78,11 @@ const SignUp: React.FC = () => { | |
} else if (!authStore.account) { | ||
alert("계좌번호 입력은 필수입니다."); | ||
result = false; | ||
} else if (!isAccountVerified) { | ||
alert("계좌 인증이 필요합니다"); | ||
} else if (!authStore.password) { | ||
} | ||
// else if (!isAccountVerified) { | ||
// alert("계좌 인증이 필요합니다"); | ||
// } | ||
else if (!authStore.password) { | ||
alert("비밀번호 입력은 필수입니다."); | ||
result = false; | ||
} else if (authStore.password !== authStore.checkPassword) { | ||
|
@@ -197,14 +199,16 @@ const SignUp: React.FC = () => { | |
onChange={(e) => handleChange(e, formName)} | ||
/> | ||
</div> | ||
{formName === "계좌번호" && | ||
(isAccountVerified ? ( | ||
<div className="text-Green-1 mb-14">계좌인증완료</div> | ||
) : ( | ||
<button type="button" onClick={(e) => verifyAccount(e)} className="btn-blue mb-14"> | ||
계좌번호 인증 | ||
</button> | ||
))} | ||
{ | ||
// formName === "계좌번호" && | ||
// (isAccountVerified ? ( | ||
// <div className="text-Green-1 mb-14">계좌인증완료</div> | ||
// ) : ( | ||
// <button type="button" onClick={(e) => verifyAccount(e)} className="btn-blue mb-14"> | ||
// 계좌번호 인증 | ||
// </button> | ||
// )) | ||
} | ||
</React.Fragment> | ||
))} | ||
<button type="submit" className="btn-blue hover:bg-blue-700 text-white mt-10"> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ import axios from "axios"; | |
import { useAuthStore } from "../../store/auth-store"; | ||
import { useNavigate } from "react-router"; | ||
import { CustomErrorType } from "@/types/common"; | ||
import { getAccountVerification } from "@/services/auth-api"; | ||
// import { getAccountVerification } from "@/services/auth-api"; | ||
|
||
const ProfileEdit = ({ userInfo }: { userInfo: UserInfoType }): JSX.Element => { | ||
// todo: 회원가입 시 정했던 닉네임이랑 소개 등 글자수 제한 반영하기 | ||
|
@@ -29,6 +29,8 @@ const ProfileEdit = ({ userInfo }: { userInfo: UserInfoType }): JSX.Element => { | |
const accountBankRef = useRef<HTMLSelectElement>(null); | ||
|
||
useEffect(() => { | ||
console.log(isAccountVerified); // 임시 로그 | ||
|
||
if (userInfo) { | ||
setProfileInfo((origin) => ({ | ||
...origin, | ||
|
@@ -113,47 +115,47 @@ const ProfileEdit = ({ userInfo }: { userInfo: UserInfoType }): JSX.Element => { | |
}; | ||
|
||
// 계좌 인증하는 함수 | ||
const verifyAccount = async (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => { | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
const bank = BANK_LIST.find((bankObj) => bankObj.name === profileInfo.accountBank); | ||
// const verifyAccount = async (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => { | ||
// e.stopPropagation(); | ||
// e.preventDefault(); | ||
// const bank = BANK_LIST.find((bankObj) => bankObj.name === profileInfo.accountBank); | ||
|
||
if (bank && profileInfo.account) { | ||
try { | ||
const response = await getAccountVerification(bank.code, profileInfo.account); | ||
if (axios.isAxiosError(response)) { | ||
const error = response.response?.data as CustomErrorType; | ||
alert(error.message); | ||
setIsAccountVerified(() => false); | ||
} else { | ||
if (response.data.accountHolder === userInfo.name) { | ||
alert("계좌번호 인증에 성공하였습니다"); | ||
setIsAccountVerified(() => true); | ||
} else { | ||
alert("본인 명의의 계좌가 아닙니다. 입력한 이름과 계좌 소유주명이 동일하지 않습니다."); | ||
setIsAccountVerified(() => false); | ||
} | ||
} | ||
} catch (error) { | ||
if (axios.isAxiosError(error)) { | ||
const customError = error.response?.data as CustomErrorType; | ||
alert(customError.message); | ||
setIsAccountVerified(() => false); | ||
} else { | ||
alert( | ||
"계좌번호 인증에 문제가 발생하였습니다. 문제가 반복될 경우 [email protected] 해당 주소로 문의 메일을 보내주시면 감사하겠습니다.", | ||
); | ||
setIsAccountVerified(() => false); | ||
} | ||
} | ||
} else if (!bank) { | ||
alert("선택한 은행이 존재하지 않습니다."); | ||
return; | ||
} else if (!profileInfo.account) { | ||
alert("계좌번호를 입력해주세요"); | ||
return; | ||
} | ||
}; | ||
// if (bank && profileInfo.account) { | ||
// try { | ||
// const response = await getAccountVerification(bank.code, profileInfo.account); | ||
// if (axios.isAxiosError(response)) { | ||
// const error = response.response?.data as CustomErrorType; | ||
// alert(error.message); | ||
// setIsAccountVerified(() => false); | ||
// } else { | ||
// if (response.data.accountHolder === userInfo.name) { | ||
// alert("계좌번호 인증에 성공하였습니다"); | ||
// setIsAccountVerified(() => true); | ||
// } else { | ||
// alert("본인 명의의 계좌가 아닙니다. 입력한 이름과 계좌 소유주명이 동일하지 않습니다."); | ||
// setIsAccountVerified(() => false); | ||
// } | ||
// } | ||
// } catch (error) { | ||
// if (axios.isAxiosError(error)) { | ||
// const customError = error.response?.data as CustomErrorType; | ||
// alert(customError.message); | ||
// setIsAccountVerified(() => false); | ||
// } else { | ||
// alert( | ||
// "계좌번호 인증에 문제가 발생하였습니다. 문제가 반복될 경우 [email protected] 해당 주소로 문의 메일을 보내주시면 감사하겠습니다.", | ||
// ); | ||
// setIsAccountVerified(() => false); | ||
// } | ||
// } | ||
// } else if (!bank) { | ||
// alert("선택한 은행이 존재하지 않습니다."); | ||
// return; | ||
// } else if (!profileInfo.account) { | ||
// alert("계좌번호를 입력해주세요"); | ||
// return; | ||
// } | ||
// }; | ||
|
||
// 프로필 수정을 저장할 때 반영하도록 하는 함수 | ||
const handleSaveClick = async ( | ||
|
@@ -188,14 +190,14 @@ const ProfileEdit = ({ userInfo }: { userInfo: UserInfoType }): JSX.Element => { | |
} | ||
} | ||
|
||
if (!isAccountVerified) { | ||
alert("계좌 인증이 필요합니다"); | ||
if (accountRef.current) { | ||
accountRef.current.classList.add("outline-Red-2"); | ||
accountRef.current.focus(); | ||
} | ||
return; | ||
} | ||
// if (!isAccountVerified) { | ||
// alert("계좌 인증이 필요합니다"); | ||
// if (accountRef.current) { | ||
// accountRef.current.classList.add("outline-Red-2"); | ||
// accountRef.current.focus(); | ||
// } | ||
// return; | ||
// } | ||
|
||
if (nicknameRef.current) { | ||
if (!nicknameRef.current.value) { | ||
|
@@ -337,13 +339,15 @@ const ProfileEdit = ({ userInfo }: { userInfo: UserInfoType }): JSX.Element => { | |
</option> | ||
))} | ||
</select> | ||
{isAccountVerified ? ( | ||
<div className="text-Green-1 mb-14">계좌인증완료</div> | ||
) : ( | ||
<button type="button" onClick={(e) => verifyAccount(e)} className="btn-blue w-24 mt-2 ml-4"> | ||
계좌번호 인증 | ||
</button> | ||
)} | ||
{ | ||
// isAccountVerified ? ( | ||
// <div className="text-Green-1 mb-14">계좌인증완료</div> | ||
// ) : ( | ||
// <button type="button" onClick={(e) => verifyAccount(e)} className="btn-blue w-24 mt-2 ml-4"> | ||
// 계좌번호 인증 | ||
// </button> | ||
// ) | ||
} | ||
</div> | ||
<button | ||
type="submit" | ||
|