contentoh-components-library 21.0.23 → 21.0.27

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.
Files changed (57) hide show
  1. package/dist/components/{molecules/Login/Login.stories.js → atoms/Loading/Loading.stories.js} +7 -7
  2. package/dist/components/atoms/Loading/index.js +27 -0
  3. package/dist/components/atoms/Loading/styles.js +18 -0
  4. package/dist/components/molecules/EmailResetPasswordLogin/EmailResetPasswordLogin.stories.js +28 -0
  5. package/dist/components/molecules/EmailResetPasswordLogin/index.js +159 -0
  6. package/dist/components/molecules/EmailResetPasswordLogin/styles.js +20 -0
  7. package/dist/components/molecules/RegistrationFirstStep/RegistrationFirstStep.stories.js +28 -0
  8. package/dist/components/molecules/RegistrationFirstStep/index.js +371 -0
  9. package/dist/components/molecules/RegistrationFirstStep/styles.js +20 -0
  10. package/dist/components/molecules/RegistrationSecondStep/RegistrationSecondStep.stories.js +28 -0
  11. package/dist/components/molecules/RegistrationSecondStep/index.js +156 -0
  12. package/dist/components/molecules/RegistrationSecondStep/styles.js +20 -0
  13. package/dist/components/molecules/RegistrationThirdStep/RegistrationThirdStep.stories.js +28 -0
  14. package/dist/components/molecules/RegistrationThirdStep/index.js +161 -0
  15. package/dist/components/molecules/RegistrationThirdStep/styles.js +20 -0
  16. package/dist/components/molecules/SignInLogin/SignInLogin.stories.js +28 -0
  17. package/dist/components/molecules/SignInLogin/index.js +288 -0
  18. package/dist/components/molecules/SignInLogin/styles.js +20 -0
  19. package/dist/components/molecules/VerificationCodeResetPasswordLogin/VerificationCodeResetPasswordLogin.stories.js +28 -0
  20. package/dist/components/molecules/VerificationCodeResetPasswordLogin/index.js +104 -0
  21. package/dist/components/molecules/VerificationCodeResetPasswordLogin/styles.js +20 -0
  22. package/dist/components/molecules/VerificationCodeResetPasswordLogin/utils.js +69 -0
  23. package/dist/components/organisms/ChangePassword/ChangePassword.stories.js +28 -0
  24. package/dist/components/organisms/ChangePassword/index.js +113 -0
  25. package/dist/components/organisms/ChangePassword/styles.js +18 -0
  26. package/dist/index.js +150 -46
  27. package/package.json +4 -2
  28. package/src/components/atoms/Loading/Loading.stories.js +10 -0
  29. package/src/components/atoms/Loading/index.js +13 -0
  30. package/src/components/atoms/Loading/styles.js +57 -0
  31. package/src/components/molecules/EmailResetPasswordLogin/EmailResetPasswordLogin.stories.js +11 -0
  32. package/src/components/molecules/EmailResetPasswordLogin/index.js +87 -0
  33. package/src/components/molecules/EmailResetPasswordLogin/styles.js +23 -0
  34. package/src/components/molecules/RegistrationFirstStep/RegistrationFirstStep.stories.js +11 -0
  35. package/src/components/molecules/RegistrationFirstStep/index.js +259 -0
  36. package/src/components/molecules/RegistrationFirstStep/styles.js +81 -0
  37. package/src/components/molecules/RegistrationSecondStep/RegistrationSecondStep.stories.js +11 -0
  38. package/src/components/molecules/RegistrationSecondStep/index.js +97 -0
  39. package/src/components/molecules/RegistrationSecondStep/styles.js +59 -0
  40. package/src/components/molecules/RegistrationThirdStep/RegistrationThirdStep.stories.js +11 -0
  41. package/src/components/molecules/RegistrationThirdStep/index.js +109 -0
  42. package/src/components/molecules/RegistrationThirdStep/styles.js +44 -0
  43. package/src/components/molecules/SignInLogin/SignInLogin.stories.js +11 -0
  44. package/src/components/molecules/SignInLogin/index.js +201 -0
  45. package/src/components/molecules/{Login → SignInLogin}/styles.js +1 -0
  46. package/src/components/molecules/VerificationCodeResetPasswordLogin/VerificationCodeResetPasswordLogin.stories.js +11 -0
  47. package/src/components/molecules/VerificationCodeResetPasswordLogin/index.js +78 -0
  48. package/src/components/molecules/VerificationCodeResetPasswordLogin/styles.js +49 -0
  49. package/src/components/molecules/VerificationCodeResetPasswordLogin/utils.js +56 -0
  50. package/src/components/organisms/ChangePassword/ChangePassword.stories.js +11 -0
  51. package/src/components/organisms/ChangePassword/index.js +63 -0
  52. package/src/components/organisms/ChangePassword/styles.js +16 -0
  53. package/src/index.js +17 -9
  54. package/dist/components/molecules/Login/index.js +0 -142
  55. package/dist/components/molecules/Login/styles.js +0 -20
  56. package/src/components/molecules/Login/Login.stories.js +0 -11
  57. package/src/components/molecules/Login/index.js +0 -79
@@ -0,0 +1,59 @@
1
+ import styled from "styled-components";
2
+ import { FontFamily, GlobalColors } from "../../../global-files/variables";
3
+
4
+ export const Container = styled.div`
5
+ display: flex;
6
+ width: 50%;
7
+ height: 100vh;
8
+ .button-end {
9
+ text-align: end;
10
+ .general-default-button {
11
+ width: 160px;
12
+ }
13
+ & + * {
14
+ margin-top: 10px;
15
+ }
16
+ }
17
+ .progress-bar {
18
+ width: 100%;
19
+ height: 8px;
20
+ display: flex;
21
+ justify-content: space-between;
22
+ .progress-bar-first-step-check {
23
+ width: 33.33%;
24
+ background-color: ${GlobalColors.exported};
25
+ }
26
+ .progress-bar-second-step {
27
+ width: 33.33%;
28
+ background-color: rgb(196, 196, 196);
29
+ }
30
+ .progress-bar-registration {
31
+ background-color: rgb(226, 226, 226);
32
+ width: 33.33%;
33
+ }
34
+ }
35
+ .date-header {
36
+ margin-left: 33.33%;
37
+ }
38
+ .checkbox-terms {
39
+ display: flex;
40
+ margin-bottom: 5px;
41
+ input {
42
+ cursor: pointer;
43
+ & + * {
44
+ margin-left: 15px;
45
+ }
46
+ }
47
+ }
48
+ .label-terms {
49
+ color: rgb(129, 115, 147);
50
+ font-size: 13px;
51
+ line-height: 24px;
52
+ font-weight: 700;
53
+ cursor: pointer;
54
+ margin-left: 25px;
55
+ & + * {
56
+ margin-top: 5px;
57
+ }
58
+ }
59
+ `;
@@ -0,0 +1,11 @@
1
+ import { RegistrationThirdStep } from "./index";
2
+
3
+ export default {
4
+ title: "Components/molecules/RegistrationThirdStep",
5
+ component: RegistrationThirdStep,
6
+ };
7
+ const Template = (args) => <RegistrationThirdStep {...args} />;
8
+
9
+ export const RegistrationThirdStepDefault = Template.bind({});
10
+
11
+ RegistrationThirdStepDefault.args = {};
@@ -0,0 +1,109 @@
1
+ import { Container } from "./styles";
2
+ import { GradientPanel } from "../../atoms/GradientPanel";
3
+ import { useState } from "react";
4
+ import { LogoImage } from "../../atoms/LogoImage";
5
+ import { ScreenHeader } from "../../atoms/ScreenHeader";
6
+ import { GlobalColors, FontFamily } from "../../../global-files/variables";
7
+ import { TagAndInput } from "../../molecules/TagAndInput";
8
+ import { Button } from "../../atoms/GeneralButton";
9
+
10
+ export const RegistrationThirdStep = () => {
11
+ const [emptyCommercialName, setEmptyCommercialName] = useState(false);
12
+ const [emptyBussinesName, setEmptyBussinesName] = useState(false);
13
+ const [emptyRFC, setEmptyRFC] = useState(false);
14
+ const [emptyFiscalAddress, setEmptyFiscalAddress] = useState(false);
15
+ const validate = async (e) => {
16
+ e.preventDefault();
17
+ const commercialName = document.querySelector("#commercialNameInput").value;
18
+ const bussinesName = document.querySelector("#bussinesNameInput").value;
19
+ const RFC = document.querySelector("#rfcInput").value;
20
+ const FiscalAddress = document.querySelector("#fiscalAddressInput").value;
21
+ commercialName === ""
22
+ ? setEmptyCommercialName(true)
23
+ : setEmptyCommercialName(false);
24
+ bussinesName === ""
25
+ ? setEmptyBussinesName(true)
26
+ : setEmptyBussinesName(false);
27
+ RFC === "" ? setEmptyRFC(true) : setEmptyRFC(false);
28
+ FiscalAddress === ""
29
+ ? setEmptyFiscalAddress(true)
30
+ : setEmptyFiscalAddress(false);
31
+ };
32
+ const loginRight = [
33
+ <LogoImage key="1" />,
34
+ <div className="credenciales" key={"2"}>
35
+ <ScreenHeader
36
+ fontFamily={FontFamily.AvenirNext}
37
+ color={GlobalColors.s5}
38
+ text={"Ingresa tus credenciales"}
39
+ />
40
+ </div>,
41
+ <div className="user" key="3">
42
+ <TagAndInput
43
+ inputType={"text"}
44
+ inputId={"commercialNameInput"}
45
+ label={"Nombre comercial"}
46
+ inputPlaceHolder={"Nombre comercial"}
47
+ />
48
+ {emptyCommercialName && (
49
+ <label>Ingrese el nombre comercial de la empresa</label>
50
+ )}
51
+ <TagAndInput
52
+ inputType={"text"}
53
+ inputId={"bussinesNameInput"}
54
+ label={"Razón social"}
55
+ inputPlaceHolder={"Razón social"}
56
+ />
57
+ {emptyBussinesName && (
58
+ <label>Ingrese la razón social de la empresa</label>
59
+ )}
60
+ <TagAndInput
61
+ inputType={"text"}
62
+ inputId={"rfcInput"}
63
+ label={"RFC"}
64
+ inputPlaceHolder={"RFC"}
65
+ />
66
+ {emptyRFC && <label>El RFC es requerido</label>}
67
+ <TagAndInput
68
+ inputType={"text"}
69
+ inputId={"fiscalAddressInput"}
70
+ label={"Direccion fiscal"}
71
+ inputPlaceHolder={"Dirección fiscal"}
72
+ />
73
+ {emptyFiscalAddress && (
74
+ <label>Ingrese la direccion fiscal de la empresa</label>
75
+ )}
76
+ </div>,
77
+ <div className="button-end" key="4">
78
+ <Button
79
+ buttonType={"general-default-button"}
80
+ label={"Enviar"}
81
+ onClick={(e) => validate(e)}
82
+ />
83
+ </div>,
84
+ <div className="progress-bar" key="5">
85
+ <div className="progress-bar-step-check"></div>
86
+ <div className="progress-bar-registration"></div>
87
+ </div>,
88
+ <ScreenHeader
89
+ text={"Paso 3"}
90
+ headerType={"date-header"}
91
+ color={GlobalColors.s4}
92
+ key="6"
93
+ />,
94
+ <div className="new-login" key="7">
95
+ <p className="pre-registro">
96
+ ¿Ya tienes una cuenta?<span> Inicia Sesión</span>
97
+ </p>
98
+ </div>,
99
+ ];
100
+ return (
101
+ <Container>
102
+ <GradientPanel
103
+ componentsArray={loginRight}
104
+ panelType={"home-login"}
105
+ panelColor={GlobalColors.white}
106
+ />
107
+ </Container>
108
+ );
109
+ };
@@ -0,0 +1,44 @@
1
+ import styled from "styled-components";
2
+ import { FontFamily, GlobalColors } from "../../../global-files/variables";
3
+
4
+ export const Container = styled.div`
5
+ display: flex;
6
+ width: 50%;
7
+ height: 100%;
8
+ .user {
9
+ .input-name-header {
10
+ margin-top: 10px;
11
+ }
12
+ }
13
+ .button-end {
14
+ text-align: end;
15
+ .general-default-button {
16
+ width: 160px;
17
+ }
18
+ & + * {
19
+ margin-top: 10px;
20
+ }
21
+ }
22
+ .progress-bar {
23
+ width: 100%;
24
+ height: 8px;
25
+ display: flex;
26
+ justify-content: space-between;
27
+ .progress-bar-step-check {
28
+ width: 66.66%;
29
+ background-color: ${GlobalColors.exported};
30
+ }
31
+ .progress-bar-registration {
32
+ background-color: rgb(196, 196, 196);
33
+ width: 33.33%;
34
+ }
35
+ }
36
+ .date-header {
37
+ margin-left: 66.66%;
38
+ .new-login {
39
+ & + * {
40
+ margin-top: 20px;
41
+ }
42
+ }
43
+ }
44
+ `;
@@ -0,0 +1,11 @@
1
+ import { SignInLogin } from "./index";
2
+
3
+ export default {
4
+ title: "Components/molecules/SignInLogin",
5
+ component: SignInLogin,
6
+ };
7
+
8
+ const Template = (args) => <SignInLogin {...args} />;
9
+
10
+ export const SignInLoginDefault = Template.bind({});
11
+ SignInLoginDefault.args = {};
@@ -0,0 +1,201 @@
1
+ import { Container } from "./styles";
2
+ import { LogoImage } from "../../atoms/LogoImage/index";
3
+ import { ScreenHeader } from "../../atoms/ScreenHeader/index";
4
+ import { Button } from "../../atoms/GeneralButton/index";
5
+ import { CheckBox } from "../../atoms/CheckBox/index";
6
+ import { TagAndInput } from "../TagAndInput";
7
+ import { FontFamily, GlobalColors } from "../../../global-files/variables";
8
+ import { useState, useEffect } from "react";
9
+ import { Loading } from "../../atoms/Loading";
10
+ import { Redirect } from "react-router-dom";
11
+
12
+ export const SignInLogin = (props) => {
13
+ const [emptyEmail, setEmptyEmail] = useState(false);
14
+ const [invalidEmail, setInvalidEmail] = useState(false);
15
+ const [emptyPassword, setEmptyPassword] = useState(false);
16
+ const [showErrors, setShowErrors] = useState(true);
17
+ const [signInError, setSignInError] = useState("");
18
+ const [loading, setLoading] = useState(false);
19
+ const [upgradePlanRedirect, setUpgradePlanRedirect] = useState(false);
20
+ const validate = async (e) => {
21
+ setSignInError("");
22
+ setShowErrors(true);
23
+ e.preventDefault();
24
+ let valid = true;
25
+ const email = document.querySelector("#emailInput").value;
26
+ const password = document.querySelector("#passwordInput").value;
27
+ !/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(
28
+ email
29
+ )
30
+ ? setInvalidEmail(true)
31
+ : setInvalidEmail(false);
32
+ if (email === "") {
33
+ valid = false;
34
+ setEmptyEmail(true);
35
+ } else {
36
+ setEmptyEmail(false);
37
+ }
38
+ if (password === "") {
39
+ valid = false;
40
+ setEmptyPassword(true);
41
+ } else {
42
+ setEmptyPassword(false);
43
+ }
44
+ if (valid) {
45
+ try {
46
+ setLoading(true);
47
+ const session = await Auth.signIn(email, password);
48
+ if (session.challengeName === "NEW_PASSWORD_REQUIRED") {
49
+ props.setUser(session);
50
+ props.setPaso(8);
51
+ } else {
52
+ const userGroup =
53
+ session.signInUserSession.accessToken.payload["cognito:groups"];
54
+ const response = await axios.get(
55
+ process.env.REACT_APP_USER_ENDPOINT,
56
+ {
57
+ headers: {
58
+ Authorization: session.signInUserSession.idToken.jwtToken,
59
+ },
60
+ }
61
+ );
62
+ const userGroupValue =
63
+ typeof userGroup === "string" ? userGroup : userGroup[0];
64
+ if (userGroupValue === "usuario_contentoh") {
65
+ sessionStorage.setItem("auth", true);
66
+ sessionStorage.setItem(
67
+ "jwt",
68
+ session.signInUserSession.idToken.jwtToken
69
+ );
70
+ const user = JSON.parse(response.data.body).data[0];
71
+ const company = JSON.parse(response.data.body).data[1];
72
+ caches.keys().then((names) => {
73
+ names.forEach((name) => {
74
+ caches.delete(name);
75
+ });
76
+ });
77
+ user.src = `https://${
78
+ process.env.REACT_APP_IMAGES_PROFILE_BUCKET
79
+ }.s3.amazonaws.com/id-${user.id_user}/${
80
+ user.id_user
81
+ }.png?${new Date().getTime()}`;
82
+ sessionStorage.setItem("user", JSON.stringify(user));
83
+ sessionStorage.setItem("company", JSON.stringify(company));
84
+ setUpgradePlanRedirect(true);
85
+ } else {
86
+ setSignInError("NotAuthorizedException");
87
+ setLoading(false);
88
+ }
89
+ }
90
+ } catch (error) {
91
+ console.log(error);
92
+ setLoading(false);
93
+ if (error.code === "NotAuthorizedException") {
94
+ setSignInError("NotAuthorizedException");
95
+ } else if (error.code === "UserNotConfirmedException") {
96
+ sessionStorage.setItem(
97
+ "email",
98
+ JSON.stringify(
99
+ document.querySelector("#usernameInput").value.trim()
100
+ )
101
+ );
102
+ sessionStorage.setItem("email", JSON.stringify(email));
103
+ props.setPaso(5);
104
+ } else {
105
+ setSignInError("Error");
106
+ }
107
+ }
108
+ }
109
+ };
110
+ useEffect(() => {
111
+ sessionStorage.getItem("resetPasswordProcess") &&
112
+ sessionStorage.removeItem("resetPasswordProcess");
113
+ }, []);
114
+ return loading ? (
115
+ <Loading />
116
+ ) : (
117
+ <>
118
+ <Container className={"home-login"}>
119
+ <div className="main-container">
120
+ <LogoImage />
121
+ <div className="credenciales">
122
+ <ScreenHeader
123
+ fontFamily={FontFamily.AvenirNext}
124
+ color={GlobalColors.s5}
125
+ text={"Ingresa tus credenciales"}
126
+ />
127
+ </div>
128
+ <div className="user">
129
+ <TagAndInput
130
+ inputType={"text"}
131
+ label={"Nombre de usuario"}
132
+ inputPlaceHolder={"username@contentoh.com"}
133
+ inputId={"emailInput"}
134
+ />
135
+ </div>
136
+ {showErrors && emptyEmail && <label>Ingrese su correo</label>}
137
+ {invalidEmail && !emptyEmail && (
138
+ <label>Ingrese un correo válido</label>
139
+ )}
140
+ <div className="password">
141
+ <TagAndInput
142
+ inputType={"password"}
143
+ label={"Contraseña"}
144
+ inputPlaceHolder={"Escribe tu contraseña"}
145
+ inputId={"passwordInput"}
146
+ />
147
+ </div>
148
+ {showErrors && emptyPassword && <label>Ingrese su contraseña</label>}
149
+ <div className="select">
150
+ <CheckBox
151
+ label={"Mantener sesión activada"}
152
+ id={"chk-default"}
153
+ className="active-left"
154
+ />
155
+ <p onClick={() => props.setPaso(10)} className="active-right">Olvide mi contraseña</p>
156
+ </div>
157
+ {showErrors && signInError === "NotAuthorizedException" && (
158
+ <label>Correo o contraseña incorrectos</label>
159
+ )}
160
+ {showErrors && signInError === "Error" && (
161
+ <label>Ha habido un problema al iniciar sesión</label>
162
+ )}
163
+ <div className="button-right">
164
+ <Button
165
+ buttonType={"general-default-button"}
166
+ label={"Iniciar sesión"}
167
+ onClick={(e) => validate(e)}
168
+ />
169
+ </div>
170
+ <div className="new-login">
171
+ <p
172
+ className="pre-registro"
173
+ onClick={() => {
174
+ props.setPaso(1);
175
+ sessionStorage.setItem(
176
+ "nuevoRegistro",
177
+ JSON.stringify({
178
+ name: "",
179
+ lastName: "",
180
+ email: "",
181
+ position: "",
182
+ country: "",
183
+ phone: "",
184
+ commercialName: "",
185
+ companyName: "",
186
+ rfc: "",
187
+ adress: "",
188
+ })
189
+ );
190
+ sessionStorage.setItem("countryCode", JSON.stringify("+52"));
191
+ }}
192
+ >
193
+ ¿Aún no tienes cuenta?<span> Regístrate</span>
194
+ </p>
195
+ </div>
196
+ </div>
197
+ </Container>
198
+ {upgradePlanRedirect && <Redirect to={{ pathname: "/dashboard" }} />}
199
+ </>
200
+ );
201
+ };
@@ -5,6 +5,7 @@ export const Container = styled.div`
5
5
  background: "white";
6
6
  display: flex;
7
7
  height: 100%;
8
+ width: 50%;
8
9
  justify-content: center;
9
10
  align-items: center;
10
11
  label {
@@ -0,0 +1,11 @@
1
+ import { VerificationCodeResetPasswordLogin } from "./index";
2
+
3
+ export default {
4
+ title: "Components/molecules/VerificationCodeResetPasswordLogin",
5
+ component: VerificationCodeResetPasswordLogin,
6
+ };
7
+ const Template = (args) => <VerificationCodeResetPasswordLogin {...args} />;
8
+
9
+ export const VerificationCodeResetPasswordLoginDefault = Template.bind({});
10
+
11
+ VerificationCodeResetPasswordLoginDefault.args = {};
@@ -0,0 +1,78 @@
1
+ import { Container } from "./styles";
2
+ import { GradientPanel } from "../../atoms/GradientPanel";
3
+ import { useEffect, useState } from "react";
4
+ import { LogoImage } from "../../atoms/LogoImage";
5
+ import { ScreenHeader } from "../../atoms/ScreenHeader";
6
+ import { GlobalColors, FontFamily } from "../../../global-files/variables";
7
+ import { GeneralInput } from "../../atoms/GeneralInput";
8
+ import { Button } from "../../atoms/GeneralButton";
9
+ import { validateInput, validate } from "./utils";
10
+
11
+ export const VerificationCodeResetPasswordLogin = () => {
12
+ const [emptyVerificationCode, setEmptyVerificationCode] = useState(false);
13
+ const [inputCodeVerificationAll, setInputCodeVerificationAll] = useState();
14
+ const inputPositions = [1, 2, 3, 4, 5, 6];
15
+
16
+ useEffect(() => {
17
+ setInputCodeVerificationAll(
18
+ document.querySelectorAll("[id^='verificationCodeInput']")
19
+ );
20
+ }, []);
21
+
22
+ const loginRight = [
23
+ <LogoImage key="1" />,
24
+ <div className="credenciales" key={"2"}>
25
+ <ScreenHeader
26
+ fontFamily={FontFamily.AvenirNext}
27
+ color={GlobalColors.s5}
28
+ text={"Ingresa tus credenciales"}
29
+ />
30
+ </div>,
31
+ <div className="user" key="3">
32
+ <ScreenHeader
33
+ text={"Ingresa el código de verificación enviado a:"}
34
+ headerType={"input-name-header"}
35
+ />
36
+ <div className="verification-code">
37
+ {inputPositions.map((position) => (
38
+ <GeneralInput
39
+ inputId={`verificationCodeInput${position}`}
40
+ inputType={"text"}
41
+ inputPlaceholder={"X"}
42
+ validateInput={validateInput}
43
+ inputsArray={inputCodeVerificationAll}
44
+ position={position}
45
+ maxLength="1"
46
+ />
47
+ ))}
48
+ </div>
49
+ {emptyVerificationCode && (
50
+ <label>Ingrese su código de verificación</label>
51
+ )}
52
+ </div>,
53
+ <div className="resend-code" key="4">
54
+ <p>Reenviar código de verificación</p>
55
+ </div>,
56
+ <div className="button-center" key="5">
57
+ <Button
58
+ buttonType={"general-default-button"}
59
+ label={"Enviar"}
60
+ onClick={(e) =>
61
+ validate(inputCodeVerificationAll, setEmptyVerificationCode)
62
+ }
63
+ />
64
+ </div>,
65
+ <div className="reset-password" key="6">
66
+ <p>Regresar...</p>
67
+ </div>,
68
+ ];
69
+ return (
70
+ <Container>
71
+ <GradientPanel
72
+ componentsArray={loginRight}
73
+ panelType={"home-login"}
74
+ panelColor={GlobalColors.white}
75
+ />
76
+ </Container>
77
+ );
78
+ };
@@ -0,0 +1,49 @@
1
+ import styled from "styled-components";
2
+ import { FontFamily, GlobalColors } from "../../../global-files/variables";
3
+
4
+ export const Container = styled.div`
5
+ display: flex;
6
+ height: 100%;
7
+ width: 50%;
8
+ .button-center {
9
+ text-align: center;
10
+ .general-default-button {
11
+ width: 160px;
12
+ }
13
+ }
14
+ .reset-password {
15
+ text-align: center;
16
+ margin: 15px !important;
17
+ color: ${GlobalColors.secondary_magenta};
18
+ cursor: pointer;
19
+ font-weight: bold;
20
+ font-family: ${FontFamily.Raleway};
21
+ font-size: 13px;
22
+ }
23
+ .resend-code {
24
+ margin-top: 8px !important;
25
+ color: ${GlobalColors.magenta_s2};
26
+ font-family: ${FontFamily.AvenirNext};
27
+ font-size: 11px;
28
+ text-decoration: underline rgb(228, 81, 172);
29
+ cursor: pointer;
30
+ & + * {
31
+ margin-top: 30px;
32
+ }
33
+ }
34
+ .verification-code {
35
+ display: flex;
36
+ text-align: center;
37
+ margin: auto;
38
+ margin-top: 10px;
39
+ input[type="number"]::-webkit-inner-spin-button,
40
+ input[type="number"]::-webkit-outer-spin-button {
41
+ -webkit-appearance: none;
42
+ margin: 0;
43
+ }
44
+ input {
45
+ width: 70%;
46
+ text-align: center;
47
+ }
48
+ }
49
+ `;
@@ -0,0 +1,56 @@
1
+ /**
2
+ *
3
+ * @param {event} e event received triggered by verification code input
4
+ * @param {number} index index position from the verification code(VC) input array (i.e. digit 1,2,3 etc...)
5
+ * @param {array<html nodes>} inputsArray array which contains every VC digit input (used to change focus on input change)
6
+ */
7
+ export const validateInput = (e, index, inputsArray) => {
8
+ let isValid = false;
9
+ const inputNotEmpty = e.target.value.length > 0;
10
+ if (inputNotEmpty) {
11
+ if (validateInputNumber(e) !== null) {
12
+ isValid = true;
13
+ nextInputFocus(inputsArray, index++);
14
+ }
15
+ }
16
+ return isValid ? e.target.value : "";
17
+ };
18
+
19
+ /**
20
+ *
21
+ * @param {event} e event received triggered by verification code input
22
+ * @returns {boolean} if digit is a number
23
+ */
24
+ const validateInputNumber = (e) => {
25
+ return (e.target.value || String.fromCharCode(e.keyCode)).match(/[0-9]{1}/);
26
+ };
27
+
28
+ /**
29
+ *
30
+ * @param {array<html nodes>} inputsArray array which contains every VC digit input (used to change focus on input change)
31
+ * @param {number} index index position from the verification code(VC) input array (i.e. digit 1,2,3 etc...)
32
+ * changes focus to next input if digit typed is a number and there wasn't any before
33
+ */
34
+ const nextInputFocus = (inputsArray, index) => {
35
+ const button = document.getElementsByClassName("general-default-button");
36
+
37
+ inputsArray?.length && index === inputsArray?.length
38
+ ? button[0].focus()
39
+ : inputsArray[index]?.focus();
40
+ };
41
+
42
+ /**
43
+ *
44
+ * @param {array<html nodes>} inputsArray array which contains every VC digit input (used to check if there's any empty)
45
+ * @param {function} setEmptyVerificationCode function to update flag which handles if there's an empty char
46
+ * updates emptyVerificationFlag from father component
47
+ */
48
+ export const validate = (inputsArray, setEmptyVerificationCode) => {
49
+ let contInputEmpty = 0;
50
+ inputsArray.forEach((element) => {
51
+ element.value === "" ? 0 : contInputEmpty++;
52
+ });
53
+ contInputEmpty === inputsArray.length
54
+ ? setEmptyVerificationCode(false)
55
+ : setEmptyVerificationCode(true);
56
+ };
@@ -0,0 +1,11 @@
1
+ import { ChangePassword } from "./index";
2
+
3
+ export default {
4
+ title: "Components/organisms/ChangePassword",
5
+ component: ChangePassword,
6
+ };
7
+ const Template = (args) => <ChangePassword {...args} />;
8
+
9
+ export const ChangePasswordDefault = Template.bind({});
10
+
11
+ ChangePasswordDefault.args = {};