Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FE] 회원가입시 예외처리를 하고, 한줄평 글자 1칸초과하는것을 해결한다. #1040

Merged
merged 9 commits into from
Dec 8, 2024

Conversation

skiende74
Copy link
Contributor

@skiende74 skiende74 commented Dec 6, 2024

❗ Issue

✨ 구현한 기능

회원가입시 예외처리

해결: usePostSignUpQuery를 이용하게해서 해결.  

한줄평 글자 1칸초과하는것을 해결한다.

해결 : onChange 전에 갯수확인을해준뒤 change

📢 논의하고 싶은 내용

🎸 기타

@skiende74 skiende74 changed the base branch from dev to dev-fe December 6, 2024 15:15
Copy link

github-actions bot commented Dec 6, 2024

@@ -53,6 +54,10 @@ const SubmitModalWithSummary = ({
onError();
};

const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
if (e.target.value.length <= 15) summary.onChange(e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이건 상수화를 하면 좋을 것 같습니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -60,16 +60,11 @@ const SignUpPage = () => {

const disabled = !isEmailValidated || !isNameValidated || !isPasswordValidated || !isPasswordConfirmValidated;

const mutation = usePostSignUpQuery();
if (mutation.isSuccess) navigate(ROUTE_PATH.signIn);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

실패시 postErrorMessage 가 떠서 에러 메세지가 렌더링 되게 해주어야 하는데 (로그인과 회원가입 실패는 toast 를 쓰지 않습니다) 이 로직도 포함시켜야 할 것 같습니다! 이렇게 되면 사용자가 회원가입을 실패한 이유를 알 수 없을 것 같아요..

Copy link
Contributor Author

@skiende74 skiende74 Dec 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

에러 시 토스트 떠요
(react-query 디폴트로 onError시 토스트 뜨게 되어서그래요)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

맞습니다ㄹ

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리안과 대화결과

토스트보다는 render로 보여주는 게 좋을거같다고 하여,
방법을찾아보고 적용했습니다.

해결한문제 : 디폴트로 들어간 onError를 특정 mutation에대해서만 해제하기

  const client = useQueryClient();
  client.setMutationDefaults(['auth', 'sign-up'], { onError: undefined });

를 통해 특정쿼리에 대해서만 onError를 해제할수있었습니다.

@ooherin
Copy link
Contributor

ooherin commented Dec 8, 2024

로그인 로직인데 참고하시면 좋을 것 같습니다!

  const handleSubmit = async () =>
    await signIn(
      { email, password },
      {
        onSuccess: async () => {
          const result = await getUserInfo();
          init(result.userEmail);

          showToast({ message: `${result?.userName}님, 환영합니다.`, type: 'confirm' });
          return navigate(ROUTE_PATH.home);
        },
        onError: error => setPostErrorMessage(error.message), //이부분
      },
    );

@skiende74 skiende74 self-assigned this Dec 8, 2024
@skiende74 skiende74 requested review from healim01 and ooherin December 8, 2024 12:10
Copy link

github-actions bot commented Dec 8, 2024

Copy link

github-actions bot commented Dec 8, 2024

@@ -60,16 +60,11 @@ const SignUpPage = () => {

const disabled = !isEmailValidated || !isNameValidated || !isPasswordValidated || !isPasswordConfirmValidated;

const mutation = usePostSignUpQuery();
if (mutation.isSuccess) navigate(ROUTE_PATH.signIn);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

맞습니다ㄹ

Comment on lines 67 to 68
await mutation.mutate({ name, email, password });
showToast({ message: '회원가입이 완료되었습니다.', type: 'confirm' });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이부분 구조분해 + 쿼리 내부로 로직 넣는건 어떨까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넣었습니다 !

Copy link

github-actions bot commented Dec 8, 2024

Copy link

github-actions bot commented Dec 8, 2024


const usePostSignUpQuery = () => {
const client = useQueryClient();
client.setMutationDefaults(['auth', 'sign-up'], { onError: undefined });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍👍👍

Copy link

github-actions bot commented Dec 8, 2024

@ooherin ooherin merged commit f28e2d1 into dev-fe Dec 8, 2024
3 checks passed
@ooherin ooherin deleted the fix/1032-sign-up branch December 8, 2024 13:55
Copy link

github-actions bot commented Dec 8, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants