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

[Auth] 회원가입 API 변경사항 대응 #71

Merged
merged 5 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/api/auth/APIDetail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ implements APIRequest<R> {
export class Signup<R extends SignupResponse> implements APIRequest<R> {
method = HTTP_METHOD.POST;

path = '/user/register';
path = '/user/student/register';

response!: R;

Expand Down
3 changes: 1 addition & 2 deletions src/api/auth/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ export interface SignupRequest {
// options
name?: string;
nickname?: string;
gender?: string;
gender?: number;
major?: string;
student_number?: string;
phone_number?: string;
identity?: number;
is_graduated?: boolean;
}

Expand Down
7 changes: 5 additions & 2 deletions src/pages/Auth/SignupPage/hooks/useSignup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { auth } from 'api';
import { AxiosError } from 'axios';
import { useMutation } from 'react-query';
import showToast from 'utils/ts/showToast';

Expand All @@ -13,8 +14,10 @@ const useSignup = (options: ISignupOption) => {
options.onSuccess?.();
showToast('success', '아우누리 이메일로 인증 메일을 발송했습니다. 확인 부탁드립니다.');
},
onError: () => {
showToast('error', '서버에 오류가 발생했습니다.');
onError: (error: AxiosError<{ message?: string }>) => {
if (error?.response?.data) {
showToast('error', error.response.data.message || '에러가 발생했습니다.');
}
},
});

Expand Down
5 changes: 2 additions & 3 deletions src/pages/Auth/SignupPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ const GenderListbox = React.forwardRef<ICustomFormInput, ICustomFormInputProps>(
[styles['select__trigger--active']]: currentValue !== null,
})}
>
{currentValue !== null ? GENDER_TYPE[currentValue].value : '성별'}
{currentValue !== null ? GENDER_TYPE[currentValue].label : '성별'}
</button>
{isOpenedPopup && (
<ul className={styles.select__content} role="listbox">
Expand Down Expand Up @@ -447,7 +447,7 @@ const useSignupForm = () => {
const submitForm: ISubmitForm = (formValue) => {
const payload = {
// 필수정보
email: formValue.id?.trim(),
email: `${formValue.id?.trim()}@koreatech.ac.kr`,
hanagertrudeKim marked this conversation as resolved.
Show resolved Hide resolved
password: formValue.password,
// 옵션
name: formValue.name || undefined,
Expand All @@ -456,7 +456,6 @@ const useSignupForm = () => {
major: formValue['student-number'].major || undefined,
student_number: formValue['student-number'].studentNumber || undefined,
phone_number: formValue['phone-number'] || undefined,
identity: 0,
is_graduated: false,
};
mutate(payload);
Expand Down
Loading