Skip to content

Commit

Permalink
오류사항 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
wpdbsx committed Sep 18, 2023
1 parent 303ba01 commit 2038f68
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 25 deletions.
3 changes: 3 additions & 0 deletions src/components/common/InputBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const InputBox = React.memo(
isClose = false,
closeClick,
buttonClass,
isButtonDisable = false,
}: {
title?: string;
inputHeight?: string;
Expand All @@ -39,6 +40,7 @@ const InputBox = React.memo(
isClose?: boolean | null;
closeClick?: any;
buttonClass?: any;
isButtonDisable?: any;
}) => {
const [completeInputChk, setCompleteInputChk] = useState<boolean>(false);
return (
Expand Down Expand Up @@ -117,6 +119,7 @@ const InputBox = React.memo(
: "register-button btn-p-xl body3-bold margintop-8 " +
buttonClass
}
disabled={isButtonDisable}
onClick={buttonClick}
>
{buttonTitle}
Expand Down
22 changes: 18 additions & 4 deletions src/pages/auth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ const Login: React.FC = () => {
const [rememberEmail, setRememberEmail] = useState<boolean>(false); //id저장여부 확인
const [emailFormChk, setEmailFormChk] = useState<boolean>(false); //* 이메일 형식체크
const [invalid, setInvalid] = useState<boolean>(true); //아이디비밀번호 일치x
const {isLogin} = useAuthStore()
const { isLogin } = useAuthStore();

useEffect(() => {
isLogin && navigate('/main') //로그인했을 경우 메인페이지로 이동
isLogin && navigate("/main"); //로그인했을 경우 메인페이지로 이동

if (localStorage.getItem("bside-remember-login")) {
//로컬스토리지에서 email 가져오기
const LSrememberEmail: string = String(
Expand Down Expand Up @@ -129,7 +129,21 @@ const Login: React.FC = () => {
const handleRememberEmail = ({ target }: any) => {
setRememberEmail(!rememberEmail);
};

const industries = {
industry: {
카페: 1,
음식점: 2,
학원: 10,
미용실: 12,
학교: 5,
병원: 22,
약국: 17,
편의점: 1,
안경점: 2,
},
total: 77,
};
console.log(industries);
return (
<>
<div>
Expand Down
57 changes: 43 additions & 14 deletions src/pages/auth/Register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const Register: React.FC = () => {
gndrClsCd: "",
brdt: "",
});
const ReconfirmRef = useRef(null);
const navigate = useNavigate();
const [email, setEmail] = useState<string>("");
const [nickName, setNickName] = useState<string>("");
Expand All @@ -51,6 +50,7 @@ const Register: React.FC = () => {

const [nickNameChk, setNickNameChk] = useState<boolean>(true); // 닉네임 여부 체크
const [nickNameExistChk, setNickNameExistChk] = useState<boolean>(false); //* 닉네임 중복체크 미개발
const [isNickNameCheck, setIsNickNameCheck] = useState<boolean>(false);
const [nickNameAlertExistChk, setNickNameAlertExistChk] =
useState<boolean>(false);

Expand All @@ -71,6 +71,10 @@ const Register: React.FC = () => {
const [checkServiceAgree, setCheckServiceAgree] = useState<boolean>(false);
const [needCheck, setNeedCheck] = useState<boolean>(false);
const [joinSucess, setJoinSucess] = useState<boolean>(false);
const [isValidEmailCode, setIsValidEmailCode] = useState<boolean>(false);
const [isValidEmailCodeChk, setIsValidEmailCodeChk] =
useState<boolean>(false);

function isValidEmail() {
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;

Expand All @@ -84,7 +88,10 @@ const Register: React.FC = () => {
}

const handleEmailUpdate = (e: any) => {
setEmailChk(false);
setEmail(e.target.value);
setEmailDisable(false);
setIsValidEmailCode(false);
};

const handlePasswordBlur = (e: any) => {
Expand Down Expand Up @@ -133,6 +140,9 @@ const Register: React.FC = () => {

const handlenickNameUpdate = (e: any) => {
setNickName(e.target.value);
setIsNickNameCheck(false);
setNickNameChk(true);
setNickNameExistChk(false);
};

const handleBirthDateUpdate = (e: any) => {
Expand Down Expand Up @@ -169,6 +179,7 @@ const Register: React.FC = () => {
setNickNameExistChk(false);
}
setNickNameAlertExistChk(true);
setIsNickNameCheck(true);
} else {
setNickNameAlertLengthChk(true);
}
Expand All @@ -182,11 +193,12 @@ const Register: React.FC = () => {
} else {
// * 이메일 중복 체크 API
try {
setEmailDisable(true);
setEmailCodeAlertChk(true);
await fetch.post(`/api/user/check-email?email=${email}`, {
withCredentials: false,
});

setEmailDisable(true);
const result = await fetch.post(
`/api/email/emailConfirm`,
{
Expand All @@ -200,9 +212,8 @@ const Register: React.FC = () => {
// console.log(result.headers.get("set-cookie"));
// setLoading(false);
if (result.status === 200) {
setEmailCodeAlertChk(true);
}
setEmailDisable(false);
// setEmailDisable(false);
} catch (e: any) {
if (e.response.status === 409) {
setEmailExistChk(true);
Expand All @@ -226,12 +237,12 @@ const Register: React.FC = () => {
withCredentials: true,
}
);
console.log(result);

if (result.data === "인증번호가 일치합니다.") {
setEmailDisable(true);
// setEmailDisable(true);
setEmailCodeChk(true);
setEmailCodeConfirmChk(true);

setIsValidEmailCode(true);
setRegisterInfo((prev) => {
return { ...prev, eml: email };
});
Expand All @@ -246,8 +257,8 @@ const Register: React.FC = () => {
const handleRegister = async (e: any): Promise<void> => {
try {
e.preventDefault();

if (handleNickNameCheck()) {
console.log(isValidEmailCode);
if (handleNickNameCheck() && isNickNameCheck) {
// 닉네임 존재여부 체크
document.getElementById("nickName")?.focus();
} else if (email.length === 0) {
Expand All @@ -262,14 +273,18 @@ const Register: React.FC = () => {
document.getElementById("password")?.focus();
} else if (passwordReconfirmSuccessChk) {
document.getElementById("passwordReconfirm")?.focus();
} else if (emailExistChk) {
} else if (emailExistChk && !emailDisable) {
// 이메일 중복이 안되고 , 인증하기버튼이 disable일때
// 미완료

document.getElementById("email")?.focus();
} else if (nickNameExistChk) {
} else if (!nickNameExistChk) {
//미완료
console.log("nickname");

document.getElementById("nickName")?.focus();
} else if (!isValidEmailCode) {
console.log("test");
setIsValidEmailCodeChk(true);
} else if (!allCheck) {
setNeedCheck(true);
} else {
Expand Down Expand Up @@ -387,6 +402,7 @@ const Register: React.FC = () => {
inputChange={handlenickNameUpdate}
inputValue={nickName}
buttonClick={handleNickNameExistCheck}
isButtonDisable={isNickNameCheck}
inputBlur={() => {
if (registerInfo.usrNm !== nickName) {
setRegisterInfo((prev) => {
Expand Down Expand Up @@ -440,7 +456,7 @@ const Register: React.FC = () => {
inputPlaceholader={"이메일을 입력해주세요."}
inputMaxLength={30}
id={"email"}
isDisable={emailDisable}
isButtonDisable={emailDisable}
inputClassName={"register-flex-row-gap8 margintop-32"}
inputChange={handleEmailUpdate}
inputValue={email}
Expand Down Expand Up @@ -470,10 +486,13 @@ const Register: React.FC = () => {
inputValue={authNumber}
buttonClick={handleEamilCodeCheck}
inputHeight="56px"
isDisable={emailCodeChk}
// isDisable={emailCodeChk}
isButtonDisable={emailCodeChk}
inputBlur={() => {
if (authNumber.length > 0) {
setAuthNumberChk(true);
} else {
setAuthNumberChk(false);
}
}}
errObject={
Expand Down Expand Up @@ -867,6 +886,16 @@ const Register: React.FC = () => {
) : (
<></>
)}
{isValidEmailCodeChk === true ? (
<AlertTextPopup
text={`이메일 인증을 완료해주세요.`}
callbackFunction={() => {
setIsValidEmailCodeChk(false);
}}
/>
) : (
<></>
)}
</>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/pages/mypage/Mypage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ const Mypage: React.FC = () => {
try {
if (res.status === 200) {
const result = res.data;
console.log(result);

setEmail(result.eml);
setNickName(result.usrNm);
setPassword(result.password);
Expand Down
22 changes: 16 additions & 6 deletions src/pages/onpager/OnePagerMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import dateFormat from "composables/MAIN/MyCalenderDateFormat";
* @desc html -> canvas -> image -> download
*/
const OnePagerMain = () => {
const [toastText, setToastText] = useState<string>("");
const { setHeaderText, setIsNavigation } = useDefaultSets();
const { selectedMonth, answeredList, selectedDate, getAnsweredList } =
useAnsweredList();
Expand Down Expand Up @@ -88,7 +89,7 @@ const OnePagerMain = () => {

// alert(wrapper.textContent);
// wrapper.style.display = ""; //hidden 시 canvas가 안그려지는 현상있음
alert("1.2로변경완료");

const canvas = await html2canvas(wrapper, {
allowTaint: true,
useCORS: true,
Expand Down Expand Up @@ -121,6 +122,13 @@ const OnePagerMain = () => {
//원페이저 다운로드 클릭 이벤트
const downloadOnepager = async () => {
// data URL에서 base64 인코딩된 데이터를 추출합니다.

setToastText("웹페이저가 다운로드 중입니다");
setToastPopup(true); //토스트 팝업 출력

setTimeout(() => {
setToastPopup(false); //토스트 팝업 종료
}, 3000);
for (
let downLoadNumber = 0;
downLoadNumber < answeredSplitList.length;
Expand Down Expand Up @@ -150,6 +158,12 @@ const OnePagerMain = () => {
const sendEmail = async (email: string) => {
setConfirmEmailPopup(false); //팝업닫기
// const imageURL = await toOnepagerImage();

setToastText("이메일로 원페이저가 전송되었습니다!");
setToastPopup(true); //토스트 팝업 출력
setTimeout(() => {
setToastPopup(false); //토스트 팝업 종료
}, 3000);
const formData = new FormData();
formData.append("email", userInfo.eml);
formData.append("sendEmail", email);
Expand Down Expand Up @@ -189,10 +203,6 @@ const OnePagerMain = () => {
console.log(result);
if (result.status === 200) {
console.log("test");
setToastPopup(true); //토스트 팝업 출력
setTimeout(() => {
setToastPopup(false); //토스트 팝업 종료
}, 3000);
} else {
return false;
}
Expand Down Expand Up @@ -334,7 +344,7 @@ const OnePagerMain = () => {
//toast popup
toastPopup && (
<ToastPopup
text={"이메일로 원페이저가 전송되었습니다!"}
text={toastText}
bgColor={"#4D99DE"}
textColor={"#FFFFFF"}
/>
Expand Down

0 comments on commit 2038f68

Please sign in to comment.