Skip to content

Commit

Permalink
Use the HideableTextFormField component
Browse files Browse the repository at this point in the history
  • Loading branch information
tan12082001 committed Dec 6, 2023
1 parent 1ca662f commit 0eb5b60
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/components/Form/FormComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const StyledForm = styled(Form)`
}
& > .margin {
gird-colum: span 2;
gird-column: span 2;
margin-left: 15%;
margin-right: 15%;
}
Expand Down
12 changes: 1 addition & 11 deletions src/components/Form/HideableTextFormField.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ const HideableTextFormField = ({
// apiKey,
...props
}) => {
const [field, meta] = useField(props);
const [field, meta] = useField(name);
const [showKey, setShowKey] = useState(false);

const handleToggle = () => {
setShowKey(!showKey);
};
Expand Down Expand Up @@ -69,15 +68,6 @@ HideableTextFormField.propTypes = {
// apiKey: PropTypes.string,
};

HideableTextFormField.defaultProps = {
lpiSrc: '',
rpiSrc: '',
className: '',
name: '',
id: '',
// apiKey: '',
};

const VisibiltyToggleIconsArea = styled.div`
display: flex;
margin-right: 1rem;
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Auth/SignIn/SigninForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { TextInputField } from '../../../components/Form/FormField';
// import { useEffect } from 'react';
import { userLogin } from '../../../redux/thunk';
// import { useSelector } from 'react-redux';
import HideableTextFormField from '../../../components/Form/HideableTextFormField';

const SignInForm = () => {
const dispatch = useDispatch();
Expand All @@ -24,7 +25,7 @@ const SignInForm = () => {
className="sign-in-form"
>
<TextInputField label="Email" name="email" placeholder="eg. example@example.com" />
<TextInputField label="Password" name="password" placeholder="eg. A1@_3er" />
<HideableTextFormField label="Password" name="password" />
<FormSubmitButton type="submit" className="sign-up-submit">
Log In
</FormSubmitButton>
Expand Down
5 changes: 3 additions & 2 deletions src/pages/Auth/SignUp/SignupForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import FormSubmitButton from '../../../components/Button/FormSubmitButton';
import { TextInputField } from '../../../components/Form/FormField';
// import { useEffect } from 'react';
import { userSignUp } from '../../../redux/thunk';
import HideableTextFormField from '../../../components/Form/HideableTextFormField';

const SignUpForm = () => {
const dispatch = useDispatch();
Expand All @@ -24,8 +25,8 @@ const SignUpForm = () => {
>
<TextInputField label="Name" name="userName" placeholder="eg. Jane Doe" />
<TextInputField label="Email" name="email" placeholder="eg. example@example.com" />
<TextInputField label="Password" name="password" placeholder="eg. A1@_3er" />
<TextInputField label="Confirm Password" name="confirm_password" />
<HideableTextFormField label="Password" name="password" className="password_block" />
<HideableTextFormField label="Confirm Password" name="confirm_password" />
<FormSubmitButton type="submit" className="sign-up-submit">
Sign Up
</FormSubmitButton>
Expand Down

0 comments on commit 0eb5b60

Please sign in to comment.