ywana-core8 0.1.13 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +14 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +0 -2
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +14 -2
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +14 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/widgets/login/ResetPasswordBox.css +0 -2
- package/src/widgets/login/ResetPasswordBox.js +5 -3
- package/src/widgets/login/ResetPasswordBoxTest.js +1 -0
package/package.json
CHANGED
@@ -6,7 +6,7 @@ import './ResetPasswordBox.css'
|
|
6
6
|
/**
|
7
7
|
* Reset Password
|
8
8
|
*/
|
9
|
-
export const ResetPasswordBox = ({ logo, title, userRequired = true, lang = "EN", children, onOK, onClose }) => {
|
9
|
+
export const ResetPasswordBox = ({ logo, title, userRequired = true, oldPwdRequired = false, lang = "EN", children, onOK, onClose }) => {
|
10
10
|
|
11
11
|
const [form, setForm] = useState({})
|
12
12
|
const [isValid, setIsValid] = useState(false)
|
@@ -14,16 +14,17 @@ export const ResetPasswordBox = ({ logo, title, userRequired = true, lang = "EN"
|
|
14
14
|
|
15
15
|
useEffect(() => {
|
16
16
|
setIsValid(validate())
|
17
|
-
}, [form.password1, form.password2])
|
17
|
+
}, [form.password1, form.password2, form.oldPassword])
|
18
18
|
|
19
19
|
function validate() {
|
20
20
|
const hasRequiredUser = userRequired ? form.user && form.user.length > 0 : true
|
21
|
+
const hasRequiredOldPwd = oldPwdRequired ? form.oldPassword && form.oldPassword.length > 0 : true
|
21
22
|
const hasPassword1 = form.password1 && form.password1.length > 0
|
22
23
|
const [isValid, error] = hasPassword1 ? validatePassword(form.password1) : [false, "La contraseña es requerida."]
|
23
24
|
setError(error)
|
24
25
|
const areEqual = form.password1 === form.password2
|
25
26
|
if (isValid && !areEqual) setError("Las contraseñas no coinciden.")
|
26
|
-
return hasRequiredUser && areEqual && isValid
|
27
|
+
return hasRequiredUser && hasRequiredOldPwd && areEqual && isValid
|
27
28
|
}
|
28
29
|
|
29
30
|
function changeField(id, value) {
|
@@ -58,6 +59,7 @@ export const ResetPasswordBox = ({ logo, title, userRequired = true, lang = "EN"
|
|
58
59
|
<main>
|
59
60
|
<Text use="headline6">{text}</Text>
|
60
61
|
{userRequired ? <TextField id="user" outlined icon="person" label={userLabel} lapse={100} onChange={changeField} onEnter={ok} /> : null}
|
62
|
+
{oldPwdRequired ? <TextField id="oldPassword" outlined icon="lock" type="password" label="Old Password" lapse={100} onChange={changeField} onEnter={ok} /> : null}
|
61
63
|
<TextField id="password1" outlined icon="lock" type="password" label={passwordLabel} lapse={100} onChange={changeField} onEnter={ok} />
|
62
64
|
<TextField id="password2" outlined icon="lock" type="password" label={password2Label} lapse={100} onChange={changeField} onEnter={ok} />
|
63
65
|
{error ? <div className="error">{error}</div> : null}
|