Skip to content

Commit

Permalink
✨ Feature: 회원가입 로직(#14)
Browse files Browse the repository at this point in the history
response 변경으로 인한 api type 수정 && memberExist에서 setMail 로직 추가
  • Loading branch information
jinn2u committed Apr 27, 2022
1 parent 11ace29 commit a757a67
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion apis/users/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ export interface SignUpApiParams {
}

export interface SignUpApiResponse {
data: null;
data: {
email: string;
};
}
9 changes: 6 additions & 3 deletions components/SignUpAndSignInModal/SignUpForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ const SignUpForm = ({ email, setStep }: Props) => {
} = useForm({
resolver: yupResolver(verifySignUpData),
});

const onSubmit: SubmitHandler<FieldValues> = async ({ password, studentId, name, nickname }) => {
try {
const { data } = await signUpApi({ email, password, studentId, name, nickname });
if (!data) {
if (data.data.email) {
setStep(1);
}
} catch (e: any) {
Expand Down Expand Up @@ -77,20 +76,24 @@ const SignUpForm = ({ email, setStep }: Props) => {
id="password"
placeholder="비밀번호를 입력해 주세요"
type="password"
autoComplete="on"
{...register('password')}
/>
{errors.password && <S.ErrorMsg>{errors.password.message}</S.ErrorMsg>}
<S.Label htmlFor="passwordConfirm">비밀 번호 확인</S.Label>
<S.Label htmlFor="password-confirm">비밀 번호 확인</S.Label>
<S.Input
id="passwordConfirm"
placeholder="비밀번호 확인"
type="password"
autoComplete="on"
{...register('passwordConfirm')}
/>
{errors.passwordConfirm && <S.ErrorMsg>{errors.passwordConfirm.message}</S.ErrorMsg>}

<S.Label htmlFor="studentId">학번</S.Label>
<S.Input id="studentId" placeholder="학번을 입력해 주세요" {...register('studentId')} />
{errors.studentId && <S.ErrorMsg>{errors.studentId.message}</S.ErrorMsg>}

<S.Label htmlFor="name">이름</S.Label>
<S.Input id="name" placeholder="이름을 입력해 주세요" {...register('name')} />
{errors.name && <S.ErrorMsg>{errors.name.message}</S.ErrorMsg>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { isMemberExist } from '../../../apis/users';
import { CLIENT_ERROR, SERVER_ERROR } from '../../../apis/constants';
import { Props } from './types';

const VerifyIsMemberModal = ({ setStep }: Props) => {
const VerifyIsMemberModal = ({ setStep, setEmail }: Props) => {
const verifyEmail = yup.object().shape({
email: yup.string().required('이메일을 입력해 주세요.').email('이메일 양식이 아닙니다.'),
});
Expand All @@ -33,6 +33,7 @@ const VerifyIsMemberModal = ({ setStep }: Props) => {
data: { signup },
} = data;
const nextStep = signup ? 1 : 2;
setEmail(email);
setStep(nextStep);
} catch (e) {
console.error(e);
Expand Down

0 comments on commit a757a67

Please sign in to comment.