Skip to content

Commit

Permalink
fixed bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Mich47 committed May 4, 2023
1 parent c033670 commit b185ace
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/components/LoginForm/LoginForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const LoginValidationSchema = Yup.object().shape({

password: Yup.string()
.matches(PASSWORD_REGEX, 'This is an ERROR password')
.min(5, 'Too Short!')
.min(6, 'Too Short!')
.max(50, 'Too Long!')
.required('Required'),
});
Expand Down Expand Up @@ -108,7 +108,9 @@ export const LoginForm = () => {
Password
</STC.Span>
<STC.Input
id="password"
type={isPass ? 'password' : 'text'}
required
name="password"
onChange={handleChange}
onBlur={event => {
Expand All @@ -134,7 +136,6 @@ export const LoginForm = () => {
isPass ? setIsPass(false) : setIsPass(true);
}}
>
{' '}
{isPass ? (
<STC.SvgEye>
<use xlinkHref={`${icon}#closed-eye`}></use>
Expand Down
4 changes: 2 additions & 2 deletions src/components/LoginForm/LoginForm.styled.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ export const ButtonEye = styled.button`
top: 38%;
left: 89%;
@media (min-width: 768px) {
top: 47%;
left: 87%;
top: 45%;
left: 91%;
}
`;

Expand Down
30 changes: 22 additions & 8 deletions src/components/RegisterForm/RegisterForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ const RegisterValidationSchema = Yup.object().shape({
password: Yup.string()
.matches(
PASSWORD_REGEX,
'must contain minimum 6 characters,at least 1 letter and 1 number'
'Must contain minimum 6 characters, at least 1 letter and 1 number'
)
.min(5, 'Too Short!')
.min(6, 'Too Short!')
.max(50, 'Too Long!')
.required('Required'),
});
Expand All @@ -36,6 +36,8 @@ export const RegisterForm = () => {
const [nameValidationCompleted, setNameValidationCompleted] = useState(false);
const [emailValidationCompleted, setEmailValidationCompleted] =
useState(false);
const [passwordValidationCompleted, setPasswordValidationCompleted] =
useState(false);

return (
<>
Expand Down Expand Up @@ -131,22 +133,35 @@ export const RegisterForm = () => {

<STC.Label
htmlFor="password"
error={errors.password && touched.password}
// error={errors.password && touched.password}
>
<STC.Span>Password</STC.Span>
<STC.Span error={errors.password} touched={touched.password}>
Password
</STC.Span>
<STC.Input
id="password"
name="password"
type="password"
type={isPass ? 'password' : 'text'}
required
autoComplete="off"
placeholder="Enter password"
value={values.password}
onChange={handleChange}
error={errors.password && touched.password}
onBlur={event => {
handleBlur(event);
setPasswordValidationCompleted(true);
}}
// error={errors.password && touched.password}
error={errors.password}
touched={touched.password}
/>
<STC.Errors error={errors.password && touched.password}>
{errors.password && touched.password && errors.password}
{passwordValidationCompleted &&
(errors.password && touched.password ? (
<span>{errors.password}</span>
) : (
<span>This is an CORRECT password</span>
))}
</STC.Errors>

<STC.ButtonEye
Expand All @@ -155,7 +170,6 @@ export const RegisterForm = () => {
isPass ? setIsPass(false) : setIsPass(true);
}}
>
{' '}
{isPass ? (
<STC.SvgEye>
<use xlinkHref={`${icon}#closed-eye`}></use>
Expand Down

0 comments on commit b185ace

Please sign in to comment.