@stokr/components-library 2.0.0-beta.21 → 2.0.0-beta.22

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.
@@ -30,11 +30,12 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
30
30
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
31
31
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
32
32
  var LoginModal = function LoginModal(props) {
33
- var _React$useState = _react.default.useState(null),
33
+ var _React$useState = _react.default.useState(),
34
34
  _React$useState2 = _slicedToArray(_React$useState, 2),
35
35
  email = _React$useState2[0],
36
36
  setemail = _React$useState2[1];
37
37
  var location = (0, _reactRouterDom.useLocation)();
38
+ var emailSetRef = _react.default.useRef(false);
38
39
  _react.default.useEffect(function () {
39
40
  //the URL will look like this: /login?email=some.email@email.com
40
41
  var search = location.search;
@@ -97,8 +98,9 @@ var LoginModal = function LoginModal(props) {
97
98
  setFieldValue(field.name, field.value, false);
98
99
  setFieldTouched(field.name);
99
100
  };
100
- if (email && values.email !== email) {
101
+ if (email && values.email !== email && !emailSetRef.current) {
101
102
  setFieldValue('email', email);
103
+ emailSetRef.current = true;
102
104
  }
103
105
 
104
106
  //hack to avoid error when autofill from browser
@@ -114,7 +116,7 @@ var LoginModal = function LoginModal(props) {
114
116
  name: "email",
115
117
  type: "email",
116
118
  label: "Your email",
117
- value: email || values.email,
119
+ value: values.email,
118
120
  onChange: onChangeWithTouch,
119
121
  onBlur: handleBlur,
120
122
  error: !!errors.email,
@@ -77,9 +77,9 @@ var RenderErrorModal = function RenderErrorModal(props) {
77
77
 
78
78
  //send activation email automatically if link is expired
79
79
  _react.default.useEffect(function () {
80
- if ((error === null || error === void 0 ? void 0 : error.code) === 'auth/invalid-action-code') {
81
- onModalSwitch && onModalSwitch();
82
- }
80
+ // if (error?.code === 'auth/invalid-action-code') {
81
+ // onModalSwitch && onModalSwitch()
82
+ // }
83
83
  if (error !== null && error !== void 0 && error.email && !isDisabled) {
84
84
  startCooldown();
85
85
  onResend({
@@ -257,7 +257,9 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
257
257
  return popup;
258
258
  });
259
259
  var mobileMenuOpen = this.state.mobileMenuOpen;
260
- var isFetchingUser = this.context.isFetchingUser;
260
+ var _this$context = this.context,
261
+ isFetchingUser = _this$context.isFetchingUser,
262
+ verifyEmailError = _this$context.verifyEmailError;
261
263
  if (!mobileMenuOpen) {
262
264
  if (isOpenCurrent) {
263
265
  document.body.style.overflow = 'hidden';
@@ -265,6 +267,9 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
265
267
  document.body.style.overflow = 'unset';
266
268
  }
267
269
  }
270
+ if ((verifyEmailError === null || verifyEmailError === void 0 ? void 0 : verifyEmailError.code) === 'auth/invalid-action-code' && !window.location.href.includes('login')) {
271
+ this.props.navigate('/login');
272
+ }
268
273
 
269
274
  // Run after page loaded
270
275
  if (!isFetchingUser) {
@@ -289,21 +294,21 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
289
294
  isLoginModalOpen = _this$props3.isLoginModalOpen,
290
295
  setIsLoginModalOpen = _this$props3.setIsLoginModalOpen,
291
296
  cooldown = _this$props3.cooldown;
292
- var _this$context = this.context,
293
- getUser = _this$context.getUser,
294
- _this$context$user = _this$context.user,
295
- user = _this$context$user === void 0 ? {} : _this$context$user,
296
- avatar = _this$context.avatar,
297
- logoutUser = _this$context.logoutUser,
298
- loginUser = _this$context.loginUser,
299
- waitingFor2fa = _this$context.waitingFor2fa,
300
- firebaseError = _this$context.firebaseError,
301
- loginUserWithTotp = _this$context.loginUserWithTotp,
302
- createUser = _this$context.createUser,
303
- handleResetPassword = _this$context.handleResetPassword,
304
- resendActivationEmail = _this$context.resendActivationEmail,
305
- verifyEmailError = _this$context.verifyEmailError,
306
- isVerifyingEmail = _this$context.isVerifyingEmail;
297
+ var _this$context2 = this.context,
298
+ getUser = _this$context2.getUser,
299
+ _this$context2$user = _this$context2.user,
300
+ user = _this$context2$user === void 0 ? {} : _this$context2$user,
301
+ avatar = _this$context2.avatar,
302
+ logoutUser = _this$context2.logoutUser,
303
+ loginUser = _this$context2.loginUser,
304
+ waitingFor2fa = _this$context2.waitingFor2fa,
305
+ firebaseError = _this$context2.firebaseError,
306
+ loginUserWithTotp = _this$context2.loginUserWithTotp,
307
+ createUser = _this$context2.createUser,
308
+ handleResetPassword = _this$context2.handleResetPassword,
309
+ resendActivationEmail = _this$context2.resendActivationEmail,
310
+ verifyEmailError = _this$context2.verifyEmailError,
311
+ isVerifyingEmail = _this$context2.isVerifyingEmail;
307
312
  return /*#__PURE__*/_react.default.createElement(Outer, {
308
313
  fixed: fixed
309
314
  }, /*#__PURE__*/_react.default.createElement(_Header.default, {
@@ -439,11 +439,11 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
439
439
  if (!user) {
440
440
  throw new Error('User is not defined');
441
441
  }
442
- if (!(user !== null && user !== void 0 && user.emailVerified) && !window.location.href.includes('signup.')) {
442
+ if (!(user !== null && user !== void 0 && user.emailVerified) && !window.location.href.includes('resend-activation-email')) {
443
443
  window.location.href = "https://signup.".concat(process.env.REACT_APP_WEBSITE_DOMAIN, "/resend-activation-email");
444
444
  return false;
445
445
  }
446
- if (!(user !== null && user !== void 0 && user.country) && (user === null || user === void 0 ? void 0 : user.user_type) === 'investor' && !window.location.href.includes('signup.')) {
446
+ if (!(user !== null && user !== void 0 && user.country) && (user === null || user === void 0 ? void 0 : user.user_type) === 'investor' && !window.location.href.includes('/welcome')) {
447
447
  window.location.href = "https://signup.".concat(process.env.REACT_APP_WEBSITE_DOMAIN, "/welcome");
448
448
  return false;
449
449
  }
@@ -538,18 +538,17 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
538
538
  _yield$Auth$updateUse = _context10.sent;
539
539
  user = _yield$Auth$updateUse.user;
540
540
  _this.setUser(user);
541
- _context10.next = 12;
542
- break;
543
- case 8:
544
- _context10.prev = 8;
541
+ return _context10.abrupt("return", user);
542
+ case 9:
543
+ _context10.prev = 9;
545
544
  _context10.t0 = _context10["catch"](0);
546
545
  console.log("Error updating the user: ".concat(_context10.t0));
547
546
  throw _context10.t0;
548
- case 12:
547
+ case 13:
549
548
  case "end":
550
549
  return _context10.stop();
551
550
  }
552
- }, _callee10, null, [[0, 8]]);
551
+ }, _callee10, null, [[0, 9]]);
553
552
  }));
554
553
  return function (_x14) {
555
554
  return _ref10.apply(this, arguments);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stokr/components-library",
3
- "version": "2.0.0-beta.21",
3
+ "version": "2.0.0-beta.22",
4
4
  "description": "STOKR - Components Library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",