Skip to content

Commit

Permalink
one more input field if password confirm is on
Browse files Browse the repository at this point in the history
  • Loading branch information
TigranBoomTech committed Oct 22, 2024
1 parent 3f6813c commit dc4f00c
Showing 1 changed file with 41 additions and 5 deletions.
46 changes: 41 additions & 5 deletions src/Body/Fields/Password/Password.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,64 @@
import React, { Fragment, useState } from 'react'
import React, { useState } from 'react'
import classNames from 'classnames/bind'
import { Input } from 'boomform'
import { stockedValidation } from '../../../Helpers/password'

const Password = ({
label,
classnameprefix,
matchPassword,
payment,
validation,
...props
}) => {
const [showPassword, setShowPassword] = useState(false)
const [passwordVisible, setPasswordVisible] = useState({
showPassword: false,
showConfirmPassword: false
})
const newValidation = stockedValidation(validation)

return (
<>
<Input
{...props}
validation={newValidation}
type={showPassword ? 'text' : 'password'}
type={passwordVisible.showPassword ? 'text' : 'password'}
placeholder={label}
/>
<span
onClick={() => setShowPassword(value => !value)}
className={classNames('password-icon', { active: showPassword })}
onClick={() =>
setPasswordVisible(prev => ({
...prev,
showPassword: !prev.showPassword
}))
}
className={classNames('password-icon', {
active: passwordVisible.showPassword
})}
></span>

{matchPassword && (
<>
<Input
{...props}
id={`${props.id}_confirm`}
validation={newValidation}
type={passwordVisible.showConfirmPassword ? 'text' : 'password'}
placeholder='Confirm Password'
/>
<span
onClick={() =>
setPasswordVisible(prev => ({
...prev,
showConfirmPassword: !prev.showConfirmPassword
}))
}
className={classNames('confirm-password-icon', {
active: passwordVisible.showConfirmPassword
})}
></span>
</>
)}
</>
)
}
Expand Down

0 comments on commit dc4f00c

Please sign in to comment.