Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added PasswordTextField component fixed #1702 #1709

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/components/Account/SignUp/SignUp.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import validationSchema from './validationSchema';
import { signUp } from './SignUp.actions';
import messages from './SignUp.messages';
import './SignUp.css';
import PasswordTextField from '../../UI/FormItems/PasswordTextField';

export class SignUp extends Component {
static propTypes = {
Expand Down Expand Up @@ -114,18 +115,16 @@ export class SignUp extends Component {
error={errors.email}
onChange={handleChange}
/>
<TextField
type="password"
name="password"
label={intl.formatMessage(messages.createYourPassword)}
<PasswordTextField
error={errors.password}
label={intl.formatMessage(messages.password)}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to label={intl.formatMessage(messages.createYourPassword)}

name="password"
onChange={handleChange}
/>
<TextField
type="password"
name="passwordConfirm"
label={intl.formatMessage(messages.confirmYourPassword)}
error={errors.passwordConfirm}
<PasswordTextField
error={errors.confirmPassword}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to error={errors.passwordConfirm}

label={intl.formatMessage(messages.confirmPassword)}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to label={intl.formatMessage(messages.confirmYourPassword)}

name="confirmPassword"
KirtiKamal marked this conversation as resolved.
Show resolved Hide resolved
onChange={handleChange}
/>
<FormControlLabel
Expand Down
33 changes: 33 additions & 0 deletions src/components/UI/FormItems/PasswordTextField.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React, { useState } from 'react';
import { TextField, InputAdornment, IconButton } from '@material-ui/core';
import { Visibility, VisibilityOff } from '@material-ui/icons';

const PasswordTextField = ({ label, error, name, onChange }) => {
const [isPasswordVisible, setPasswordVisible] = useState(false);

const togglePasswordVisibility = () => {
setPasswordVisible(!isPasswordVisible);
};

return (
<TextField
error={!!error}
helperText={error}
label={label}
type={isPasswordVisible ? 'text' : 'password'}
name={name}
onChange={onChange}
InputProps={{
endAdornment: (
<InputAdornment position="end">
<IconButton onClick={togglePasswordVisibility}>
{isPasswordVisible ? <Visibility /> : <VisibilityOff />}
</IconButton>
</InputAdornment>
)
}}
/>
);
};

export default PasswordTextField;
Loading