-
Notifications
You must be signed in to change notification settings - Fork 0
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
refactor: 로그인/회원가입 폼에 react-hook-form 적용 #223
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
703a4a8
rebase: from develop
fecapark 22c6bec
refactor: SignupForm에 rhf 적용완료
fecapark 521d9c9
refactor: pr #217에 맞게 수정
fecapark 121b1fe
refactor: import 경로 @ 적용
fecapark b90cbd9
refactor: 확장자명 tsx -> ts
fecapark 6e00f91
fix: button들에 type=button 설정
fecapark 8a01a72
fix: button들에 type button 추가 설정
fecapark 9a706e3
fix: 닉네임 검사시 누락된 isBlank 함수 추가
fecapark 58844ea
fix: 약관동의를 첫 페이지로
fecapark 2924c05
remove: 중복되는 파일 제거
fecapark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 33 additions & 23 deletions
56
src/home/components/SignupContents/SignupForm/SignupForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 0 additions & 43 deletions
43
src/home/components/SignupContents/SignupForm/useSignUpForm.ts
This file was deleted.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
src/home/components/SignupContents/SignupForm/useSignupFormConfirm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { AxiosError } from 'axios'; | ||
import { SubmitHandler } from 'react-hook-form'; | ||
|
||
import { STORAGE_KEYS } from '@/constants/storage.constant'; | ||
import { postAuthSignUp } from '@/home/apis/postAuthSignUp'; | ||
import { AuthErrorData } from '@/home/types/Auth.type'; | ||
|
||
import { SignupFormProps, SignupFormStates } from './SignUpForm.type'; | ||
|
||
export const useSignupFormConfirm = ({ email, onConfirm }: SignupFormProps) => { | ||
const onSignupError = (error: AxiosError) => { | ||
alert( | ||
(error as AxiosError<AuthErrorData>).response?.data.message || '회원가입에 실패했습니다.' | ||
); | ||
}; | ||
|
||
const onSignupSuccess = () => { | ||
sessionStorage.removeItem(STORAGE_KEYS.EMAIL_AUTH_SESSION_TOKEN); | ||
sessionStorage.removeItem(STORAGE_KEYS.EMAIL_AUTH_SESSION_TOKEN_EXPIRED_IN); | ||
onConfirm(); | ||
}; | ||
|
||
const onFormConfirm: SubmitHandler<SignupFormStates> = async ({ nickname, password }) => { | ||
const sessionToken = sessionStorage.getItem(STORAGE_KEYS.EMAIL_AUTH_SESSION_TOKEN); | ||
|
||
if (!sessionToken) { | ||
alert('세션 토큰이 없습니다.'); | ||
return; | ||
} | ||
|
||
const signUpParams = { | ||
nickName: nickname, | ||
password: password, | ||
sessionToken: sessionToken, | ||
email: email, | ||
}; | ||
|
||
const { data, error } = await postAuthSignUp(signUpParams); | ||
|
||
if (data) onSignupSuccess(); | ||
else if (error) onSignupError(error); | ||
}; | ||
|
||
return onFormConfirm; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/react-hook-form/resolvers RHF에 resolver를 사용할 수도 있습니다 ㅎㅎ