contentoh-components-library 21.0.37 → 21.0.40
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/components/atoms/GeneralInput/index.js +8 -2
- package/dist/components/atoms/GradientPanel/styles.js +1 -1
- package/dist/components/atoms/Loading/index.js +5 -3
- package/dist/components/atoms/Loading/styles.js +1 -1
- package/dist/components/molecules/EmailResetPasswordLogin/index.js +1 -3
- package/dist/components/molecules/LoginPasswordStrength/index.js +9 -3
- package/dist/components/molecules/RegistrationFirstStep/index.js +68 -99
- package/dist/components/molecules/RegistrationFirstStep/styles.js +1 -1
- package/dist/components/molecules/RegistrationSecondStep/index.js +130 -47
- package/dist/components/molecules/SignInLogin/styles.js +1 -1
- package/dist/components/molecules/TagAndInput/index.js +8 -2
- package/dist/components/molecules/VerificationCodeResetPasswordLogin/index.js +114 -9
- package/package.json +1 -1
- package/src/components/atoms/GeneralInput/index.js +6 -0
- package/src/components/atoms/GradientPanel/styles.js +1 -0
- package/src/components/atoms/Loading/index.js +2 -0
- package/src/components/atoms/Loading/styles.js +14 -5
- package/src/components/molecules/EmailResetPasswordLogin/index.js +2 -2
- package/src/components/molecules/LoginPasswordStrength/index.js +11 -1
- package/src/components/molecules/RegistrationFirstStep/index.js +85 -103
- package/src/components/molecules/RegistrationFirstStep/styles.js +4 -1
- package/src/components/molecules/RegistrationSecondStep/index.js +76 -3
- package/src/components/molecules/SignInLogin/styles.js +1 -0
- package/src/components/molecules/TagAndInput/index.js +6 -0
- package/src/components/molecules/VerificationCodeResetPasswordLogin/index.js +100 -10
|
@@ -1,17 +1,52 @@
|
|
|
1
1
|
import { Container } from "./styles";
|
|
2
2
|
import { GradientPanel } from "../../atoms/GradientPanel";
|
|
3
|
-
import { useState } from "react";
|
|
3
|
+
import { useState, useEffect } from "react";
|
|
4
4
|
import { ScreenHeader } from "../../atoms/ScreenHeader";
|
|
5
5
|
import { GlobalColors, FontFamily } from "../../../global-files/variables";
|
|
6
6
|
import { Button } from "../../atoms/GeneralButton";
|
|
7
7
|
import { LoginPasswordStrength } from "../../molecules/LoginPasswordStrength";
|
|
8
8
|
import { LogoImage } from "../../atoms/LogoImage";
|
|
9
9
|
|
|
10
|
-
export const RegistrationSecondStep = () => {
|
|
10
|
+
export const RegistrationSecondStep = (props) => {
|
|
11
|
+
const [passwordStrength, setPasswordStrenght] = useState(0);
|
|
12
|
+
const [passwordFinal, setPasswordFinal] = useState("");
|
|
13
|
+
const [repeatedPassword, setRepeatedPassword] = useState("");
|
|
14
|
+
const [passwordMatches, setPasswordMatches] = useState(false);
|
|
15
|
+
const [passwordToShort, setPasswordToShort] = useState(true);
|
|
16
|
+
const [showErrors, setShowErrors] = useState(false);
|
|
17
|
+
const [privacyCheck, setPrivacyCheck] = useState(false);
|
|
18
|
+
const [termsCheck, setTermsCheck] = useState(false);
|
|
19
|
+
|
|
11
20
|
const [emptyPassword, setEmptyPassword] = useState(false);
|
|
12
21
|
const [emptyConfirmPassword, setEmptyConfirmPassword] = useState(false);
|
|
13
22
|
const [matchPasswords, setMatchPasswords] = useState(true);
|
|
14
|
-
|
|
23
|
+
|
|
24
|
+
let nuevoUsuario = JSON.parse(sessionStorage.getItem("nuevoRegistro"));
|
|
25
|
+
let upperCaseLetters = /[A-Z]/g;
|
|
26
|
+
let numbers = /[0-9]/g;
|
|
27
|
+
let specialChar = /['!','@','#','$','%','^','&','*']/g;
|
|
28
|
+
|
|
29
|
+
// on passwordFinal update
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
passwordFinal === repeatedPassword
|
|
32
|
+
? setPasswordMatches(true)
|
|
33
|
+
: setPasswordMatches(false);
|
|
34
|
+
passwordFinal.length < 8
|
|
35
|
+
? setPasswordToShort(true)
|
|
36
|
+
: setPasswordToShort(false);
|
|
37
|
+
}, [passwordFinal, repeatedPassword]);
|
|
38
|
+
|
|
39
|
+
// on repeatedPassword update
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
passwordFinal === repeatedPassword
|
|
42
|
+
? setPasswordMatches(true)
|
|
43
|
+
: setPasswordMatches(false);
|
|
44
|
+
repeatedPassword === ""
|
|
45
|
+
? setEmptyConfirmPassword(true)
|
|
46
|
+
: setEmptyConfirmPassword(false);
|
|
47
|
+
}, [passwordFinal, repeatedPassword]);
|
|
48
|
+
|
|
49
|
+
const updateInfo = (e, newValue) => {
|
|
15
50
|
e.preventDefault();
|
|
16
51
|
const password = document.querySelector("#newPasswordInput").value;
|
|
17
52
|
password.length < 8 ? setEmptyPassword(true) : setEmptyPassword(false);
|
|
@@ -26,7 +61,43 @@ export const RegistrationSecondStep = () => {
|
|
|
26
61
|
} else {
|
|
27
62
|
setMatchPasswords(false);
|
|
28
63
|
}
|
|
64
|
+
switch (e.target.id) {
|
|
65
|
+
case "passwordInput":
|
|
66
|
+
setPasswordStrenght(0);
|
|
67
|
+
if (newValue.length > 8) {
|
|
68
|
+
setPasswordStrenght((passwordStrenght) => passwordStrenght + 1);
|
|
69
|
+
}
|
|
70
|
+
//Verificar si la contraseña contiene mayuscula, numeros y un caracter especial
|
|
71
|
+
newValue.match(upperCaseLetters) &&
|
|
72
|
+
setPasswordStrenght((passwordStrenght) => passwordStrenght + 1);
|
|
73
|
+
newValue.match(numbers) &&
|
|
74
|
+
setPasswordStrenght((passwordStrenght) => passwordStrenght + 1);
|
|
75
|
+
newValue.match(specialChar) &&
|
|
76
|
+
setPasswordStrenght((passwordStrenght) => passwordStrenght + 1);
|
|
77
|
+
//Actualizar value de la contraseña y guardar en sessionStorage
|
|
78
|
+
setPasswordFinal(newValue);
|
|
79
|
+
nuevoUsuario.password = newValue;
|
|
80
|
+
sessionStorage.setItem("nuevoRegistro", JSON.stringify(nuevoUsuario));
|
|
81
|
+
break;
|
|
82
|
+
case "confirmPasswordInput":
|
|
83
|
+
setRepeatedPassword(newValue);
|
|
84
|
+
break;
|
|
85
|
+
default:
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
const validateForm = (evt) => {
|
|
90
|
+
evt.preventDefault();
|
|
91
|
+
setShowErrors(true);
|
|
92
|
+
let valid = true;
|
|
93
|
+
passwordToShort && (valid = false);
|
|
94
|
+
emptyConfirmPassword && (valid = false);
|
|
95
|
+
!passwordMatches && (valid = false);
|
|
96
|
+
!termsCheck && (valid = false);
|
|
97
|
+
!privacyCheck && (valid = false);
|
|
98
|
+
valid && props.setPaso(3);
|
|
29
99
|
};
|
|
100
|
+
|
|
30
101
|
const loginRight = [
|
|
31
102
|
<LogoImage key="1" />,
|
|
32
103
|
<div className="credenciales" key={"2"}>
|
|
@@ -42,6 +113,8 @@ export const RegistrationSecondStep = () => {
|
|
|
42
113
|
emptyConfirmPassword={emptyConfirmPassword}
|
|
43
114
|
matchPasswords={matchPasswords}
|
|
44
115
|
textTittle={"Ingresa tus credenciales"}
|
|
116
|
+
onChange={(e) => updateInfo(e, e.target.value)}
|
|
117
|
+
required={"required"}
|
|
45
118
|
/>,
|
|
46
119
|
<label className="label-terms" key={"4"}>Términos y condiciones</label>,
|
|
47
120
|
<div className="checkbox-terms" key={"5"}>
|
|
@@ -8,6 +8,9 @@ export const TagAndInput = ({
|
|
|
8
8
|
value,
|
|
9
9
|
inputPlaceHolder,
|
|
10
10
|
inputId,
|
|
11
|
+
required,
|
|
12
|
+
onChange,
|
|
13
|
+
defaultValue,
|
|
11
14
|
}) => {
|
|
12
15
|
return (
|
|
13
16
|
<Container
|
|
@@ -21,6 +24,9 @@ export const TagAndInput = ({
|
|
|
21
24
|
inputType={inputType}
|
|
22
25
|
inputValue={value}
|
|
23
26
|
inputPlaceholder={inputPlaceHolder}
|
|
27
|
+
required={required}
|
|
28
|
+
onChange={onChange}
|
|
29
|
+
defaultValue={defaultValue}
|
|
24
30
|
/>
|
|
25
31
|
</Container>
|
|
26
32
|
);
|
|
@@ -8,11 +8,58 @@ import { GeneralInput } from "../../atoms/GeneralInput";
|
|
|
8
8
|
import { Button } from "../../atoms/GeneralButton";
|
|
9
9
|
import { validateInput, validate } from "./utils";
|
|
10
10
|
|
|
11
|
-
export const VerificationCodeResetPasswordLogin = () => {
|
|
11
|
+
export const VerificationCodeResetPasswordLogin = (props) => {
|
|
12
|
+
const [resend, setResend] = useState(false);
|
|
13
|
+
const [awsError, setAwsError] = useState("");
|
|
12
14
|
const [emptyVerificationCode, setEmptyVerificationCode] = useState(false);
|
|
13
15
|
const [inputCodeVerificationAll, setInputCodeVerificationAll] = useState();
|
|
14
16
|
const inputPositions = [1, 2, 3, 4, 5, 6];
|
|
15
17
|
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
props.confirmationError !== "" && setEmptyVerificationCode(false);
|
|
20
|
+
}, [props.confirmationError]);
|
|
21
|
+
|
|
22
|
+
const checkCode = (e) => {
|
|
23
|
+
let valid = true;
|
|
24
|
+
e.preventDefault();
|
|
25
|
+
let code = "";
|
|
26
|
+
if (awsError === "" && !emptyVerificationCode) {
|
|
27
|
+
inputPositions.map(
|
|
28
|
+
(position) =>
|
|
29
|
+
(code =
|
|
30
|
+
code +
|
|
31
|
+
document.querySelector(`#verificationCodeInput${position}`).value)
|
|
32
|
+
);
|
|
33
|
+
if (sessionStorage.getItem("resetError")) {
|
|
34
|
+
JSON.parse(sessionStorage.getItem("confirmationCode")) === code &&
|
|
35
|
+
(valid = false);
|
|
36
|
+
}
|
|
37
|
+
sessionStorage.setItem("confirmationCode", JSON.stringify(code));
|
|
38
|
+
setEmptyVerificationCode(false);
|
|
39
|
+
valid &&
|
|
40
|
+
!sessionStorage.getItem("resetPasswordProcess") &&
|
|
41
|
+
props.setPaso(6);
|
|
42
|
+
valid &&
|
|
43
|
+
sessionStorage.getItem("resetPasswordProcess") &&
|
|
44
|
+
props.setPaso(8);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const validateResend = async (e) => {
|
|
49
|
+
e.preventDefault();
|
|
50
|
+
//const email = JSON.parse(sessionStorage.getItem("email"));
|
|
51
|
+
try {
|
|
52
|
+
await props.Auth.forgotPassword(email);
|
|
53
|
+
sessionStorage.setItem("email", JSON.stringify(email));
|
|
54
|
+
sessionStorage.setItem("resetPasswordProcess", JSON.stringify("true"));
|
|
55
|
+
props.setPaso(5);
|
|
56
|
+
setResend(true);
|
|
57
|
+
} catch (err) {
|
|
58
|
+
setAwsError(err.code);
|
|
59
|
+
console.log(err.message);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
16
63
|
useEffect(() => {
|
|
17
64
|
setInputCodeVerificationAll(
|
|
18
65
|
document.querySelectorAll("[id^='verificationCodeInput']")
|
|
@@ -29,10 +76,22 @@ export const VerificationCodeResetPasswordLogin = () => {
|
|
|
29
76
|
/>
|
|
30
77
|
</div>,
|
|
31
78
|
<div className="user" key="3">
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
79
|
+
{sessionStorage.getItem("email") && (
|
|
80
|
+
<ScreenHeader
|
|
81
|
+
text={`Ingrese el código de verificación enviado a: ${JSON.parse(
|
|
82
|
+
sessionStorage.getItem("email")
|
|
83
|
+
)}`}
|
|
84
|
+
headerType={"input-name-header"}
|
|
85
|
+
/>
|
|
86
|
+
)}
|
|
87
|
+
{!sessionStorage.getItem("email") && (
|
|
88
|
+
<ScreenHeader
|
|
89
|
+
text={`Ingrese código de verificación enviado a: ${
|
|
90
|
+
JSON.parse(sessionStorage.getItem("nuevoRegistro")).email
|
|
91
|
+
}`}
|
|
92
|
+
headerType={"input-name-header"}
|
|
93
|
+
/>
|
|
94
|
+
)}
|
|
36
95
|
<div className="verification-code">
|
|
37
96
|
{inputPositions.map((position) => (
|
|
38
97
|
<GeneralInput
|
|
@@ -49,21 +108,52 @@ export const VerificationCodeResetPasswordLogin = () => {
|
|
|
49
108
|
{emptyVerificationCode && (
|
|
50
109
|
<label>Ingrese su código de verificación</label>
|
|
51
110
|
)}
|
|
111
|
+
{sessionStorage.getItem("resetError") && (
|
|
112
|
+
<label>Código de verifiación incorrecto</label>
|
|
113
|
+
)}
|
|
114
|
+
{props.confirmationError === "LimitExceededException" &&
|
|
115
|
+
!emptyVerificationCode && (
|
|
116
|
+
<label>Haz realizado demasiados intentos, intentalo más tarde</label>
|
|
117
|
+
)}
|
|
118
|
+
{props.confirmationError === "CodeMismatchException" &&
|
|
119
|
+
!emptyVerificationCode && (
|
|
120
|
+
<label>Código de verificación incorrecto</label>
|
|
121
|
+
)}
|
|
122
|
+
{props.confirmationError === "ExpiredCodeException" &&
|
|
123
|
+
!emptyVerificationCode && (
|
|
124
|
+
<label>El código ingresado está expirado</label>
|
|
125
|
+
)}
|
|
126
|
+
{props.confirmationError === "InternalErrorException" &&
|
|
127
|
+
!emptyVerificationCode && (
|
|
128
|
+
<label>Algo salió mal, porfavor vuelva a intentarlo</label>
|
|
129
|
+
)}
|
|
130
|
+
{awsError === "LimitExceededException" && (
|
|
131
|
+
<label>Haz realizado demasiados intentos, intentalo más tarde</label>
|
|
132
|
+
)}
|
|
133
|
+
{awsError === "InternalErrorException" && (
|
|
134
|
+
<label>Algo salió mal, porfavor vuelva a intentarlo</label>
|
|
135
|
+
)}
|
|
136
|
+
{resend && awsError === "" && (
|
|
137
|
+
<label className="resendTrue">
|
|
138
|
+
Se reenvió el código de verificación correctamente
|
|
139
|
+
</label>
|
|
140
|
+
)}
|
|
52
141
|
</div>,
|
|
53
142
|
<div className="resend-code" key="4">
|
|
54
|
-
<p>Reenviar código de verificación</p>
|
|
143
|
+
<p onClick={(e) => validateResend(e)}>Reenviar código de verificación</p>
|
|
55
144
|
</div>,
|
|
56
145
|
<div className="button-center" key="5">
|
|
57
146
|
<Button
|
|
58
147
|
buttonType={"general-default-button"}
|
|
59
148
|
label={"Enviar"}
|
|
60
|
-
onClick={(e) =>
|
|
61
|
-
validate(inputCodeVerificationAll, setEmptyVerificationCode)
|
|
62
|
-
|
|
149
|
+
onClick={(e) => {
|
|
150
|
+
validate(inputCodeVerificationAll, setEmptyVerificationCode);
|
|
151
|
+
checkCode(e);
|
|
152
|
+
}}
|
|
63
153
|
/>
|
|
64
154
|
</div>,
|
|
65
155
|
<div className="reset-password" key="6">
|
|
66
|
-
<p>Regresar...</p>
|
|
156
|
+
<p onClick={() => props.setPaso(10)}>Regresar...</p>
|
|
67
157
|
</div>,
|
|
68
158
|
];
|
|
69
159
|
return (
|