Skip to content

Commit

Permalink
fix/#61: 로그인 & 회원가입 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
yh-project committed Aug 30, 2024
1 parent ed145e4 commit 1667b25
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ssh-web/src/pages/Signup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ import { BirthdayForm } from '../../components/organisms/BirthdayForm';
import { nicknameDuplicate, signup } from '../../apis/userApi';
import { useLocation, useNavigate } from 'react-router-dom';
import { useMutation } from '@tanstack/react-query';
import { showToast } from '../../utils/toastUtil';

export const Signup = () => {
const location = useLocation();
const nav = useNavigate();
const { mutate } = useMutation({
mutationFn: async (request: ISignupRequest) => await signup(request),
onSuccess: () => nav('/'),
onError: (err) => console.log(err),
onSuccess: () => {
nav('/login');
showToast('success', '회원가입에 성공하였습니다');
},
onError: () => showToast('error', '회원가입에 실패하였습니다'),
});
const [pageType, setPageType] = useState<string>('info');
const [contents, setContents] = useState<IContent[]>([
Expand Down Expand Up @@ -73,11 +77,11 @@ export const Signup = () => {
!(contents[0].value as string).length ||
!nicknameCheck.test(contents[0].value as string)
) {
alert('닉네임은 한글/영문 2~8자 입니다');
showToast('error', '닉네임은 한글/영문 2~8자 입니다');
} else {
await nicknameDuplicate(contents[0].value as string).then((res) => {
if (res.data.isDuplicated) {
alert('중복된 닉네임입니다');
showToast('error', '중복된 닉네임입니다');
} else {
mutate({
code: location.state?.code,
Expand Down

0 comments on commit 1667b25

Please sign in to comment.