ywana-core8 0.0.746 → 0.0.747

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.0.746",
3
+ "version": "0.0.747",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -1,13 +1,13 @@
1
- import React, { useEffect, useState } from 'react'
1
+ import React, { useState } from 'react'
2
2
  import { TextField, Text, Button } from '../../html'
3
3
  import './ResetPasswordBox.css'
4
4
 
5
5
  /**
6
6
  * Reset Password
7
7
  */
8
- export const ResetPasswordBox = ({ logo, title, children, onOK, onClose }) => {
8
+ export const ResetPasswordBox = ({ logo, title, userRequired = true, lang = "EN", children, onOK, onClose }) => {
9
9
 
10
- const [form, setForm ] = useState({})
10
+ const [form, setForm] = useState({})
11
11
  const [error, setError] = useState()
12
12
 
13
13
  function canOK() {
@@ -15,13 +15,13 @@ export const ResetPasswordBox = ({ logo, title, children, onOK, onClose }) => {
15
15
  }
16
16
 
17
17
  function changeField(id, value) {
18
- const next = Object.assign({}, form, {[id]: value})
18
+ const next = Object.assign({}, form, { [id]: value })
19
19
  setForm(next)
20
20
  }
21
21
 
22
22
  function ok() {
23
23
  if (onOK && canOK()) {
24
- if (form.password1 === form.password2 ) {
24
+ if (form.password1 === form.password2) {
25
25
  setError(null)
26
26
  onOK(form)
27
27
  } else {
@@ -34,23 +34,30 @@ export const ResetPasswordBox = ({ logo, title, children, onOK, onClose }) => {
34
34
  if (onClose) onClose()
35
35
  }
36
36
 
37
+ const text = lang === "EN" ? "CHANGE PASSWORD" : "CAMBIO DE CLAVE"
38
+ const userLabel = lang === "EN" ? "User" : "Usuario"
39
+ const passwordLabel = lang === "EN" ? "New Password" : "Nueva Clave"
40
+ const password2Label = lang === "EN" ? "Confirm New Password" : "Confirmar Nueva Clave"
41
+ const okLabel = lang === "EN" ? "OK" : "Aceptar"
42
+ const cancelLabel = lang === "EN" ? "Cancel" : "Cancelar"
43
+
37
44
  return (
38
45
  <div className="reset-password-box">
39
46
  <header>
40
47
  {logo ? <img src={logo} /> : null}
41
48
  {title ? <div className="title"><Text>{title}</Text></div> : null}
42
- { children }
49
+ {children}
43
50
  </header>
44
51
  <main>
45
- <Text use="headline6">Change Password</Text>
46
- <TextField id="user" outlined icon="person" label="User" lapse={100} onChange={changeField} onEnter={ok}/>
47
- <TextField id="password1" outlined icon="lock" type="password" label="New Password" lapse={100} onChange={changeField} onEnter={ok}/>
48
- <TextField id="password2" outlined icon="lock" type="password" label="Confirm New Password" lapse={100} onChange={changeField} onEnter={ok}/>
49
- { error ? <div className="error">{error}</div> : null}
52
+ <Text use="headline6">{text}</Text>
53
+ {userRequired ? <TextField id="user" outlined icon="person" label={userLabel} lapse={100} onChange={changeField} onEnter={ok} /> : null}
54
+ <TextField id="password1" outlined icon="lock" type="password" label={passwordLabel} lapse={100} onChange={changeField} onEnter={ok} />
55
+ <TextField id="password2" outlined icon="lock" type="password" label={password2Label} lapse={100} onChange={changeField} onEnter={ok} />
56
+ {error ? <div className="error">{error}</div> : null}
50
57
  </main>
51
58
  <footer>
52
- <Button label="Close" action={close}/>
53
- <Button label="OK" raised disabled={!canOK()} action={ok}/>
59
+ <Button label={cancelLabel} action={close} />
60
+ <Button label={okLabel} raised disabled={!canOK()} action={ok} />
54
61
  </footer>
55
62
  </div>
56
63
  )