-
Notifications
You must be signed in to change notification settings - Fork 2
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
[Feat] 비밀번호 재설정 QA #228
Merged
Merged
[Feat] 비밀번호 재설정 QA #228
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
3cf5577
feat: 이메일 전송하자마자 인증코드 섹션 보이게 구현
namdaeun 046ece4
#226 docs: api 폴더 생성 및 파일 이동
namdaeun 32e752d
#226 feat: 비밀번호 폼 커스텀 훅 생성 및 적용
namdaeun 158cb8b
#226 refactor: 객체로 상태관리
namdaeun 167fe88
#226 chore: boolean 변수명 변경
namdaeun f9ea764
#226 refactor: 인터페이스에 필요한 prop만 작성
namdaeun 0138f8f
#226 chore: add onClick prop
namdaeun 052001d
#226 feat: 상태 값이 있을 때 error message 띄우기
namdaeun d2a701c
#226 fix: 버튼 인터페이스 onClick 제거
namdaeun 90f2997
#226 chore: 절대 경로로 변경
namdaeun 624213a
#226 refactor: 업데이트 되는 값key 값 동적 할당으로 수정
namdaeun 04ba18b
#226 refactor: error, supportingText 값들 변수로 선언한 다음 할당
namdaeun 56e9254
#226 refactor: 커스텀 훅 이벤트 핸들러명 변경
namdaeun bd0b59a
#226 fix: 함수 호출코드 수정
namdaeun 5fbe542
#226 fix: 함수 조건문에 맞지 않을 경우 리턴 안함
namdaeun 2910354
#226 fix: 타입 에러 수정
namdaeun b527670
docs: merge develop
namdaeun 4a8823b
#226 fix: 빌드 에러 해결
namdaeun f58ab2b
#226 fix: 코리 반영
namdaeun 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
File renamed without changes.
68 changes: 68 additions & 0 deletions
68
src/page/login/password/reset/hook/common/usePasswordForm.ts
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,68 @@ | ||
import { useCallback, useState } from 'react'; | ||
|
||
import { PASSWORD_VALID_FORMAT, SUPPORTING_TEXT } from '@/shared/constant/form'; | ||
|
||
type Password = 'updatedPassword' | 'updatedPasswordChecker'; | ||
|
||
export const usePasswordForm = () => { | ||
const [form, setForm] = useState({ | ||
updatedPassword: '', | ||
updatedPasswordChecker: '', | ||
}); | ||
|
||
const handlePasswordChange = useCallback((key: Password, e: React.ChangeEvent<HTMLInputElement>) => { | ||
const { value } = e.target; | ||
|
||
setForm((prev) => ({ | ||
...prev, | ||
[key]: value, | ||
})); | ||
}, []); | ||
|
||
const handlePasswordValidate = useCallback(() => { | ||
const isPasswordValid = PASSWORD_VALID_FORMAT.test(form.updatedPassword); | ||
|
||
const isConfirmPasswordValid = form.updatedPassword === form.updatedPasswordChecker; | ||
|
||
return form.updatedPassword && form.updatedPasswordChecker && isPasswordValid && isConfirmPasswordValid; | ||
}, [form.updatedPassword, form.updatedPasswordChecker]); | ||
|
||
// 에러에 맞는 supporting text 반환 | ||
const handlePasswordMessage = useCallback((password: string) => { | ||
if (password === '') { | ||
return SUPPORTING_TEXT.PASSWORD; | ||
} | ||
|
||
if (!PASSWORD_VALID_FORMAT.test(password)) { | ||
return SUPPORTING_TEXT.PASSWORD_INVALID; | ||
} | ||
}, []); | ||
|
||
const handlePasswordCheckerMessage = useCallback((password: string, passwordChecker: string) => { | ||
if (passwordChecker === '') { | ||
return SUPPORTING_TEXT.PASSWORD; | ||
} | ||
|
||
if (password !== passwordChecker) { | ||
return SUPPORTING_TEXT.PASSWORD_NO_EQUAL; | ||
} | ||
}, []); | ||
|
||
const isPasswordError = !!form.updatedPassword && !handlePasswordValidate(); | ||
const isPasswordCheckerError = !!form.updatedPasswordChecker && !handlePasswordValidate(); | ||
const passwordSupportingTxt = form.updatedPassword && handlePasswordMessage(form.updatedPassword); | ||
const passwordCheckerSupportingTxt = | ||
form.updatedPasswordChecker && handlePasswordCheckerMessage(form.updatedPassword, form.updatedPasswordChecker); | ||
|
||
return { | ||
form, | ||
handlePasswordChange, | ||
handlePasswordValidate, | ||
handlePasswordMessage, | ||
handlePasswordCheckerMessage, | ||
isPasswordError, | ||
isPasswordCheckerError, | ||
passwordSupportingTxt, | ||
passwordCheckerSupportingTxt, | ||
}; | ||
}; |
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
4 changes: 2 additions & 2 deletions
4
src/shared/component/workSpaceModal/complete/WorkSpaceComplete.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
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
Oops, something went wrong.
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.
확실히 form으로 묶으니 전달하고자 하는 바를 명확하게 알 수 있어서 좋네요💯!!