diff --git a/src/components/dashboard/users/UserPasswordForm.scss b/src/components/dashboard/users/UserPasswordForm.scss new file mode 100644 index 0000000000..2522737c5d --- /dev/null +++ b/src/components/dashboard/users/UserPasswordForm.scss @@ -0,0 +1,23 @@ +.inputContainer { + position: relative; +} + +.passwordToggle { + position: absolute; + width: 3em; + height: 3em; + top: 2.95em; + transform: translateY(-50%); + right: 0.1em; + background: none; + border: none; + cursor: pointer; + padding: 0.1em; + align-items: center; + justify-content: center; +} + +.passwordToggle .material-icons { + font-size: 1.8em; + color: #666; +} \ No newline at end of file diff --git a/src/components/dashboard/users/UserPasswordForm.tsx b/src/components/dashboard/users/UserPasswordForm.tsx index 090f3377a5..5ef5619980 100644 --- a/src/components/dashboard/users/UserPasswordForm.tsx +++ b/src/components/dashboard/users/UserPasswordForm.tsx @@ -7,6 +7,8 @@ import loading from '../../loading/loading'; import toast from '../../toast/toast'; import ButtonElement from '../../../elements/ButtonElement'; import InputElement from '../../../elements/InputElement'; +import IconButtonElement from 'elements/IconButtonElement'; +import './UserPasswordForm.scss'; type IProps = { userId: string | null; @@ -142,8 +144,30 @@ const UserPasswordForm: FunctionComponent = ({ userId }: IProps) => { }); }; + const togglePassword = () => { + const inputIds = ['#txtCurrentPassword', '#txtNewPassword', '#txtNewPasswordConfirm']; + inputIds.forEach(id => { + const input = page.querySelector(id) as HTMLInputElement; + if (input) { + input.type = (input.type === 'password') ? 'text' : 'password'; + } + }); + page.querySelectorAll('.passwordToggle .material-icons').forEach(icon => { + if (icon.classList.contains('visibility')) { + icon.classList.remove('visibility'); + icon.classList.add('visibility_off'); + } else { + icon.classList.remove('visibility_off'); + icon.classList.add('visibility'); + } + }); + }; + (page.querySelector('.updatePasswordForm') as HTMLFormElement).addEventListener('submit', onSubmit); (page.querySelector('#btnResetPassword') as HTMLButtonElement).addEventListener('click', resetPassword); + page.querySelectorAll('.passwordToggle').forEach(button => { + button.addEventListener('click', togglePassword); + }); }, [loadUser, userId]); return ( @@ -160,6 +184,11 @@ const UserPasswordForm: FunctionComponent = ({ userId }: IProps) => { label='LabelCurrentPassword' options={'autoComplete="off"'} /> +
= ({ userId }: IProps) => { label='LabelNewPassword' options={'autoComplete="off"'} /> +
= ({ userId }: IProps) => { label='LabelNewPasswordConfirm' options={'autoComplete="off"'} /> +