@stokr/components-library 2.0.0-beta.2 → 2.0.0-beta.20

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 (34) hide show
  1. package/dist/components/2FA/Connect2FA.js +58 -16
  2. package/dist/components/2FA/EnterCode.js +2 -1
  3. package/dist/components/2FA/InstallAuthApp.js +41 -11
  4. package/dist/components/2FA/Sucess2FA.js +15 -6
  5. package/dist/components/2FA/disable-2fa-flow.js +10 -133
  6. package/dist/components/2FA/enable-2fa-flow.js +2 -2
  7. package/dist/components/2FA/main-flow.js +8 -4
  8. package/dist/components/2FA/main-flow.stories.js +1 -1
  9. package/dist/components/ComponentScroll/ComponentScroll.js +4 -2
  10. package/dist/components/ComponentScroll/ComponentScroll.styles.js +7 -5
  11. package/dist/components/ComponentWrapper/ComponentWrapper.styles.js +9 -7
  12. package/dist/components/CryptoAddress/CryptoAddress.js +6 -3
  13. package/dist/components/ForgotPasswordModal/ForgotPasswordModal.stories.js +4 -1
  14. package/dist/components/Header/Header.styles.js +1 -1
  15. package/dist/components/Input/OtpInput.js +54 -8
  16. package/dist/components/MainMenu/MainMenu.js +2 -2
  17. package/dist/components/Modal/Modal.styles.js +5 -2
  18. package/dist/components/RegisterConfirmModal/RegisterConfirmModal.js +10 -3
  19. package/dist/components/RegisterConfirmModal/RegisterConfirmModal.stories.js +6 -2
  20. package/dist/components/RegisterModal/RegisterModal.js +1 -22
  21. package/dist/components/Switch/Switch.js +13 -6
  22. package/dist/components/Switch/Switch.styles.js +3 -3
  23. package/dist/components/TermsModal/TermsModal.js +1 -1
  24. package/dist/components/TextLink/TextLink.styles.js +4 -2
  25. package/dist/components/VerifyEmailModal/VerifyEmailModal.js +163 -0
  26. package/dist/components/VerifyEmailModal/VerifyEmailModal.stories.js +64 -0
  27. package/dist/components/headerHo/HeaderHo.js +162 -104
  28. package/dist/components/headerHo/HeaderHo.stories.js +5 -1
  29. package/dist/context/Auth.js +41 -22
  30. package/dist/context/AuthContext.js +305 -218
  31. package/dist/static/images/avatar-placeholder.png +0 -0
  32. package/dist/static/images/google_auth.png +0 -0
  33. package/dist/utils/customHooks.js +60 -2
  34. package/package.json +1 -1
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.VerifyEmailSuccess = exports.VerifyEmailError = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _VerifyEmailModal = require("./VerifyEmailModal");
9
+ var _ComponentWrapper = require("../ComponentWrapper/ComponentWrapper.styles");
10
+ var _global = _interopRequireDefault(require("../../styles/global"));
11
+ var _reactRouterDom = require("react-router-dom");
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ var _default = {
14
+ title: 'Components Library/Verify Email Modal',
15
+ component: _VerifyEmailModal.VerifyEmailModal,
16
+ argTypes: {
17
+ isModalOpen: {
18
+ type: 'boolean',
19
+ defaultValue: true,
20
+ required: true
21
+ },
22
+ onModalClose: {
23
+ type: 'function',
24
+ action: 'onModalClose',
25
+ required: true
26
+ },
27
+ popupError: {
28
+ type: 'object',
29
+ defaultValue: {}
30
+ },
31
+ isSuccess: {
32
+ type: 'boolean',
33
+ defaultValue: true,
34
+ required: true
35
+ }
36
+ }
37
+ };
38
+ exports.default = _default;
39
+ var Template = function Template(args) {
40
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactRouterDom.BrowserRouter, null, /*#__PURE__*/_react.default.createElement(_global.default, null), /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, null, /*#__PURE__*/_react.default.createElement(_VerifyEmailModal.VerifyEmailModal, args))));
41
+ };
42
+ var VerifyEmailError = Template.bind({});
43
+ exports.VerifyEmailError = VerifyEmailError;
44
+ VerifyEmailError.args = {
45
+ popupError: {},
46
+ isModalOpen: true,
47
+ popupSuccess: {},
48
+ error: {
49
+ message: 'This link has expired. Please try verifying email again.'
50
+ },
51
+ isSuccess: false,
52
+ onResend: function onResend(data) {
53
+ console.log(data);
54
+ }
55
+ };
56
+ var VerifyEmailSuccess = Template.bind({});
57
+ exports.VerifyEmailSuccess = VerifyEmailSuccess;
58
+ VerifyEmailSuccess.args = {
59
+ popupError: {},
60
+ isModalOpen: true,
61
+ popupSuccess: {},
62
+ isSuccess: true,
63
+ continueUrl: 'https://www.stokr.info'
64
+ };
@@ -15,12 +15,14 @@ var _ForgotPasswordModal = _interopRequireDefault(require("../ForgotPasswordModa
15
15
  var _ResetPasswordModal = _interopRequireDefault(require("../ResetPasswordModal/ResetPasswordModal"));
16
16
  var _ResetConfirmModal = _interopRequireDefault(require("../ResetConfirmModal/ResetConfirmModal"));
17
17
  var _LoginModal = _interopRequireDefault(require("../LoginModal/LoginModal"));
18
+ var _VerifyEmailModal = _interopRequireDefault(require("../VerifyEmailModal/VerifyEmailModal"));
18
19
  var _Header = _interopRequireDefault(require("../Header/Header"));
19
20
  var _FA = require("../2FA");
20
21
  var _auth = _interopRequireDefault(require("../../api/auth"));
21
22
  var _fetchDataPublic = _interopRequireDefault(require("../../api/fetchDataPublic"));
22
23
  var _AuthContext = require("../../context/AuthContext");
23
24
  var _withRouter = require("../../utils/withRouter");
25
+ var _customHooks = require("../../utils/customHooks");
24
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
27
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
26
28
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -71,7 +73,8 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
71
73
  resetPassword: false,
72
74
  confirmReset: false,
73
75
  enter2fa: false,
74
- resetCode: false
76
+ resetCode: false,
77
+ verifyEmail: false
75
78
  },
76
79
  userInfo: {
77
80
  email: undefined,
@@ -95,12 +98,21 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
95
98
  var _this$props = _this.props,
96
99
  isLogin = _this$props.isLogin,
97
100
  isSignUp = _this$props.isSignUp,
98
- isResetPassword = _this$props.isResetPassword;
101
+ isResetPassword = _this$props.isResetPassword,
102
+ isVerifyEmail = _this$props.isVerifyEmail;
99
103
  var user = _this.context.user;
100
104
  var isModalOpen = _this.state.isModalOpen;
101
105
  var login = isModalOpen.login,
102
106
  signUp = isModalOpen.signUp,
103
- resetPassword = isModalOpen.resetPassword;
107
+ resetPassword = isModalOpen.resetPassword,
108
+ verifyEmail = isModalOpen.verifyEmail;
109
+
110
+ //checks if any modal is open
111
+ //if true we won't open any modal from below
112
+ var isAnyModalOpen = Object.values(isModalOpen).some(function (value) {
113
+ return value === true;
114
+ });
115
+ if (isAnyModalOpen) return;
104
116
 
105
117
  //dont open if modal is already open or user is logged in
106
118
  if (isLogin && !user && !login) {
@@ -130,6 +142,15 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
130
142
  });
131
143
  });
132
144
  }
145
+ if (isVerifyEmail && !verifyEmail) {
146
+ _this.setState(function (prevState) {
147
+ return _objectSpread(_objectSpread({}, prevState), {}, {
148
+ isModalOpen: _objectSpread(_objectSpread({}, isModalOpen), {}, {
149
+ verifyEmail: true
150
+ })
151
+ });
152
+ });
153
+ }
133
154
  });
134
155
  _defineProperty(_assertThisInitialized(_this), "setOpenModalStatus", function (modalId, status) {
135
156
  var isModalOpen = _this.state.isModalOpen;
@@ -143,7 +164,7 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
143
164
  window.history.pushState('', '', modalId === 'login' ? '/login' : modalId === 'signUp' ? '/signup' : '/');
144
165
 
145
166
  //when we close login or signup or reset password modal, we want to remove modal url
146
- if ((modalId === 'login' || modalId === 'signUp' || modalId === 'resetPassword') && !status) {
167
+ if ((modalId === 'login' || modalId === 'signUp' || modalId === 'resetPassword' || modalId === 'verifyEmail') && !status) {
147
168
  navigate('/');
148
169
  }
149
170
  }
@@ -155,6 +176,12 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
155
176
  });
156
177
  _defineProperty(_assertThisInitialized(_this), "switchOpenModal", function (prevModalId, nextModalId) {
157
178
  var isModalOpen = _this.state.isModalOpen;
179
+
180
+ //if you previously were on /signup or any other route and you want to swtich to login modal
181
+ //we need to change the url accordingly so if you refresh the page, the modal will open
182
+ if (nextModalId === 'login' || nextModalId === 'signUp') {
183
+ window.history.pushState('', '', nextModalId === 'login' ? '/login' : nextModalId === 'signUp' ? '/signup' : '/');
184
+ }
158
185
  _this.setState(function (prevState) {
159
186
  var _objectSpread3;
160
187
  return _objectSpread(_objectSpread({}, prevState), {}, {
@@ -230,10 +257,7 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
230
257
  return popup;
231
258
  });
232
259
  var mobileMenuOpen = this.state.mobileMenuOpen;
233
- var _this$context = this.context,
234
- isFetchingUser = _this$context.isFetchingUser,
235
- user = _this$context.user;
236
- var isUserLogged = !!user;
260
+ var isFetchingUser = this.context.isFetchingUser;
237
261
  if (!mobileMenuOpen) {
238
262
  if (isOpenCurrent) {
239
263
  document.body.style.overflow = 'hidden';
@@ -242,8 +266,8 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
242
266
  }
243
267
  }
244
268
 
245
- // Run after page loaded, if user is not logged in
246
- if (!isFetchingUser && !isUserLogged) {
269
+ // Run after page loaded
270
+ if (!isFetchingUser) {
247
271
  this.checkForModals();
248
272
  }
249
273
  }
@@ -263,18 +287,23 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
263
287
  withoutLoginSignupButton = _this$props3.withoutLoginSignupButton,
264
288
  useRelativePathForMenu = _this$props3.useRelativePathForMenu,
265
289
  isLoginModalOpen = _this$props3.isLoginModalOpen,
266
- setIsLoginModalOpen = _this$props3.setIsLoginModalOpen;
267
- var _this$context2 = this.context,
268
- getUser = _this$context2.getUser,
269
- _this$context2$user = _this$context2.user,
270
- user = _this$context2$user === void 0 ? {} : _this$context2$user,
271
- avatar = _this$context2.avatar,
272
- logoutUser = _this$context2.logoutUser,
273
- loginUser = _this$context2.loginUser,
274
- waitingFor2fa = _this$context2.waitingFor2fa,
275
- firebaseError = _this$context2.firebaseError,
276
- loginUserWithTotp = _this$context2.loginUserWithTotp,
277
- createUser = _this$context2.createUser;
290
+ setIsLoginModalOpen = _this$props3.setIsLoginModalOpen,
291
+ 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;
278
307
  return /*#__PURE__*/_react.default.createElement(Outer, {
279
308
  fixed: fixed
280
309
  }, /*#__PURE__*/_react.default.createElement(_Header.default, {
@@ -335,13 +364,13 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
335
364
  _context.next = 10;
336
365
  return loginUser(email, password);
337
366
  case 10:
367
+ _context.next = 12;
368
+ return getUser();
369
+ case 12:
338
370
  _this2.setOpenModalStatus('login', false);
339
371
  setIsLoginModalOpen && setIsLoginModalOpen(false);
340
372
  _this2.clearPopupError();
341
373
  _this2.setIsActionLoading(undefined);
342
- _context.next = 16;
343
- return getUser();
344
- case 16:
345
374
  _context.next = 28;
346
375
  break;
347
376
  case 18:
@@ -403,10 +432,13 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
403
432
  _context2.next = 7;
404
433
  return getUser();
405
434
  case 7:
406
- _context2.next = 13;
435
+ _this2.setOpenModalStatus('enter2fa', false);
436
+ _this2.clearPopupError();
437
+ _this2.setIsActionLoading(undefined);
438
+ _context2.next = 16;
407
439
  break;
408
- case 9:
409
- _context2.prev = 9;
440
+ case 12:
441
+ _context2.prev = 12;
410
442
  _context2.t0 = _context2["catch"](2);
411
443
  console.log('🚀 ~ file: HeaderHo.jsx:364 ~ error:', _context2.t0);
412
444
  if ((_context2.t0 === null || _context2.t0 === void 0 ? void 0 : _context2.t0.code) === 'auth/invalid-verification-code') {
@@ -414,13 +446,13 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
414
446
  } else {
415
447
  _this2.setPopupError('enter2fa', _context2.t0 === null || _context2.t0 === void 0 ? void 0 : _context2.t0.message);
416
448
  }
417
- case 13:
449
+ case 16:
418
450
  _this2.setIsActionLoading(undefined);
419
- case 14:
451
+ case 17:
420
452
  case "end":
421
453
  return _context2.stop();
422
454
  }
423
- }, _callee2, null, [[2, 9]]);
455
+ }, _callee2, null, [[2, 12]]);
424
456
  }));
425
457
  return function (_x2) {
426
458
  return _ref5.apply(this, arguments);
@@ -479,61 +511,38 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
479
511
  },
480
512
  onFormSend: /*#__PURE__*/function () {
481
513
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(userInfo) {
482
- var referralCode, checkedCheckboxes;
483
514
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
484
515
  while (1) switch (_context3.prev = _context3.next) {
485
516
  case 0:
486
517
  _this2.clearPopupError();
487
518
  _this2.setIsActionLoading('signUp');
488
- referralCode = _jsCookie.default.get('STOKR_REFERRAL_CODE'); //check username
489
- // try {
490
- // const result = await fetchDataPublic('user/checkUsernameExists', {
491
- // username: userInfo.username,
492
- // })
493
- // if (result.usernameExists) {
494
- // this.setPopupError(
495
- // 'register',
496
- // 'This username is already taken',
497
- // 'username',
498
- // )
499
- // this.setIsActionLoading(undefined)
500
- // return
501
- // }
502
- // } catch (error) {
503
- // console.log(error)
504
- // this.setPopupError('register', 'Oops, something went wrong')
505
- // this.setIsActionLoading(undefined)
506
- // return
507
- // }
519
+
508
520
  //check password
509
- _context3.prev = 3;
521
+ _context3.prev = 2;
510
522
  if (!(userInfo.password.length > 128)) {
511
- _context3.next = 8;
523
+ _context3.next = 7;
512
524
  break;
513
525
  }
514
526
  _this2.setPopupError('register', 'Your password cannot exceed 128 characters', 'password');
515
527
  _this2.setIsActionLoading(undefined);
516
528
  return _context3.abrupt("return");
517
- case 8:
518
- //we add the checked checkboxes at the end because sometimes the checkboxes are already checked in persist storage
519
- //so we want to make sure that the EP receives checkedCheckboxes
520
- checkedCheckboxes = [];
521
- if (userInfo.newsletter) checkedCheckboxes.push('newsletter');
522
- if (userInfo.terms) checkedCheckboxes.push('privacyTerms');
529
+ case 7:
530
+ _context3.next = 9;
531
+ return createUser(userInfo.email, userInfo.password);
532
+ case 9:
533
+ //start the timer to count when user can resend email
534
+ cooldown === null || cooldown === void 0 || cooldown.startCooldown();
523
535
 
524
- // await authAPI('signup', {
525
- // email: userInfo.email,
526
- // password: userInfo.password,
527
- // userType: 'investor',
528
- // // fa2: false,
529
- // newsletter: userInfo.newsletter,
530
- // terms: userInfo.terms,
531
- // username: userInfo.username,
532
- // tapfiliateReferralCode: referralCode,
533
- // checkedCheckboxes,
534
- // })
536
+ //if user checked newsletter checkbox
537
+ if (!userInfo.newsletter) {
538
+ _context3.next = 13;
539
+ break;
540
+ }
535
541
  _context3.next = 13;
536
- return createUser(userInfo.email, userInfo.password);
542
+ return (0, _fetchDataPublic.default)('emails/subscribe', {
543
+ email: userInfo.email,
544
+ listName: 'newsletter'
545
+ });
537
546
  case 13:
538
547
  _this2.setUserInfo(userInfo);
539
548
  _this2.switchOpenModal('signUp', 'confirm');
@@ -542,7 +551,7 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
542
551
  break;
543
552
  case 18:
544
553
  _context3.prev = 18;
545
- _context3.t0 = _context3["catch"](3);
554
+ _context3.t0 = _context3["catch"](2);
546
555
  console.log(_context3.t0);
547
556
  _this2.setIsActionLoading(undefined);
548
557
  if ((_context3.t0 === null || _context3.t0 === void 0 ? void 0 : _context3.t0.code) === 'auth/email-already-in-use') {
@@ -556,7 +565,7 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
556
565
  case "end":
557
566
  return _context3.stop();
558
567
  }
559
- }, _callee3, null, [[3, 18]]);
568
+ }, _callee3, null, [[2, 18]]);
560
569
  }));
561
570
  return function (_x3) {
562
571
  return _ref6.apply(this, arguments);
@@ -575,6 +584,7 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
575
584
  id: "form-submitted-popup",
576
585
  isActionLoading: isActionLoading,
577
586
  userInfo: userInfo,
587
+ cooldown: cooldown,
578
588
  popupError: this.state.popupError,
579
589
  popupSuccess: this.state.popupSuccess,
580
590
  isModalOpen: isModalOpen.confirm,
@@ -595,25 +605,24 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
595
605
  _context4.prev = 3;
596
606
  email = _this2.state.userInfo.email;
597
607
  _context4.next = 7;
598
- return (0, _auth.default)('forgotPass', {
599
- email: email
600
- });
608
+ return resendActivationEmail(email);
601
609
  case 7:
610
+ cooldown === null || cooldown === void 0 || cooldown.startCooldown();
602
611
  _this2.setPopupSuccess('resend', 'Email sent.');
603
612
  _this2.setIsActionLoading(undefined);
604
- _context4.next = 16;
613
+ _context4.next = 17;
605
614
  break;
606
- case 11:
607
- _context4.prev = 11;
615
+ case 12:
616
+ _context4.prev = 12;
608
617
  _context4.t0 = _context4["catch"](3);
609
618
  console.log(_context4.t0);
610
619
  _this2.setPopupError('resend', 'Something went wrong.');
611
620
  _this2.setIsActionLoading(undefined);
612
- case 16:
621
+ case 17:
613
622
  case "end":
614
623
  return _context4.stop();
615
624
  }
616
- }, _callee4, null, [[3, 11]]);
625
+ }, _callee4, null, [[3, 12]]);
617
626
  }))
618
627
  }), /*#__PURE__*/_react.default.createElement(_ForgotPasswordModal.default, {
619
628
  isActionLoading: isActionLoading,
@@ -677,47 +686,42 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
677
686
  _this2.setIsActionLoading(undefined);
678
687
  },
679
688
  onModalSwitch: function onModalSwitch() {
689
+ window.history.pushState({}, null, '/login');
680
690
  _this2.switchOpenModal('resetPassword', 'login');
681
691
  _this2.clearPopupError();
682
692
  _this2.setIsActionLoading(undefined);
683
693
  },
684
694
  onFormSend: /*#__PURE__*/function () {
685
695
  var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref10) {
686
- var password, isUsingQueryParam, token;
696
+ var password;
687
697
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
688
698
  while (1) switch (_context6.prev = _context6.next) {
689
699
  case 0:
690
700
  password = _ref10.password;
691
701
  _this2.clearPopupError();
692
702
  _this2.setIsActionLoading('resetPassword');
693
- isUsingQueryParam = window.location.href.includes('?token=');
694
- if (isUsingQueryParam) {
695
- token = window.location.href.split('reset-password?token=')[1].split('&')[0];
696
- } else {
697
- token = window.location.href.split('reset-password/')[1].split('/')[0];
698
- }
699
- _context6.prev = 5;
700
- _context6.next = 8;
701
- return (0, _auth.default)('resetPass', {
702
- password: password,
703
- token: token
704
- });
705
- case 8:
703
+
704
+ //localhost:3001/manage-user?mode=resetPassword&oobCode=PT_AyRFYWXwDe0Ols12TOKSiGQUSdb6mM4DKDLwHGdQAAAGMgUUaEQ&apiKey=AIzaSyBBp_3Romnfv--YpUuV0mJgDymvSp3oq0c&continueUrl=https%3A%2F%2Fstokr.info&lang=en
705
+ //https://stokr.info/manage-user?mode=resetPassword&oobCode=TGhCFwb9uLeYiL2Hp4LFgRg5Fd9osw1Fvza4qY5Hhy0AAAGMgmuGuw&apiKey=AIzaSyBBp_3Romnfv--YpUuV0mJgDymvSp3oq0c&continueUrl=https%3A%2F%2Fstokr.info&lang=en
706
+ _context6.prev = 3;
707
+ _context6.next = 6;
708
+ return handleResetPassword(password);
709
+ case 6:
706
710
  _this2.switchOpenModal('resetPassword', 'confirmReset');
707
711
  _this2.setIsActionLoading(undefined);
708
- _context6.next = 17;
712
+ _context6.next = 15;
709
713
  break;
710
- case 12:
711
- _context6.prev = 12;
712
- _context6.t0 = _context6["catch"](5);
714
+ case 10:
715
+ _context6.prev = 10;
716
+ _context6.t0 = _context6["catch"](3);
713
717
  console.log(_context6.t0);
714
- _this2.setPopupError('resetPassword', 'Something went wrong.');
718
+ _this2.setPopupError('resetPassword', (_context6.t0 === null || _context6.t0 === void 0 ? void 0 : _context6.t0.message) || 'Something went wrong.');
715
719
  _this2.setIsActionLoading(undefined);
716
- case 17:
720
+ case 15:
717
721
  case "end":
718
722
  return _context6.stop();
719
723
  }
720
- }, _callee6, null, [[5, 12]]);
724
+ }, _callee6, null, [[3, 10]]);
721
725
  }));
722
726
  return function (_x5) {
723
727
  return _ref11.apply(this, arguments);
@@ -731,6 +735,60 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
731
735
  onModalSwitch: function onModalSwitch() {
732
736
  _this2.switchOpenModal('confirmReset', 'login');
733
737
  }
738
+ }), !isVerifyingEmail && /*#__PURE__*/_react.default.createElement(_VerifyEmailModal.default, {
739
+ id: "verify-email-popup",
740
+ isActionLoading: isActionLoading,
741
+ popupError: this.state.popupError,
742
+ popupSuccess: this.state.popupSuccess,
743
+ isModalOpen: isModalOpen.verifyEmail,
744
+ continueUrl: 'https://signup.stokr.info/',
745
+ error: verifyEmailError,
746
+ isSuccess: !!!verifyEmailError,
747
+ onModalSwitch: function onModalSwitch() {
748
+ _this2.switchOpenModal('verifyEmail', 'login');
749
+ _this2.clearPopupError();
750
+ _this2.setIsActionLoading(undefined);
751
+ },
752
+ onModalClose: function onModalClose() {
753
+ _this2.setOpenModalStatus('verifyEmail', false);
754
+ _this2.clearPopupSuccess();
755
+ _this2.clearPopupError();
756
+ _this2.setIsActionLoading(undefined);
757
+ },
758
+ onResend: /*#__PURE__*/function () {
759
+ var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(values) {
760
+ var email;
761
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
762
+ while (1) switch (_context7.prev = _context7.next) {
763
+ case 0:
764
+ _this2.clearPopupSuccess();
765
+ _this2.clearPopupError();
766
+ _this2.setIsActionLoading('resend');
767
+ _context7.prev = 3;
768
+ email = values === null || values === void 0 ? void 0 : values.email;
769
+ _context7.next = 7;
770
+ return resendActivationEmail(email);
771
+ case 7:
772
+ _this2.setPopupSuccess('resend', 'Email sent.');
773
+ _this2.setIsActionLoading(undefined);
774
+ _context7.next = 16;
775
+ break;
776
+ case 11:
777
+ _context7.prev = 11;
778
+ _context7.t0 = _context7["catch"](3);
779
+ console.log(_context7.t0);
780
+ _this2.setPopupError('resend', (_context7.t0 === null || _context7.t0 === void 0 ? void 0 : _context7.t0.message) || 'Something went wrong.');
781
+ _this2.setIsActionLoading(undefined);
782
+ case 16:
783
+ case "end":
784
+ return _context7.stop();
785
+ }
786
+ }, _callee7, null, [[3, 11]]);
787
+ }));
788
+ return function (_x6) {
789
+ return _ref12.apply(this, arguments);
790
+ };
791
+ }()
734
792
  }));
735
793
  }
736
794
  }]);
@@ -738,7 +796,7 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
738
796
  }(_react.Component);
739
797
  _defineProperty(HeaderHoClass, "propTypes", {});
740
798
  _defineProperty(HeaderHoClass, "contextType", _AuthContext.AuthContext);
741
- var HeaderHo = (0, _withRouter.withRouter)(HeaderHoClass);
799
+ var HeaderHo = (0, _withRouter.withRouter)((0, _customHooks.cooldownHOC)(HeaderHoClass, 90));
742
800
  exports.HeaderHo = HeaderHo;
743
801
  var _default = HeaderHo;
744
802
  exports.default = _default;
@@ -27,7 +27,11 @@ var _default = {
27
27
  };
28
28
  exports.default = _default;
29
29
  var Template = function Template(args) {
30
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_global.default, null), /*#__PURE__*/_react.default.createElement(_reactRouterDom.BrowserRouter, null, /*#__PURE__*/_react.default.createElement(_AuthContext.AuthProvider, null, /*#__PURE__*/_react.default.createElement(_HeaderHo.default, args))));
30
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_global.default, null), /*#__PURE__*/_react.default.createElement(_reactRouterDom.BrowserRouter, null, /*#__PURE__*/_react.default.createElement(_AuthContext.AuthProvider, null, /*#__PURE__*/_react.default.createElement(_HeaderHo.default, args), /*#__PURE__*/_react.default.createElement("div", {
31
+ style: {
32
+ height: '100vh'
33
+ }
34
+ }))));
31
35
  };
32
36
  var HeaderHoOverview = Template.bind({});
33
37
  exports.HeaderHoOverview = HeaderHoOverview;
@@ -81,18 +81,11 @@ var Auth = /*#__PURE__*/function () {
81
81
  });
82
82
  }
83
83
  }, {
84
- key: "activateUser",
85
- value: function activateUser() {
86
- var isUsingQueryParam = window.location.href.includes('?token=');
87
- var token;
88
- if (isUsingQueryParam) {
89
- token = window.location.href.split('activateUser?token=')[1].split('&')[0];
90
- } else {
91
- token = window.location.href.split('activateUser/')[1].split('/')[0];
92
- }
84
+ key: "resendActivationEmail",
85
+ value: function resendActivationEmail(email) {
93
86
  return new Promise(function (resolve, reject) {
94
- _axios.default.post("auth/activate", {
95
- token: token
87
+ _axios.default.post("auth/resend-activation-email", {
88
+ email: email
96
89
  }).then(function (response) {
97
90
  resolve(response.data);
98
91
  }).catch(function (err) {
@@ -100,6 +93,43 @@ var Auth = /*#__PURE__*/function () {
100
93
  });
101
94
  });
102
95
  }
96
+ }, {
97
+ key: "handleVerifyEmail",
98
+ value: function handleVerifyEmail(actionCode, continueUrl) {
99
+ return new Promise(function (resolve, reject) {
100
+ (0, _auth.applyActionCode)(_firebaseConfig.auth, actionCode).then(function (resp) {
101
+ // Email address has been verified.
102
+ resolve(resp);
103
+ }).catch(function (error) {
104
+ reject(error);
105
+ });
106
+ });
107
+ }
108
+ }, {
109
+ key: "handleResetPassword",
110
+ value: function handleResetPassword(actionCode, newPassword, continueUrl) {
111
+ return new Promise(function (resolve, reject) {
112
+ // Verify the password reset code is valid.
113
+ (0, _auth.verifyPasswordResetCode)(_firebaseConfig.auth, actionCode).then(function (email) {
114
+ var accountEmail = email;
115
+ (0, _auth.confirmPasswordReset)(_firebaseConfig.auth, actionCode, newPassword).then(function (resp) {
116
+ // Password reset has been confirmed and new password updated.
117
+
118
+ //signInWithEmailAndPassword(accountEmail, newPassword)
119
+
120
+ resolve(accountEmail);
121
+ }).catch(function (error) {
122
+ // Error occurred during confirmation. The code might have expired or the
123
+ // password is too weak.
124
+ reject(error);
125
+ });
126
+ }).catch(function (error) {
127
+ // Invalid or expired action code. Ask user to try to reset the password
128
+ // again.
129
+ reject(error);
130
+ });
131
+ });
132
+ }
103
133
  }, {
104
134
  key: "getUser",
105
135
  value: function getUser() {
@@ -223,17 +253,6 @@ var Auth = /*#__PURE__*/function () {
223
253
  });
224
254
  });
225
255
  }
226
- }, {
227
- key: "resendActivationEmail",
228
- value: function resendActivationEmail(data) {
229
- return new Promise(function (resolve, reject) {
230
- _axios.default.post("auth/forgotPass", data).then(function () {
231
- resolve();
232
- }).catch(function (err) {
233
- reject(err);
234
- });
235
- });
236
- }
237
256
  }, {
238
257
  key: "uploaProofOfAddress",
239
258
  value: function uploaProofOfAddress(data, ip) {