-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 관리자 로그인 페이지에서 스위치가 관리로 활성화되지 않는 버그 (#469)
* fix: 관리페이지 로그인에서도 top nav 관리 탭으로 활성화 되도록 수정 * refactor: useEventLogin으로 훅 분리
- Loading branch information
1 parent
803f1c6
commit 1e37410
Showing
5 changed files
with
76 additions
and
59 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import {useState} from 'react'; | ||
|
||
import validateEventPassword from '@utils/validate/validateEventPassword'; | ||
|
||
import RULE from '@constants/rule'; | ||
|
||
import useRequestPostLogin from './queries/useRequestPostLogin'; | ||
|
||
const useEventLogin = () => { | ||
const [password, setPassword] = useState(''); | ||
const [errorMessage, setErrorMessage] = useState<string | null>(null); | ||
const [canSubmit, setCanSubmit] = useState(false); | ||
const {mutate: postLogin} = useRequestPostLogin(); | ||
|
||
const submitPassword = async (event: React.FormEvent<HTMLFormElement>) => { | ||
event.preventDefault(); | ||
|
||
postLogin({password}, {onError: () => setErrorMessage('비밀번호가 틀렸어요')}); | ||
}; | ||
|
||
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
const newValue = event.target.value; | ||
const validation = validateEventPassword(newValue); | ||
setErrorMessage(validation.errorMessage); | ||
|
||
if (validation.isValid) { | ||
setPassword(newValue); | ||
} | ||
|
||
setCanSubmit(newValue.length === RULE.maxEventPasswordLength); | ||
}; | ||
|
||
return { | ||
password, | ||
errorMessage, | ||
handleChange, | ||
canSubmit, | ||
submitPassword, | ||
}; | ||
}; | ||
|
||
export default useEventLogin; |
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