Skip to content

Commit

Permalink
Update LoginForm.jsx
Browse files Browse the repository at this point in the history
  • Loading branch information
Mich47 committed May 4, 2023
1 parent 5e91808 commit 31b4a03
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions src/components/LoginForm/LoginForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,14 @@ const LoginValidationSchema = Yup.object().shape({

password: Yup.string()
.matches(PASSWORD_REGEX, 'This is an ERROR password')
.min(6, 'Too Short!')
.max(50, 'Too Long!')
.min(6, 'Too short!')
.max(50, 'Too long!')
.required('Required'),
});

export const LoginForm = () => {
const dispatch = useDispatch();
const [isPass, setIsPass] = useState(true);
const [emailValidationCompleted, setEmailValidationCompleted] =
useState(false);
const [passwordValidationCompleted, setPasswordValidationCompleted] =
useState(false);
const isLoading = useSelector(selectIsLoading);

useEffect(() => {
Expand Down Expand Up @@ -90,20 +86,16 @@ export const LoginForm = () => {
onChange={handleChange}
onBlur={event => {
handleBlur(event);
setEmailValidationCompleted(true);
}}
value={values.email}
placeholder="Enter your email"
error={errors.email}
touched={touched.email}
/>
<STC.Errors error={errors.email && touched.email}>
{emailValidationCompleted &&
(errors.email && touched.email ? (
<span>{errors.email}</span>
) : (
<span>This is an CORRECT email</span>
))}
{errors.email && touched.email && (
<span>{errors.email}</span>
)}
</STC.Errors>
</STC.Label>

Expand All @@ -119,20 +111,16 @@ export const LoginForm = () => {
onChange={handleChange}
onBlur={event => {
handleBlur(event);
setPasswordValidationCompleted(true);
}}
value={values.password}
placeholder="Enter password"
error={errors.password}
touched={touched.password}
/>
<STC.Errors error={errors.password && touched.password}>
{passwordValidationCompleted &&
(errors.password && touched.password ? (
<span>{errors.password}</span>
) : (
<span>This is an CORRECT password</span>
))}
{errors.password && touched.password && (
<span>{errors.password}</span>
)}
</STC.Errors>
<STC.ButtonEye
type="button"
Expand Down

0 comments on commit 31b4a03

Please sign in to comment.