ywana-core8 0.1.13 → 0.1.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ywana-core8",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -9,10 +9,8 @@
9
9
  .reset-password-box>header {
10
10
  grid-area: header;
11
11
  display: flex;
12
- flex: 1;
13
12
  flex-direction: column;
14
13
  justify-content: space-around;
15
- align-items: center;
16
14
  }
17
15
 
18
16
  .reset-password-box>main {
@@ -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) {
@@ -32,7 +33,7 @@ export const ResetPasswordBox = ({ logo, title, userRequired = true, lang = "EN"
32
33
  }
33
34
 
34
35
  function ok() {
35
- if (onOK && canOK()) {
36
+ if (onOK) {
36
37
  onOK(form)
37
38
  }
38
39
  }
@@ -56,8 +57,8 @@ export const ResetPasswordBox = ({ logo, title, userRequired = true, lang = "EN"
56
57
  {children}
57
58
  </header>
58
59
  <main>
59
- <Text use="headline6">{text}</Text>
60
60
  {userRequired ? <TextField id="user" outlined icon="person" label={userLabel} lapse={100} onChange={changeField} onEnter={ok} /> : null}
61
+ {oldPwdRequired ? <TextField id="oldPassword" outlined icon="lock" type="password" label="Old Password" lapse={100} onChange={changeField} onEnter={ok} /> : null}
61
62
  <TextField id="password1" outlined icon="lock" type="password" label={passwordLabel} lapse={100} onChange={changeField} onEnter={ok} />
62
63
  <TextField id="password2" outlined icon="lock" type="password" label={password2Label} lapse={100} onChange={changeField} onEnter={ok} />
63
64
  {error ? <div className="error">{error}</div> : null}
@@ -10,6 +10,7 @@ export const ResetPasswordBoxTest = (prop) => {
10
10
  const config = {
11
11
  title: 'Reset Password',
12
12
  userRequired: false,
13
+ oldPwdRequired: false,
13
14
  lang: 'EN',
14
15
  onOK: (form) => {
15
16
  console.log('onOK', form)