diff --git a/src/features/AuthServiceApp/components/Login/hooks.tsx b/src/features/AuthServiceApp/components/Login/hooks.tsx index 8ca1649f..8d5b9102 100644 --- a/src/features/AuthServiceApp/components/Login/hooks.tsx +++ b/src/features/AuthServiceApp/components/Login/hooks.tsx @@ -28,7 +28,7 @@ export const useLoginForm = () => { onPasswordBlur, onPasswordChange, password, - } = useAuthFields() + } = useAuthFields('login') const isSubmitDisabled = ( !email diff --git a/src/features/AuthServiceApp/components/Registration/hooks.tsx b/src/features/AuthServiceApp/components/Registration/hooks.tsx index 945b0b18..fef571be 100644 --- a/src/features/AuthServiceApp/components/Registration/hooks.tsx +++ b/src/features/AuthServiceApp/components/Registration/hooks.tsx @@ -17,7 +17,7 @@ export const useRegistrationForm = () => { onPasswordBlur, onPasswordChange, password, - } = useAuthFields() + } = useAuthFields('registration') const isSubmitDisabled = ( !email diff --git a/src/features/AuthServiceApp/hooks/useAuthFields.tsx b/src/features/AuthServiceApp/hooks/useAuthFields.tsx index 3bc5b3f1..89831b9a 100644 --- a/src/features/AuthServiceApp/hooks/useAuthFields.tsx +++ b/src/features/AuthServiceApp/hooks/useAuthFields.tsx @@ -7,7 +7,7 @@ import { useState } from 'react' import { isValidEmail } from 'features/AuthServiceApp/helpers/isValidEmail' import { isValidPassword } from 'features/AuthServiceApp/helpers/isValidPassword' -export const useAuthFields = () => { +export const useAuthFields = (page: 'login'|'registration') => { const [email, setEmail] = useState('') const [password, setPassword] = useState('') const [error, setError] = useState('') @@ -25,7 +25,8 @@ export const useAuthFields = () => { const onPasswordChange = ({ target: { value } }: ChangeEvent) => { setError('') setPassword(value) - if (!checkPassword(value)) { + const isRegisterPage = page === 'registration' + if (!checkPassword(value) && isRegisterPage) { setError('check_password') } }