contentoh-components-library 21.0.27 → 21.0.30

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.
@@ -29,6 +29,8 @@ var _TagAndInput = require("../../molecules/TagAndInput");
29
29
 
30
30
  var _GeneralButton = require("../../atoms/GeneralButton");
31
31
 
32
+ var _awsAmplify = require("aws-amplify");
33
+
32
34
  var _jsxRuntime = require("react/jsx-runtime");
33
35
 
34
36
  var EmailResetPasswordLogin = function EmailResetPasswordLogin(props) {
@@ -52,12 +54,6 @@ var EmailResetPasswordLogin = function EmailResetPasswordLogin(props) {
52
54
  awsError = _useState8[0],
53
55
  setAwsError = _useState8[1];
54
56
 
55
- var _useState9 = (0, _react.useState)(false),
56
- _useState10 = (0, _slicedToArray2.default)(_useState9, 2),
57
- upgradePlanRedirect = _useState10[0],
58
- setUpgradePlanRedirect = _useState10[1]; //upgradePlanRedirect && (<Redirect/>
59
-
60
-
61
57
  var validate = /*#__PURE__*/function () {
62
58
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(e) {
63
59
  var valid, email;
@@ -81,7 +77,7 @@ var EmailResetPasswordLogin = function EmailResetPasswordLogin(props) {
81
77
 
82
78
  _context.prev = 9;
83
79
  _context.next = 12;
84
- return Auth.forgotPassword(email);
80
+ return _awsAmplify.Auth.forgotPassword(email);
85
81
 
86
82
  case 12:
87
83
  sessionStorage.setItem("email", JSON.stringify(email));
@@ -7,10 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.RegistrationFirstStep = void 0;
9
9
 
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/asyncToGenerator"));
13
-
14
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
15
11
 
16
12
  var _styles = require("./styles");
@@ -59,68 +55,30 @@ var RegistrationFirstStep = function RegistrationFirstStep(props) {
59
55
  emptyPhone = _useState10[0],
60
56
  setEmptyPhone = _useState10[1];
61
57
 
62
- var _useState11 = (0, _react.useState)(false),
58
+ var _useState11 = (0, _react.useState)(true),
63
59
  _useState12 = (0, _slicedToArray2.default)(_useState11, 2),
64
- invalidEmail = _useState12[0],
65
- setInvalidEmail = _useState12[1];
66
-
67
- var validate = /*#__PURE__*/function () {
68
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(e) {
69
- var name, lastName, email, job, phone;
70
- return _regenerator.default.wrap(function _callee$(_context) {
71
- while (1) {
72
- switch (_context.prev = _context.next) {
73
- case 0:
74
- e.preventDefault();
75
- name = document.querySelector("#nameInput").value;
76
- lastName = document.querySelector("#lastNameInput").value;
77
- email = document.querySelector("#emailInput").value;
78
- job = document.querySelector("#jobInput").value;
79
- phone = document.querySelector("#phoneInput").value;
80
- name === "" ? setEmptyName(true) : setEmptyName(false);
81
- lastName === "" ? setEmptyLastName(true) : setEmptyLastName(false);
82
- email === "" ? setEmptyEmail(true) : setEmptyEmail(false);
83
- job === "" ? setEmptyJob(true) : setEmptyJob(false);
84
- phone === "" ? setEmptyPhone(true) : setEmptyPhone(false);
85
- !/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(email) ? setInvalidEmail(true) : setInvalidEmail(false);
86
-
87
- case 12:
88
- case "end":
89
- return _context.stop();
90
- }
91
- }
92
- }, _callee);
93
- }));
60
+ emptyCountry = _useState12[0],
61
+ setEmptyCountry = _useState12[1];
94
62
 
95
- return function validate(_x) {
96
- return _ref.apply(this, arguments);
97
- };
98
- }();
99
-
100
- var _useState13 = (0, _react.useState)(true),
63
+ var _useState13 = (0, _react.useState)(false),
101
64
  _useState14 = (0, _slicedToArray2.default)(_useState13, 2),
102
- emptyCountry = _useState14[0],
103
- setEmptyCountry = _useState14[1];
65
+ showErrors = _useState14[0],
66
+ setShowErrors = _useState14[1];
104
67
 
105
68
  var _useState15 = (0, _react.useState)(false),
106
69
  _useState16 = (0, _slicedToArray2.default)(_useState15, 2),
107
- showErrors = _useState16[0],
108
- setShowErrors = _useState16[1];
70
+ regError = _useState16[0],
71
+ setRegError = _useState16[1];
109
72
 
110
73
  var _useState17 = (0, _react.useState)(false),
111
74
  _useState18 = (0, _slicedToArray2.default)(_useState17, 2),
112
- regError = _useState18[0],
113
- setRegError = _useState18[1];
75
+ phoneFormatError = _useState18[0],
76
+ setPhoneFormatError = _useState18[1];
114
77
 
115
78
  var _useState19 = (0, _react.useState)(false),
116
79
  _useState20 = (0, _slicedToArray2.default)(_useState19, 2),
117
- phoneFormatError = _useState20[0],
118
- setPhoneFormatError = _useState20[1];
119
-
120
- var _useState21 = (0, _react.useState)(false),
121
- _useState22 = (0, _slicedToArray2.default)(_useState21, 2),
122
- emailFormatError = _useState22[0],
123
- setEmailFormatError = _useState22[1];
80
+ emailFormatError = _useState20[0],
81
+ setEmailFormatError = _useState20[1];
124
82
 
125
83
  (0, _react.useEffect)(function () {
126
84
  JSON.parse(sessionStorage.getItem("nuevoRegistro")).name === "" && sessionStorage.removeItem("registrationError");
@@ -130,7 +88,7 @@ var RegistrationFirstStep = function RegistrationFirstStep(props) {
130
88
  setEmptyName(false);
131
89
  setEmptyLastName(false);
132
90
  setEmptyEmail(false);
133
- setEmptyPosition(false);
91
+ setEmptyJob(false);
134
92
  setEmptyCountry(false);
135
93
  setEmptyPhone(false);
136
94
  }
@@ -143,12 +101,12 @@ var RegistrationFirstStep = function RegistrationFirstStep(props) {
143
101
  var nuevoUsuario = JSON.parse(sessionStorage.getItem("nuevoRegistro"));
144
102
 
145
103
  switch (e.target.id) {
146
- case "nombreInput":
104
+ case "nameInput":
147
105
  nuevoUsuario.name = newValue;
148
106
  newValue === "" ? setEmptyName(true) : setEmptyName(false);
149
107
  break;
150
108
 
151
- case "apellidoInput":
109
+ case "lastNameInput":
152
110
  nuevoUsuario.lastName = newValue;
153
111
  newValue === "" ? setEmptyLastName(true) : setEmptyLastName(false);
154
112
  break;
@@ -165,28 +123,28 @@ var RegistrationFirstStep = function RegistrationFirstStep(props) {
165
123
 
166
124
  break;
167
125
 
168
- case "puestoInput":
126
+ case "jobInput":
169
127
  nuevoUsuario.position = newValue;
170
- newValue === "" ? setEmptyPosition(true) : setEmptyPosition(false);
128
+ newValue === "" ? setEmptyJob(true) : setEmptyJob(false);
171
129
  break;
172
130
 
173
- case "telSelect":
131
+ case "phoneInput":
174
132
  Array.from(newValue).forEach(function (digit, i) {
175
133
  newValue.charCodeAt(i) < 48 ? setPhoneFormatError(true) : setPhoneFormatError(false);
176
134
  newValue.charCodeAt(i) > 57 ? setPhoneFormatError(true) : setPhoneFormatError(false);
177
135
  });
178
- nuevoUsuario.phone = "".concat(JSON.parse(sessionStorage.getItem("countryCode"))).concat(newValue);
136
+ nuevoUsuario.phone = "".concat(JSON.parse(sessionStorage.getItem("countryCodeSelect"))).concat(newValue);
179
137
  newValue === "" ? setEmptyPhone(true) : setEmptyPhone(false);
180
138
  break;
181
139
 
182
- case "paisSelect":
140
+ case "countrySelect":
183
141
  nuevoUsuario.country = newValue;
184
142
  newValue === "" || newValue === "Selecciona tu país" ? setEmptyCountry(true) : setEmptyCountry(false);
185
143
  break;
186
144
 
187
145
  case "countryCodeSelect":
188
146
  sessionStorage.setItem("countryCode", JSON.stringify(newValue));
189
- nuevoUsuario.phone = "".concat(JSON.parse(sessionStorage.getItem("countryCode"))).concat(document.querySelector("#telSelect").value);
147
+ nuevoUsuario.phone = "".concat(JSON.parse(sessionStorage.getItem("countryCode"))).concat(document.querySelector("#phoneInput").value);
190
148
  break;
191
149
 
192
150
  default:
@@ -203,7 +161,7 @@ var RegistrationFirstStep = function RegistrationFirstStep(props) {
203
161
  emptyName && (valid = false);
204
162
  emptyLastName && (valid = false);
205
163
  emptyEmail && (valid = false);
206
- emptyPosition && (valid = false);
164
+ emptyJob && (valid = false);
207
165
  emptyPhone && (valid = false);
208
166
  emptyCountry && (valid = false);
209
167
  phoneFormatError && (valid = false);
@@ -229,7 +187,12 @@ var RegistrationFirstStep = function RegistrationFirstStep(props) {
229
187
  inputType: "text",
230
188
  inputId: "nameInput",
231
189
  label: "Nombre",
232
- inputPlaceHolder: "Nombre"
190
+ inputPlaceHolder: "Nombre",
191
+ defaultValue: JSON.parse(sessionStorage.getItem("nuevoRegistro")).name,
192
+ required: true,
193
+ onInput: function onInput(e) {
194
+ return updateInfo(e, e.target.value);
195
+ }
233
196
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_TagAndInput.TagAndInput, {
234
197
  inputType: "text",
235
198
  inputId: "lastNameInput",
@@ -264,6 +227,7 @@ var RegistrationFirstStep = function RegistrationFirstStep(props) {
264
227
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("select", {
265
228
  name: "select",
266
229
  className: "phone-options",
230
+ id: "countryCodeSelect",
267
231
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
268
232
  children: "+52"
269
233
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
@@ -296,6 +260,7 @@ var RegistrationFirstStep = function RegistrationFirstStep(props) {
296
260
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("select", {
297
261
  name: "select",
298
262
  className: "country-options",
263
+ id: "countrySelect",
299
264
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
300
265
  value: "value1",
301
266
  selected: true,
@@ -33,6 +33,10 @@ var _Loading = require("../../atoms/Loading");
33
33
 
34
34
  var _reactRouterDom = require("react-router-dom");
35
35
 
36
+ var _awsAmplify = require("aws-amplify");
37
+
38
+ var _axios = _interopRequireDefault(require("axios"));
39
+
36
40
  var _jsxRuntime = require("react/jsx-runtime");
37
41
 
38
42
  var SignInLogin = function SignInLogin(props) {
@@ -108,7 +112,7 @@ var SignInLogin = function SignInLogin(props) {
108
112
  _context.prev = 10;
109
113
  setLoading(true);
110
114
  _context.next = 14;
111
- return Auth.signIn(email, password);
115
+ return props.Auth.signIn(email, password);
112
116
 
113
117
  case 14:
114
118
  session = _context.sent;
@@ -126,7 +130,7 @@ var SignInLogin = function SignInLogin(props) {
126
130
  case 20:
127
131
  userGroup = session.signInUserSession.accessToken.payload["cognito:groups"];
128
132
  _context.next = 23;
129
- return axios.get(process.env.REACT_APP_USER_ENDPOINT, {
133
+ return _axios.default.get(process.env.REACT_APP_USER_ENDPOINT, {
130
134
  headers: {
131
135
  Authorization: session.signInUserSession.idToken.jwtToken
132
136
  }
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.0.27",
3
+ "version": "21.0.30",
4
4
  "dependencies": {
5
+ "@aws-amplify/auth": "^4.5.4-unstable.3",
5
6
  "@babel/runtime": "^7.17.2",
6
7
  "@storybook/addon-postcss": "^2.0.0",
7
8
  "@testing-library/jest-dom": "^5.11.4",
8
9
  "@testing-library/react": "^11.1.0",
9
10
  "@testing-library/user-event": "^12.1.10",
10
- "auth": "^0.0.9",
11
+ "aws-amplify": "^4.3.22-unstable.3",
11
12
  "axios": "^0.25.0",
12
13
  "babel-preset-react-app": "^10.0.1",
13
14
  "chart.js": "^3.7.1",
@@ -69,6 +70,7 @@
69
70
  "@storybook/addon-essentials": "^6.4.1",
70
71
  "@storybook/addon-links": "^6.4.1",
71
72
  "@storybook/react": "^6.4.1",
73
+ "auth": "^0.0.9",
72
74
  "auto": "^10.36.5",
73
75
  "babel-loader": "^8.2.3",
74
76
  "chromatic": "^6.3.3",
@@ -6,14 +6,13 @@ import { ScreenHeader } from "../../atoms/ScreenHeader";
6
6
  import { GlobalColors, FontFamily } from "../../../global-files/variables";
7
7
  import { TagAndInput } from "../../molecules/TagAndInput";
8
8
  import { Button } from "../../atoms/GeneralButton";
9
+ import { Auth } from "aws-amplify";
9
10
 
10
11
  export const EmailResetPasswordLogin = (props) => {
11
12
  const [emptyEmail, setEmptyEmail] = useState(false);
12
13
  const [invalidEmail, setInvalidEmail] = useState(false);
13
14
  const [showErrors, setShowErrors] = useState(false);
14
15
  const [awsError, setAwsError] = useState("");
15
- const [upgradePlanRedirect, setUpgradePlanRedirect] = useState(false);
16
- //upgradePlanRedirect && (<Redirect/>
17
16
  const validate = async (e) => {
18
17
  let valid = true;
19
18
  setShowErrors(true);
@@ -14,28 +14,6 @@ export const RegistrationFirstStep = (props) => {
14
14
  const [emptyEmail, setEmptyEmail] = useState(false);
15
15
  const [emptyJob, setEmptyJob] = useState(false);
16
16
  const [emptyPhone, setEmptyPhone] = useState(false);
17
- const [invalidEmail, setInvalidEmail] = useState(false);
18
-
19
- const validate = async (e) => {
20
- e.preventDefault();
21
- const name = document.querySelector("#nameInput").value;
22
- const lastName = document.querySelector("#lastNameInput").value;
23
- const email = document.querySelector("#emailInput").value;
24
- const job = document.querySelector("#jobInput").value;
25
- const phone = document.querySelector("#phoneInput").value;
26
- name === "" ? setEmptyName(true) : setEmptyName(false);
27
- lastName === "" ? setEmptyLastName(true) : setEmptyLastName(false);
28
- email === "" ? setEmptyEmail(true) : setEmptyEmail(false);
29
- job === "" ? setEmptyJob(true) : setEmptyJob(false);
30
- phone === "" ? setEmptyPhone(true) : setEmptyPhone(false);
31
- !/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(
32
- email
33
- )
34
- ? setInvalidEmail(true)
35
- : setInvalidEmail(false);
36
- };
37
-
38
-
39
17
  const [emptyCountry, setEmptyCountry] = useState(true);
40
18
  const [showErrors, setShowErrors] = useState(false);
41
19
  const [regError, setRegError] = useState(false);
@@ -50,7 +28,7 @@ export const RegistrationFirstStep = (props) => {
50
28
  setEmptyName(false);
51
29
  setEmptyLastName(false);
52
30
  setEmptyEmail(false);
53
- setEmptyPosition(false);
31
+ setEmptyJob(false);
54
32
  setEmptyCountry(false);
55
33
  setEmptyPhone(false);
56
34
  }
@@ -73,11 +51,11 @@ export const RegistrationFirstStep = (props) => {
73
51
  const updateInfo = (e, newValue) => {
74
52
  let nuevoUsuario = JSON.parse(sessionStorage.getItem("nuevoRegistro"));
75
53
  switch (e.target.id) {
76
- case "nombreInput":
54
+ case "nameInput":
77
55
  nuevoUsuario.name = newValue;
78
56
  newValue === "" ? setEmptyName(true) : setEmptyName(false);
79
57
  break;
80
- case "apellidoInput":
58
+ case "lastNameInput":
81
59
  nuevoUsuario.lastName = newValue;
82
60
  newValue === "" ? setEmptyLastName(true) : setEmptyLastName(false);
83
61
  break;
@@ -94,11 +72,11 @@ export const RegistrationFirstStep = (props) => {
94
72
  setEmailFormatError(false);
95
73
  }
96
74
  break;
97
- case "puestoInput":
75
+ case "jobInput":
98
76
  nuevoUsuario.position = newValue;
99
- newValue === "" ? setEmptyPosition(true) : setEmptyPosition(false);
77
+ newValue === "" ? setEmptyJob(true) : setEmptyJob(false);
100
78
  break;
101
- case "telSelect":
79
+ case "phoneInput":
102
80
  Array.from(newValue).forEach((digit, i) => {
103
81
  newValue.charCodeAt(i) < 48
104
82
  ? setPhoneFormatError(true)
@@ -108,11 +86,11 @@ export const RegistrationFirstStep = (props) => {
108
86
  : setPhoneFormatError(false);
109
87
  });
110
88
  nuevoUsuario.phone = `${JSON.parse(
111
- sessionStorage.getItem("countryCode")
89
+ sessionStorage.getItem("countryCodeSelect")
112
90
  )}${newValue}`;
113
91
  newValue === "" ? setEmptyPhone(true) : setEmptyPhone(false);
114
92
  break;
115
- case "paisSelect":
93
+ case "countrySelect":
116
94
  nuevoUsuario.country = newValue;
117
95
  newValue === "" || newValue === "Selecciona tu país"
118
96
  ? setEmptyCountry(true)
@@ -122,7 +100,7 @@ export const RegistrationFirstStep = (props) => {
122
100
  sessionStorage.setItem("countryCode", JSON.stringify(newValue));
123
101
  nuevoUsuario.phone = `${JSON.parse(
124
102
  sessionStorage.getItem("countryCode")
125
- )}${document.querySelector("#telSelect").value}`;
103
+ )}${document.querySelector("#phoneInput").value}`;
126
104
  break;
127
105
  default:
128
106
  return;
@@ -137,7 +115,7 @@ export const RegistrationFirstStep = (props) => {
137
115
  emptyName && (valid = false);
138
116
  emptyLastName && (valid = false);
139
117
  emptyEmail && (valid = false);
140
- emptyPosition && (valid = false);
118
+ emptyJob && (valid = false);
141
119
  emptyPhone && (valid = false);
142
120
  emptyCountry && (valid = false);
143
121
  phoneFormatError && (valid = false);
@@ -161,6 +139,11 @@ export const RegistrationFirstStep = (props) => {
161
139
  inputId={"nameInput"}
162
140
  label={"Nombre"}
163
141
  inputPlaceHolder={"Nombre"}
142
+ defaultValue={
143
+ JSON.parse(sessionStorage.getItem("nuevoRegistro")).name
144
+ }
145
+ required
146
+ onInput={(e) => updateInfo(e, e.target.value)}
164
147
  />
165
148
  <TagAndInput
166
149
  inputType={"text"}
@@ -188,7 +171,7 @@ export const RegistrationFirstStep = (props) => {
188
171
  {emptyJob && <label>Ingrese su puesto</label>}
189
172
  <ScreenHeader text={"Teléfono"} headerType={"input-name-header"} />
190
173
  <div className="phone-registration-user">
191
- <select name="select" className="phone-options">
174
+ <select name="select" className="phone-options" id="countryCodeSelect">
192
175
  <option>+52</option>
193
176
  <option>+54</option>
194
177
  <option>+57</option>
@@ -207,7 +190,7 @@ export const RegistrationFirstStep = (props) => {
207
190
  </div>
208
191
  {emptyPhone && <label>Ingrese su número de teléfono</label>}
209
192
  <ScreenHeader text={"País"} headerType={"input-name-header"} />
210
- <select name="select" className="country-options">
193
+ <select name="select" className="country-options" id="countrySelect">
211
194
  <option value="value1" selected>
212
195
  Selecciona tu país
213
196
  </option>
@@ -8,6 +8,8 @@ import { FontFamily, GlobalColors } from "../../../global-files/variables";
8
8
  import { useState, useEffect } from "react";
9
9
  import { Loading } from "../../atoms/Loading";
10
10
  import { Redirect } from "react-router-dom";
11
+ import { Auth } from "aws-amplify";
12
+ import axios from "axios";
11
13
 
12
14
  export const SignInLogin = (props) => {
13
15
  const [emptyEmail, setEmptyEmail] = useState(false);
@@ -152,7 +154,9 @@ export const SignInLogin = (props) => {
152
154
  id={"chk-default"}
153
155
  className="active-left"
154
156
  />
155
- <p onClick={() => props.setPaso(10)} className="active-right">Olvide mi contraseña</p>
157
+ <p onClick={() => props.setPaso(10)} className="active-right">
158
+ Olvide mi contraseña
159
+ </p>
156
160
  </div>
157
161
  {showErrors && signInError === "NotAuthorizedException" && (
158
162
  <label>Correo o contraseña incorrectos</label>