@stokr/components-library 2.0.0-beta.7 → 2.0.0-beta.9

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.
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = exports.VerifyEmailModal = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
11
+ var sc = _interopRequireWildcard(require("../../constants/style"));
12
+ var _Modal = require("../Modal/Modal");
13
+ var _Text = _interopRequireDefault(require("../Text/Text.styles"));
14
+ var _TextLink = _interopRequireDefault(require("../TextLink/TextLink.styles"));
15
+ var _Grid = require("../Grid/Grid.styles");
16
+ var _RegisterConfirmModal = require("../RegisterConfirmModal/RegisterConfirmModal.styles");
17
+ var _ComponentWrapper = _interopRequireDefault(require("../ComponentWrapper/ComponentWrapper.styles"));
18
+ var _Form = require("../Form/Form.styles");
19
+ var _Button = _interopRequireDefault(require("components/Button/Button.styles"));
20
+ 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); }
21
+ 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; }
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
+ var RedBar = _styledComponents.default.div.withConfig({
24
+ displayName: "VerifyEmailModal__RedBar",
25
+ componentId: "sc-13smx1f-0"
26
+ })(["background:", ";bottom:0;height:30%;position:absolute;right:0;width:50%;"], sc.RED_BASE_HEX);
27
+ var VerifyEmailModal = function VerifyEmailModal(_ref) {
28
+ var id = _ref.id,
29
+ isModalOpen = _ref.isModalOpen,
30
+ onModalClose = _ref.onModalClose,
31
+ onResend = _ref.onResend,
32
+ popupError = _ref.popupError,
33
+ popupSuccess = _ref.popupSuccess,
34
+ isActionLoading = _ref.isActionLoading,
35
+ continueUrl = _ref.continueUrl,
36
+ isSuccess = _ref.isSuccess,
37
+ error = _ref.error;
38
+ return /*#__PURE__*/_react.default.createElement(_Modal.Modal, {
39
+ isOpen: isModalOpen,
40
+ onClose: onModalClose,
41
+ closeIsFullHeight: true,
42
+ id: id
43
+ }, /*#__PURE__*/_react.default.createElement(_Grid.Row, {
44
+ isConfirmModal: true
45
+ }, /*#__PURE__*/_react.default.createElement(_Grid.Column, {
46
+ relative: true,
47
+ part: 10,
48
+ isConfirmModal: true
49
+ }, /*#__PURE__*/_react.default.createElement(_Modal.ModalInner, {
50
+ isConfirmModal: true
51
+ }, /*#__PURE__*/_react.default.createElement(_RegisterConfirmModal.ContainerWithLine, null, /*#__PURE__*/_react.default.createElement(_Text.default, {
52
+ withBorder: true,
53
+ isConfirm: true
54
+ }, /*#__PURE__*/_react.default.createElement("h3", null, isSuccess ? "GREAT! You're verified" : error ? "Oops. Something went wrong" : ''), /*#__PURE__*/_react.default.createElement("p", null, ' ', isSuccess ? "You can now complete your sign up proccess by clicking the\n button below.\n " : error ? error === null || error === void 0 ? void 0 : error.message : '')), continueUrl && isSuccess && /*#__PURE__*/_react.default.createElement(_ComponentWrapper.default, {
55
+ noPaddingHorizontal: true
56
+ }, /*#__PURE__*/_react.default.createElement(_Button.default, {
57
+ onClick: function onClick() {
58
+ window.open(continueUrl);
59
+ }
60
+ }, "Continue")), error && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ComponentWrapper.default, {
61
+ noPaddingHorizontal: true
62
+ }, /*#__PURE__*/_react.default.createElement(_TextLink.default, {
63
+ to: "",
64
+ onClick: onResend
65
+ }, isActionLoading === 'resend' ? 'Resending email' : 'Resend activation email'))), /*#__PURE__*/_react.default.createElement(_ComponentWrapper.default, {
66
+ noPaddingVertical: true,
67
+ noPaddingHorizontal: true
68
+ }, /*#__PURE__*/_react.default.createElement(_Form.FormError, {
69
+ show: popupError.popup === 'resend'
70
+ }, popupError.message)), /*#__PURE__*/_react.default.createElement(_ComponentWrapper.default, {
71
+ noPaddingVertical: true,
72
+ noPaddingHorizontal: true
73
+ }, /*#__PURE__*/_react.default.createElement(_Form.FormError, {
74
+ isSuccess: true,
75
+ show: popupSuccess.popup === 'resend'
76
+ }, popupSuccess.message)))))), /*#__PURE__*/_react.default.createElement(RedBar, null));
77
+ };
78
+ exports.VerifyEmailModal = VerifyEmailModal;
79
+ VerifyEmailModal.propTypes = {
80
+ isModalOpen: _propTypes.default.bool.isRequired,
81
+ onModalClose: _propTypes.default.func.isRequired
82
+ };
83
+ var _default = VerifyEmailModal;
84
+ exports.default = _default;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.VerifyEmailModalDefault = 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 VerifyEmailModalDefault = Template.bind({});
43
+ exports.VerifyEmailModalDefault = VerifyEmailModalDefault;
44
+ VerifyEmailModalDefault.args = {
45
+ popupError: {},
46
+ popupSuccess: {}
47
+ };
@@ -15,6 +15,7 @@ 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"));
@@ -71,7 +72,8 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
71
72
  resetPassword: false,
72
73
  confirmReset: false,
73
74
  enter2fa: false,
74
- resetCode: false
75
+ resetCode: false,
76
+ verifyEmail: false
75
77
  },
76
78
  userInfo: {
77
79
  email: undefined,
@@ -95,13 +97,22 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
95
97
  var _this$props = _this.props,
96
98
  isLogin = _this$props.isLogin,
97
99
  isSignUp = _this$props.isSignUp,
98
- isResetPassword = _this$props.isResetPassword;
99
- console.log('🚀 ~ file: HeaderHo.jsx:102 ~ this.props:', _this.props);
100
+ isResetPassword = _this$props.isResetPassword,
101
+ isVerifyEmail = _this$props.isVerifyEmail;
100
102
  var user = _this.context.user;
101
103
  var isModalOpen = _this.state.isModalOpen;
102
104
  var login = isModalOpen.login,
103
105
  signUp = isModalOpen.signUp,
104
- resetPassword = isModalOpen.resetPassword;
106
+ resetPassword = isModalOpen.resetPassword,
107
+ verifyEmail = isModalOpen.verifyEmail;
108
+
109
+ //checks if any modal is open
110
+ //if true we won't open any modal from below
111
+ var isAnyModalOpen = Object.values(isModalOpen).some(function (value) {
112
+ return value === true;
113
+ });
114
+ if (isAnyModalOpen) return;
115
+ console.log('🚀 ~ file: HeaderHo.jsx:102 ~ this.props:', _this.props);
105
116
 
106
117
  //dont open if modal is already open or user is logged in
107
118
  if (isLogin && !user && !login) {
@@ -131,6 +142,15 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
131
142
  });
132
143
  });
133
144
  }
145
+ if (isVerifyEmail && !user && !verifyEmail) {
146
+ _this.setState(function (prevState) {
147
+ return _objectSpread(_objectSpread({}, prevState), {}, {
148
+ isModalOpen: _objectSpread(_objectSpread({}, isModalOpen), {}, {
149
+ verifyEmail: true
150
+ })
151
+ });
152
+ });
153
+ }
134
154
  });
135
155
  _defineProperty(_assertThisInitialized(_this), "setOpenModalStatus", function (modalId, status) {
136
156
  var isModalOpen = _this.state.isModalOpen;
@@ -144,7 +164,7 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
144
164
  window.history.pushState('', '', modalId === 'login' ? '/login' : modalId === 'signUp' ? '/signup' : '/');
145
165
 
146
166
  //when we close login or signup or reset password modal, we want to remove modal url
147
- if ((modalId === 'login' || modalId === 'signUp' || modalId === 'resetPassword') && !status) {
167
+ if ((modalId === 'login' || modalId === 'signUp' || modalId === 'resetPassword' || modalId === 'verifyEmail') && !status) {
148
168
  navigate('/');
149
169
  }
150
170
  }
@@ -158,7 +178,7 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
158
178
  var isModalOpen = _this.state.isModalOpen;
159
179
 
160
180
  //if you previously were on /signup or any other route and you want to swtich to login modal
161
- //we need to change the url accordingly to override passed props which opens previous modal
181
+ //we need to change the url accordingly so if you refresh the page, the modal will open
162
182
  if (nextModalId === 'login' || nextModalId === 'signUp') {
163
183
  window.history.pushState('', '', nextModalId === 'login' ? '/login' : nextModalId === 'signUp' ? '/signup' : '/');
164
184
  }
@@ -282,7 +302,9 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
282
302
  firebaseError = _this$context2.firebaseError,
283
303
  loginUserWithTotp = _this$context2.loginUserWithTotp,
284
304
  createUser = _this$context2.createUser,
285
- handleResetPassword = _this$context2.handleResetPassword;
305
+ handleResetPassword = _this$context2.handleResetPassword,
306
+ resendActivationEmail = _this$context2.resendActivationEmail,
307
+ verifyEmailError = _this$context2.verifyEmailError;
286
308
  return /*#__PURE__*/_react.default.createElement(Outer, {
287
309
  fixed: fixed
288
310
  }, /*#__PURE__*/_react.default.createElement(_Header.default, {
@@ -343,39 +365,40 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
343
365
  _context.next = 10;
344
366
  return loginUser(email, password);
345
367
  case 10:
368
+ console.log('🚀 ~ file: HeaderHo.jsx:344 ~ loginUser:', loginUser);
369
+ _context.next = 13;
370
+ return getUser();
371
+ case 13:
346
372
  _this2.setOpenModalStatus('login', false);
347
373
  setIsLoginModalOpen && setIsLoginModalOpen(false);
348
374
  _this2.clearPopupError();
349
375
  _this2.setIsActionLoading(undefined);
350
- _context.next = 16;
351
- return getUser();
352
- case 16:
353
- _context.next = 28;
376
+ _context.next = 29;
354
377
  break;
355
- case 18:
356
- _context.prev = 18;
378
+ case 19:
379
+ _context.prev = 19;
357
380
  _context.t0 = _context["catch"](3);
358
381
  errorMessage = _context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message; //handle switch modal correctly
359
382
  if (!((_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.code) === 'auth/multi-factor-auth-required')) {
360
- _context.next = 26;
383
+ _context.next = 27;
361
384
  break;
362
385
  }
363
386
  _this2.switchOpenModal('login', 'enter2fa');
364
387
  _this2.clearPopupError();
365
388
  _this2.setIsActionLoading(undefined);
366
389
  return _context.abrupt("return");
367
- case 26:
390
+ case 27:
368
391
  if (errorMessage) {
369
392
  _this2.setPopupError('login', errorMessage);
370
393
  } else {
371
394
  _this2.setPopupError('login', "Oops. Something's not right there. Try again?");
372
395
  }
373
396
  _this2.setIsActionLoading(undefined);
374
- case 28:
397
+ case 29:
375
398
  case "end":
376
399
  return _context.stop();
377
400
  }
378
- }, _callee, null, [[3, 18]]);
401
+ }, _callee, null, [[3, 19]]);
379
402
  }));
380
403
  return function (_x) {
381
404
  return _ref3.apply(this, arguments);
@@ -576,9 +599,7 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
576
599
  _context4.prev = 3;
577
600
  email = _this2.state.userInfo.email;
578
601
  _context4.next = 7;
579
- return (0, _auth.default)('forgotPass', {
580
- email: email
581
- });
602
+ return resendActivationEmail(email);
582
603
  case 7:
583
604
  _this2.setPopupSuccess('resend', 'Email sent.');
584
605
  _this2.setIsActionLoading(undefined);
@@ -707,6 +728,50 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
707
728
  onModalSwitch: function onModalSwitch() {
708
729
  _this2.switchOpenModal('confirmReset', 'login');
709
730
  }
731
+ }), /*#__PURE__*/_react.default.createElement(_VerifyEmailModal.default, {
732
+ id: "verify-email-popup",
733
+ isActionLoading: isActionLoading,
734
+ popupError: this.state.popupError,
735
+ popupSuccess: this.state.popupSuccess,
736
+ isModalOpen: isModalOpen.verifyEmail,
737
+ continueUrl: 'https://signup.stokr.info/',
738
+ error: verifyEmailError,
739
+ isSuccess: !!!verifyEmailError,
740
+ onModalClose: function onModalClose() {
741
+ _this2.setOpenModalStatus('verifyEmail', false);
742
+ _this2.clearPopupSuccess();
743
+ _this2.clearPopupError();
744
+ _this2.setIsActionLoading(undefined);
745
+ },
746
+ onResend: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
747
+ var email;
748
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
749
+ while (1) switch (_context7.prev = _context7.next) {
750
+ case 0:
751
+ _this2.clearPopupSuccess();
752
+ _this2.clearPopupError();
753
+ _this2.setIsActionLoading('resend');
754
+ _context7.prev = 3;
755
+ email = _this2.state.userInfo.email;
756
+ _context7.next = 7;
757
+ return resendActivationEmail(email);
758
+ case 7:
759
+ _this2.setPopupSuccess('resend', 'Email sent.');
760
+ _this2.setIsActionLoading(undefined);
761
+ _context7.next = 16;
762
+ break;
763
+ case 11:
764
+ _context7.prev = 11;
765
+ _context7.t0 = _context7["catch"](3);
766
+ console.log(_context7.t0);
767
+ _this2.setPopupError('resend', (_context7.t0 === null || _context7.t0 === void 0 ? void 0 : _context7.t0.message) || 'Something went wrong.');
768
+ _this2.setIsActionLoading(undefined);
769
+ case 16:
770
+ case "end":
771
+ return _context7.stop();
772
+ }
773
+ }, _callee7, null, [[3, 11]]);
774
+ }))
710
775
  }));
711
776
  }
712
777
  }]);
@@ -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
87
  _axios.default.post("auth/activate", {
95
- token: token
88
+ email: email
96
89
  }).then(function (response) {
97
90
  resolve(response.data);
98
91
  }).catch(function (err) {
@@ -104,10 +97,16 @@ var Auth = /*#__PURE__*/function () {
104
97
  key: "handleVerifyEmail",
105
98
  value: function handleVerifyEmail(actionCode, continueUrl) {
106
99
  return new Promise(function (resolve, reject) {
107
- // Try to apply the email verification code.
108
- (0, _auth.applyActionCode)(_firebaseConfig.auth, actionCode).then(function (resp) {
109
- // Email address has been verified.
110
- resolve(resp);
100
+ (0, _auth.checkActionCode)(_firebaseConfig.auth, actionCode).then(function (resp) {
101
+ console.log('🚀 response from checkAcctionCode', resp);
102
+
103
+ // Try to apply the email verification code.
104
+ (0, _auth.applyActionCode)(_firebaseConfig.auth, actionCode).then(function (resp) {
105
+ // Email address has been verified.
106
+ resolve(resp);
107
+ }).catch(function (error) {
108
+ reject(error);
109
+ });
111
110
  }).catch(function (error) {
112
111
  reject(error);
113
112
  });
@@ -261,17 +260,6 @@ var Auth = /*#__PURE__*/function () {
261
260
  });
262
261
  });
263
262
  }
264
- }, {
265
- key: "resendActivationEmail",
266
- value: function resendActivationEmail(data) {
267
- return new Promise(function (resolve, reject) {
268
- _axios.default.post("auth/forgotPass", data).then(function () {
269
- resolve();
270
- }).catch(function (err) {
271
- reject(err);
272
- });
273
- });
274
- }
275
263
  }, {
276
264
  key: "uploaProofOfAddress",
277
265
  value: function uploaProofOfAddress(data, ip) {
@@ -53,7 +53,8 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
53
53
  avatar: _avatarPlaceholder.default,
54
54
  userMfaEnrollment: null,
55
55
  waitingFor2fa: false,
56
- firebaseError: null
56
+ firebaseError: null,
57
+ verifyEmailError: null
57
58
  });
58
59
  _defineProperty(_assertThisInitialized(_this), "checkTokenIsValid", function () {
59
60
  var redirect = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
@@ -74,6 +75,13 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
74
75
  return _Auth.default.login(email, password);
75
76
  case 3:
76
77
  user = _context.sent;
78
+ console.log('🚀 ~ file: AuthContext.js:50 ~ user:', user);
79
+ if (user.emailVerified) {
80
+ _context.next = 7;
81
+ break;
82
+ }
83
+ throw new Error("You're not activated. Please check your email address to verify your account.");
84
+ case 7:
77
85
  _Auth.default.setAccessToken(user.accessToken);
78
86
  _this.setState({
79
87
  firebaseUser: user,
@@ -81,37 +89,37 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
81
89
  });
82
90
  //if you need user immediatly
83
91
  return _context.abrupt("return", user);
84
- case 9:
85
- _context.prev = 9;
92
+ case 12:
93
+ _context.prev = 12;
86
94
  _context.t0 = _context["catch"](0);
87
95
  console.log('🚀 ~ file: AuthContext.js:56 ~ error:', _context.t0);
88
96
  _context.t1 = _context.t0.code;
89
- _context.next = _context.t1 === 'auth/multi-factor-auth-required' ? 15 : _context.t1 === 'auth/requires-recent-login' ? 17 : _context.t1 === 'auth/invalid-login-credentials' ? 19 : 21;
97
+ _context.next = _context.t1 === 'auth/multi-factor-auth-required' ? 18 : _context.t1 === 'auth/requires-recent-login' ? 20 : _context.t1 === 'auth/invalid-login-credentials' ? 22 : 24;
90
98
  break;
91
- case 15:
99
+ case 18:
92
100
  // Initiate your second factor sign-in flow. (See next step.)
93
101
  _this.setState({
94
102
  waitingFor2fa: true,
95
103
  firebaseError: _context.t0
96
104
  });
97
105
  throw _context.t0;
98
- case 17:
106
+ case 20:
99
107
  // The user's last sign-in time does not meet the security threshold.
100
108
  _this.logoutUser();
101
- return _context.abrupt("break", 24);
102
- case 19:
109
+ return _context.abrupt("break", 27);
110
+ case 22:
103
111
  _context.t0.message = 'The credentials are not correct. Try again?';
104
112
  throw _context.t0;
105
- case 21:
113
+ case 24:
106
114
  console.log({
107
115
  error: _context.t0
108
116
  }); // Handle other errors, such as wrong passwords.
109
117
  throw _context.t0;
110
- case 24:
118
+ case 27:
111
119
  case "end":
112
120
  return _context.stop();
113
121
  }
114
- }, _callee, null, [[0, 9]]);
122
+ }, _callee, null, [[0, 12]]);
115
123
  }));
116
124
  return function (_x, _x2) {
117
125
  return _ref.apply(this, arguments);
@@ -287,45 +295,6 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
287
295
  return _ref5.apply(this, arguments);
288
296
  };
289
297
  }());
290
- _defineProperty(_assertThisInitialized(_this), "activateUser", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
291
- var _yield$Auth$activateU, user, access_token;
292
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
293
- while (1) switch (_context6.prev = _context6.next) {
294
- case 0:
295
- _context6.prev = 0;
296
- _context6.next = 3;
297
- return _Auth.default.activateUser();
298
- case 3:
299
- _yield$Auth$activateU = _context6.sent;
300
- user = _yield$Auth$activateU.user;
301
- access_token = _yield$Auth$activateU.access_token;
302
- _axios.default.defaults.headers.common.Authorization = "Bearer ".concat(access_token);
303
- _Auth.default.setAccessToken(access_token);
304
- _this.setState({
305
- user: user,
306
- isFetchingUser: false
307
- });
308
- _context6.next = 16;
309
- break;
310
- case 11:
311
- _context6.prev = 11;
312
- _context6.t0 = _context6["catch"](0);
313
- console.log('Error activating user: ', _context6.t0);
314
- _this.props.navigate('/oops', {
315
- state: {
316
- message: 'This activation token has expired.',
317
- hasActivationTokenExpired: true
318
- }
319
- });
320
- _this.setState({
321
- isFetchingUser: false
322
- });
323
- case 16:
324
- case "end":
325
- return _context6.stop();
326
- }
327
- }, _callee6, null, [[0, 11]]);
328
- })));
329
298
  _defineProperty(_assertThisInitialized(_this), "logoutUser", function () {
330
299
  var redirect = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
331
300
  _Auth.default.logout();
@@ -345,45 +314,45 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
345
314
  //user object will override any properties that are the same in the firebaseUser
346
315
  return Object.assign(firebaseUser, user);
347
316
  });
348
- _defineProperty(_assertThisInitialized(_this), "getUser", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
317
+ _defineProperty(_assertThisInitialized(_this), "getUser", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
349
318
  var accessToken,
350
319
  customValidateGetUser,
351
320
  result,
352
321
  firebaseUser,
353
322
  user,
354
323
  userAvatar,
355
- _args7 = arguments;
356
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
357
- while (1) switch (_context7.prev = _context7.next) {
324
+ _args6 = arguments;
325
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
326
+ while (1) switch (_context6.prev = _context6.next) {
358
327
  case 0:
359
- accessToken = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : _Auth.default.getAccessToken();
328
+ accessToken = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : _Auth.default.getAccessToken();
360
329
  if (accessToken) {
361
- _context7.next = 4;
330
+ _context6.next = 4;
362
331
  break;
363
332
  }
364
333
  _this.setState({
365
334
  isFetchingUser: false
366
335
  });
367
- return _context7.abrupt("return");
336
+ return _context6.abrupt("return");
368
337
  case 4:
369
338
  _axios.default.defaults.headers.common.Authorization = "Bearer ".concat(accessToken);
370
339
 
371
340
  //pass this function as a prop if you need any custom logic after user/get
372
341
  customValidateGetUser = _this.props.customValidateGetUser;
373
- _context7.prev = 6;
374
- _context7.next = 9;
342
+ _context6.prev = 6;
343
+ _context6.next = 9;
375
344
  return _Auth.default.getUser();
376
345
  case 9:
377
- result = _context7.sent;
346
+ result = _context6.sent;
378
347
  firebaseUser = _this.state.firebaseUser;
379
348
  if (firebaseUser) {
380
- _context7.next = 15;
349
+ _context6.next = 15;
381
350
  break;
382
351
  }
383
- _context7.next = 14;
352
+ _context6.next = 14;
384
353
  return _Auth.default.getFirebaseUser();
385
354
  case 14:
386
- firebaseUser = _context7.sent;
355
+ firebaseUser = _context6.sent;
387
356
  case 15:
388
357
  //merge firebaseUser and our user object
389
358
  user = _this.patchUserObject(result.user, firebaseUser);
@@ -404,20 +373,20 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
404
373
  _this.replaceLocationPathName();
405
374
 
406
375
  //if you need user info immediately after call (before setState is executed), you can use this
407
- return _context7.abrupt("return", user);
376
+ return _context6.abrupt("return", user);
408
377
  case 27:
409
- _context7.prev = 27;
410
- _context7.t0 = _context7["catch"](6);
378
+ _context6.prev = 27;
379
+ _context6.t0 = _context6["catch"](6);
411
380
  _this.setState({
412
381
  isFetchingUser: false
413
382
  });
414
- console.log("Error in getUser: ".concat(_context7.t0));
415
- throw _context7.t0;
383
+ console.log("Error in getUser: ".concat(_context6.t0));
384
+ throw _context6.t0;
416
385
  case 32:
417
386
  case "end":
418
- return _context7.stop();
387
+ return _context6.stop();
419
388
  }
420
- }, _callee7, null, [[6, 27]]);
389
+ }, _callee6, null, [[6, 27]]);
421
390
  })));
422
391
  _defineProperty(_assertThisInitialized(_this), "checkUserPhoto", function (avatar) {
423
392
  try {
@@ -447,63 +416,63 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
447
416
  });
448
417
  _defineProperty(_assertThisInitialized(_this), "uploadPhoto", function (file) {
449
418
  return new Promise( /*#__PURE__*/function () {
450
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(resolve, reject) {
419
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(resolve, reject) {
451
420
  var user, formData, result;
452
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
453
- while (1) switch (_context8.prev = _context8.next) {
421
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
422
+ while (1) switch (_context7.prev = _context7.next) {
454
423
  case 0:
455
- _context8.prev = 0;
424
+ _context7.prev = 0;
456
425
  user = _this.state.user;
457
426
  if (!(!user || !file)) {
458
- _context8.next = 4;
427
+ _context7.next = 4;
459
428
  break;
460
429
  }
461
- return _context8.abrupt("return");
430
+ return _context7.abrupt("return");
462
431
  case 4:
463
432
  formData = new FormData();
464
433
  formData.append('userId', user._id);
465
434
  formData.append('file', file);
466
- _context8.next = 9;
435
+ _context7.next = 9;
467
436
  return _Auth.default.uploadPhoto(formData);
468
437
  case 9:
469
- result = _context8.sent;
438
+ result = _context7.sent;
470
439
  _this.setState({
471
440
  avatar: "".concat(process.env.REACT_APP_PHOTO_API_URL, "/media/picture/view/").concat(user._id, "?ignore=").concat(Date.now())
472
441
  });
473
442
  resolve(result);
474
- _context8.next = 18;
443
+ _context7.next = 18;
475
444
  break;
476
445
  case 14:
477
- _context8.prev = 14;
478
- _context8.t0 = _context8["catch"](0);
479
- console.log("Error: ".concat(_context8.t0));
480
- reject(_context8.t0);
446
+ _context7.prev = 14;
447
+ _context7.t0 = _context7["catch"](0);
448
+ console.log("Error: ".concat(_context7.t0));
449
+ reject(_context7.t0);
481
450
  case 18:
482
451
  case "end":
483
- return _context8.stop();
452
+ return _context7.stop();
484
453
  }
485
- }, _callee8, null, [[0, 14]]);
454
+ }, _callee7, null, [[0, 14]]);
486
455
  }));
487
456
  return function (_x10, _x11) {
488
- return _ref8.apply(this, arguments);
457
+ return _ref7.apply(this, arguments);
489
458
  };
490
459
  }());
491
460
  });
492
- _defineProperty(_assertThisInitialized(_this), "deletePhoto", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
461
+ _defineProperty(_assertThisInitialized(_this), "deletePhoto", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
493
462
  var user, formData;
494
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
495
- while (1) switch (_context9.prev = _context9.next) {
463
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
464
+ while (1) switch (_context8.prev = _context8.next) {
496
465
  case 0:
497
466
  user = _this.state.user;
498
467
  if (user) {
499
- _context9.next = 3;
468
+ _context8.next = 3;
500
469
  break;
501
470
  }
502
- return _context9.abrupt("return");
471
+ return _context8.abrupt("return");
503
472
  case 3:
504
473
  formData = new FormData();
505
474
  formData.append('userId', user._id);
506
- _context9.next = 7;
475
+ _context8.next = 7;
507
476
  return _Auth.default.deletePhoto(formData);
508
477
  case 7:
509
478
  _this.setState({
@@ -511,9 +480,9 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
511
480
  });
512
481
  case 8:
513
482
  case "end":
514
- return _context9.stop();
483
+ return _context8.stop();
515
484
  }
516
- }, _callee9);
485
+ }, _callee8);
517
486
  })));
518
487
  _defineProperty(_assertThisInitialized(_this), "replaceLocationPathName", function () {
519
488
  var pathname = _this.props.location.pathname;
@@ -522,359 +491,336 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
522
491
  }
523
492
  });
524
493
  _defineProperty(_assertThisInitialized(_this), "updateUser", /*#__PURE__*/function () {
525
- var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(data) {
494
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(data) {
526
495
  var _yield$Auth$updateUse, user;
527
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
528
- while (1) switch (_context10.prev = _context10.next) {
496
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
497
+ while (1) switch (_context9.prev = _context9.next) {
529
498
  case 0:
530
- _context10.prev = 0;
531
- _context10.next = 3;
499
+ _context9.prev = 0;
500
+ _context9.next = 3;
532
501
  return _Auth.default.updateUser(data);
533
502
  case 3:
534
- _yield$Auth$updateUse = _context10.sent;
503
+ _yield$Auth$updateUse = _context9.sent;
535
504
  user = _yield$Auth$updateUse.user;
536
505
  _this.setUser(user);
537
- _context10.next = 12;
506
+ _context9.next = 12;
538
507
  break;
539
508
  case 8:
540
- _context10.prev = 8;
541
- _context10.t0 = _context10["catch"](0);
542
- console.log("Error updating the user: ".concat(_context10.t0));
543
- throw _context10.t0;
509
+ _context9.prev = 8;
510
+ _context9.t0 = _context9["catch"](0);
511
+ console.log("Error updating the user: ".concat(_context9.t0));
512
+ throw _context9.t0;
544
513
  case 12:
545
514
  case "end":
546
- return _context10.stop();
515
+ return _context9.stop();
547
516
  }
548
- }, _callee10, null, [[0, 8]]);
517
+ }, _callee9, null, [[0, 8]]);
549
518
  }));
550
519
  return function (_x12) {
551
- return _ref10.apply(this, arguments);
520
+ return _ref9.apply(this, arguments);
552
521
  };
553
522
  }());
554
523
  _defineProperty(_assertThisInitialized(_this), "checkIfPrivateInvestor", /*#__PURE__*/function () {
555
- var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(project) {
524
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(project) {
556
525
  var user,
557
526
  returnData,
558
527
  dataToSend,
559
528
  isPrivateInvestor,
560
529
  userCopy,
561
- _args11 = arguments;
562
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
563
- while (1) switch (_context11.prev = _context11.next) {
530
+ _args10 = arguments;
531
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
532
+ while (1) switch (_context10.prev = _context10.next) {
564
533
  case 0:
565
- user = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : _this.state.user;
566
- returnData = _args11.length > 2 && _args11[2] !== undefined ? _args11[2] : false;
534
+ user = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : _this.state.user;
535
+ returnData = _args10.length > 2 && _args10[2] !== undefined ? _args10[2] : false;
567
536
  if (!(!user || !project)) {
568
- _context11.next = 4;
537
+ _context10.next = 4;
569
538
  break;
570
539
  }
571
- return _context11.abrupt("return");
540
+ return _context10.abrupt("return");
572
541
  case 4:
573
- _context11.prev = 4;
542
+ _context10.prev = 4;
574
543
  dataToSend = {
575
544
  userId: user._id,
576
545
  projectId: project._id
577
546
  };
578
- _context11.next = 8;
547
+ _context10.next = 8;
579
548
  return _Auth.default.checkPrivateInvestor(dataToSend);
580
549
  case 8:
581
- isPrivateInvestor = _context11.sent;
550
+ isPrivateInvestor = _context10.sent;
582
551
  userCopy = _objectSpread({}, user);
583
552
  userCopy.isPrivateInvestor = isPrivateInvestor.isAllowed;
584
553
  userCopy.privateInvestorStatus = isPrivateInvestor.status;
585
554
  if (!returnData) {
586
- _context11.next = 16;
555
+ _context10.next = 16;
587
556
  break;
588
557
  }
589
- return _context11.abrupt("return", userCopy);
558
+ return _context10.abrupt("return", userCopy);
590
559
  case 16:
591
560
  _this.setState({
592
561
  user: userCopy
593
562
  });
594
563
  case 17:
595
- _context11.next = 23;
564
+ _context10.next = 23;
596
565
  break;
597
566
  case 19:
598
- _context11.prev = 19;
599
- _context11.t0 = _context11["catch"](4);
600
- console.log('🚀 ~ error in checkPrivateInvestor', _context11.t0);
601
- throw _context11.t0;
567
+ _context10.prev = 19;
568
+ _context10.t0 = _context10["catch"](4);
569
+ console.log('🚀 ~ error in checkPrivateInvestor', _context10.t0);
570
+ throw _context10.t0;
602
571
  case 23:
603
572
  case "end":
604
- return _context11.stop();
573
+ return _context10.stop();
605
574
  }
606
- }, _callee11, null, [[4, 19]]);
575
+ }, _callee10, null, [[4, 19]]);
607
576
  }));
608
577
  return function (_x13) {
609
- return _ref11.apply(this, arguments);
578
+ return _ref10.apply(this, arguments);
610
579
  };
611
580
  }());
612
581
  _defineProperty(_assertThisInitialized(_this), "checkIfUserSubscribed", /*#__PURE__*/function () {
613
- var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(project) {
582
+ var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(project) {
614
583
  var user,
615
584
  returnData,
616
585
  dataToSend,
617
586
  isSubscribed,
618
587
  userCopy,
619
- _args12 = arguments;
620
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
621
- while (1) switch (_context12.prev = _context12.next) {
588
+ _args11 = arguments;
589
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
590
+ while (1) switch (_context11.prev = _context11.next) {
622
591
  case 0:
623
- user = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : _this.state.user;
624
- returnData = _args12.length > 2 && _args12[2] !== undefined ? _args12[2] : false;
592
+ user = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : _this.state.user;
593
+ returnData = _args11.length > 2 && _args11[2] !== undefined ? _args11[2] : false;
625
594
  if (!(!user || !project)) {
626
- _context12.next = 4;
595
+ _context11.next = 4;
627
596
  break;
628
597
  }
629
- return _context12.abrupt("return");
598
+ return _context11.abrupt("return");
630
599
  case 4:
631
- _context12.prev = 4;
600
+ _context11.prev = 4;
632
601
  dataToSend = {
633
602
  listName: project.name,
634
603
  email: user.email
635
604
  };
636
- _context12.next = 8;
605
+ _context11.next = 8;
637
606
  return _Auth.default.checkIfUserSubscribed(dataToSend);
638
607
  case 8:
639
- isSubscribed = _context12.sent;
608
+ isSubscribed = _context11.sent;
640
609
  userCopy = _objectSpread({}, user);
641
610
  userCopy.isSubscribed = isSubscribed;
642
611
  if (!returnData) {
643
- _context12.next = 15;
612
+ _context11.next = 15;
644
613
  break;
645
614
  }
646
- return _context12.abrupt("return", userCopy);
615
+ return _context11.abrupt("return", userCopy);
647
616
  case 15:
648
617
  _this.setState({
649
618
  user: userCopy
650
619
  });
651
620
  case 16:
652
- _context12.next = 22;
621
+ _context11.next = 22;
653
622
  break;
654
623
  case 18:
655
- _context12.prev = 18;
656
- _context12.t0 = _context12["catch"](4);
657
- console.log('🚀 ~ error in checkIfUserSubscribed', _context12.t0);
658
- throw _context12.t0;
624
+ _context11.prev = 18;
625
+ _context11.t0 = _context11["catch"](4);
626
+ console.log('🚀 ~ error in checkIfUserSubscribed', _context11.t0);
627
+ throw _context11.t0;
659
628
  case 22:
660
629
  case "end":
661
- return _context12.stop();
630
+ return _context11.stop();
662
631
  }
663
- }, _callee12, null, [[4, 18]]);
632
+ }, _callee11, null, [[4, 18]]);
664
633
  }));
665
634
  return function (_x14) {
666
- return _ref12.apply(this, arguments);
667
- };
668
- }());
669
- _defineProperty(_assertThisInitialized(_this), "resendActivationEmail", /*#__PURE__*/function () {
670
- var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(data) {
671
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
672
- while (1) switch (_context13.prev = _context13.next) {
673
- case 0:
674
- _context13.prev = 0;
675
- _context13.next = 3;
676
- return _Auth.default.resendActivationEmail(data);
677
- case 3:
678
- _context13.next = 9;
679
- break;
680
- case 5:
681
- _context13.prev = 5;
682
- _context13.t0 = _context13["catch"](0);
683
- console.log("Error resending activation email: ".concat(_context13.t0));
684
- throw _context13.t0;
685
- case 9:
686
- case "end":
687
- return _context13.stop();
688
- }
689
- }, _callee13, null, [[0, 5]]);
690
- }));
691
- return function (_x15) {
692
- return _ref13.apply(this, arguments);
635
+ return _ref11.apply(this, arguments);
693
636
  };
694
637
  }());
695
- _defineProperty(_assertThisInitialized(_this), "handleVerifyEmail", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
638
+ _defineProperty(_assertThisInitialized(_this), "handleVerifyEmail", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
696
639
  var location, query, oobCode;
697
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
698
- while (1) switch (_context14.prev = _context14.next) {
640
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
641
+ while (1) switch (_context12.prev = _context12.next) {
699
642
  case 0:
700
643
  location = _this.props.location;
701
- _context14.prev = 1;
644
+ _context12.prev = 1;
702
645
  query = new URLSearchParams(location.search);
703
646
  oobCode = query.get('oobCode');
704
- _context14.next = 6;
647
+ _context12.next = 6;
705
648
  return _Auth.default.handleVerifyEmail(oobCode);
706
649
  case 6:
707
- _context14.next = 21;
650
+ _context12.next = 21;
708
651
  break;
709
652
  case 8:
710
- _context14.prev = 8;
711
- _context14.t0 = _context14["catch"](1);
712
- _context14.t1 = _context14.t0 === null || _context14.t0 === void 0 ? void 0 : _context14.t0.code;
713
- _context14.next = _context14.t1 === 'auth/expired-action-code' ? 13 : _context14.t1 === 'auth/invalid-action-code' ? 15 : _context14.t1 === 'auth/user-disabled' ? 17 : 19;
653
+ _context12.prev = 8;
654
+ _context12.t0 = _context12["catch"](1);
655
+ _context12.t1 = _context12.t0 === null || _context12.t0 === void 0 ? void 0 : _context12.t0.code;
656
+ _context12.next = _context12.t1 === 'auth/expired-action-code' ? 13 : _context12.t1 === 'auth/invalid-action-code' ? 15 : _context12.t1 === 'auth/user-disabled' ? 17 : 19;
714
657
  break;
715
658
  case 13:
716
- _context14.t0.message = 'This link has expired. Please try reseting password again.';
717
- return _context14.abrupt("break", 20);
659
+ _context12.t0.message = 'This link has expired. Please try verifying email again.';
660
+ return _context12.abrupt("break", 20);
718
661
  case 15:
719
- _context14.t0.message = 'This link is invalid. Please try reseting password again.';
720
- return _context14.abrupt("break", 20);
662
+ _context12.t0.message = 'This link is invalid. Please try verifying email again.';
663
+ return _context12.abrupt("break", 20);
721
664
  case 17:
722
- _context14.t0.message = 'Your account has been disabled. Please contact our support.';
723
- return _context14.abrupt("break", 20);
665
+ _context12.t0.message = 'Your account has been disabled. Please contact our support.';
666
+ return _context12.abrupt("break", 20);
724
667
  case 19:
725
- return _context14.abrupt("break", 20);
668
+ return _context12.abrupt("break", 20);
726
669
  case 20:
727
- throw _context14.t0;
670
+ _this.setState({
671
+ verifyEmailError: _context12.t0
672
+ });
673
+ //throw error
728
674
  case 21:
729
675
  case "end":
730
- return _context14.stop();
676
+ return _context12.stop();
731
677
  }
732
- }, _callee14, null, [[1, 8]]);
678
+ }, _callee12, null, [[1, 8]]);
733
679
  })));
734
680
  _defineProperty(_assertThisInitialized(_this), "handleResetPassword", /*#__PURE__*/function () {
735
- var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(password) {
681
+ var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(password) {
736
682
  var location, query, oobCode;
737
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
738
- while (1) switch (_context15.prev = _context15.next) {
683
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
684
+ while (1) switch (_context13.prev = _context13.next) {
739
685
  case 0:
740
686
  location = _this.props.location;
741
- _context15.prev = 1;
687
+ _context13.prev = 1;
742
688
  query = new URLSearchParams(location.search);
743
689
  oobCode = query.get('oobCode');
744
- _context15.next = 6;
690
+ _context13.next = 6;
745
691
  return _Auth.default.handleResetPassword(oobCode, password);
746
692
  case 6:
747
- _context15.next = 21;
693
+ _context13.next = 21;
748
694
  break;
749
695
  case 8:
750
- _context15.prev = 8;
751
- _context15.t0 = _context15["catch"](1);
752
- _context15.t1 = _context15.t0 === null || _context15.t0 === void 0 ? void 0 : _context15.t0.code;
753
- _context15.next = _context15.t1 === 'auth/expired-action-code' ? 13 : _context15.t1 === 'auth/invalid-action-code' ? 15 : _context15.t1 === 'auth/user-disabled' ? 17 : 19;
696
+ _context13.prev = 8;
697
+ _context13.t0 = _context13["catch"](1);
698
+ _context13.t1 = _context13.t0 === null || _context13.t0 === void 0 ? void 0 : _context13.t0.code;
699
+ _context13.next = _context13.t1 === 'auth/expired-action-code' ? 13 : _context13.t1 === 'auth/invalid-action-code' ? 15 : _context13.t1 === 'auth/user-disabled' ? 17 : 19;
754
700
  break;
755
701
  case 13:
756
- _context15.t0.message = 'This link has expired. Please try reseting password again.';
757
- return _context15.abrupt("break", 20);
702
+ _context13.t0.message = 'This link has expired. Please try reseting password again.';
703
+ return _context13.abrupt("break", 20);
758
704
  case 15:
759
- _context15.t0.message = 'This link is invalid. Please try reseting password again.';
760
- return _context15.abrupt("break", 20);
705
+ _context13.t0.message = 'This link is invalid. Please try reseting password again.';
706
+ return _context13.abrupt("break", 20);
761
707
  case 17:
762
- _context15.t0.message = 'Your account has been disabled. Please contact our support.';
763
- return _context15.abrupt("break", 20);
708
+ _context13.t0.message = 'Your account has been disabled. Please contact our support.';
709
+ return _context13.abrupt("break", 20);
764
710
  case 19:
765
- return _context15.abrupt("break", 20);
711
+ return _context13.abrupt("break", 20);
766
712
  case 20:
767
- throw _context15.t0;
713
+ throw _context13.t0;
768
714
  case 21:
769
715
  case "end":
770
- return _context15.stop();
716
+ return _context13.stop();
771
717
  }
772
- }, _callee15, null, [[1, 8]]);
718
+ }, _callee13, null, [[1, 8]]);
773
719
  }));
774
- return function (_x16) {
775
- return _ref15.apply(this, arguments);
720
+ return function (_x15) {
721
+ return _ref13.apply(this, arguments);
776
722
  };
777
723
  }());
778
- _defineProperty(_assertThisInitialized(_this), "sendWelcomeEmail", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
779
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
780
- while (1) switch (_context16.prev = _context16.next) {
724
+ _defineProperty(_assertThisInitialized(_this), "sendWelcomeEmail", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
725
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
726
+ while (1) switch (_context14.prev = _context14.next) {
781
727
  case 0:
782
- _context16.prev = 0;
783
- _context16.next = 3;
728
+ _context14.prev = 0;
729
+ _context14.next = 3;
784
730
  return _Auth.default.sendWelcomeEmail();
785
731
  case 3:
786
- _context16.next = 8;
732
+ _context14.next = 8;
787
733
  break;
788
734
  case 5:
789
- _context16.prev = 5;
790
- _context16.t0 = _context16["catch"](0);
791
- console.log("Error sending welcome email: ".concat(_context16.t0));
735
+ _context14.prev = 5;
736
+ _context14.t0 = _context14["catch"](0);
737
+ console.log("Error sending welcome email: ".concat(_context14.t0));
792
738
  // No need to throw error, let the app continue even if it fails
793
739
  case 8:
794
740
  case "end":
795
- return _context16.stop();
741
+ return _context14.stop();
796
742
  }
797
- }, _callee16, null, [[0, 5]]);
743
+ }, _callee14, null, [[0, 5]]);
798
744
  })));
799
745
  _defineProperty(_assertThisInitialized(_this), "uploaProofOfAddress", /*#__PURE__*/function () {
800
- var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(data, ip) {
746
+ var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(data, ip) {
801
747
  var user;
802
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
803
- while (1) switch (_context17.prev = _context17.next) {
748
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
749
+ while (1) switch (_context15.prev = _context15.next) {
804
750
  case 0:
805
- _context17.prev = 0;
806
- _context17.next = 3;
751
+ _context15.prev = 0;
752
+ _context15.next = 3;
807
753
  return _Auth.default.uploaProofOfAddress(data, ip);
808
754
  case 3:
809
- user = _context17.sent;
755
+ user = _context15.sent;
810
756
  _this.setUser(user);
811
- _context17.next = 11;
757
+ _context15.next = 11;
812
758
  break;
813
759
  case 7:
814
- _context17.prev = 7;
815
- _context17.t0 = _context17["catch"](0);
816
- console.log("Error uploading proof of address: ".concat(_context17.t0));
817
- throw _context17.t0;
760
+ _context15.prev = 7;
761
+ _context15.t0 = _context15["catch"](0);
762
+ console.log("Error uploading proof of address: ".concat(_context15.t0));
763
+ throw _context15.t0;
818
764
  case 11:
819
765
  case "end":
820
- return _context17.stop();
766
+ return _context15.stop();
821
767
  }
822
- }, _callee17, null, [[0, 7]]);
768
+ }, _callee15, null, [[0, 7]]);
823
769
  }));
824
- return function (_x17, _x18) {
825
- return _ref17.apply(this, arguments);
770
+ return function (_x16, _x17) {
771
+ return _ref15.apply(this, arguments);
826
772
  };
827
773
  }());
828
774
  _defineProperty(_assertThisInitialized(_this), "validateGreenWalletId", /*#__PURE__*/function () {
829
- var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(id) {
830
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
831
- while (1) switch (_context18.prev = _context18.next) {
775
+ var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(id) {
776
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
777
+ while (1) switch (_context16.prev = _context16.next) {
832
778
  case 0:
833
- _context18.prev = 0;
834
- _context18.next = 3;
779
+ _context16.prev = 0;
780
+ _context16.next = 3;
835
781
  return _Auth.default.validateGreenWalletId(id);
836
782
  case 3:
837
- return _context18.abrupt("return", _context18.sent);
783
+ return _context16.abrupt("return", _context16.sent);
838
784
  case 6:
839
- _context18.prev = 6;
840
- _context18.t0 = _context18["catch"](0);
841
- console.log("Error validating Green Wallet ID: ".concat(_context18.t0));
842
- throw _context18.t0;
785
+ _context16.prev = 6;
786
+ _context16.t0 = _context16["catch"](0);
787
+ console.log("Error validating Green Wallet ID: ".concat(_context16.t0));
788
+ throw _context16.t0;
843
789
  case 10:
844
790
  case "end":
845
- return _context18.stop();
791
+ return _context16.stop();
846
792
  }
847
- }, _callee18, null, [[0, 6]]);
793
+ }, _callee16, null, [[0, 6]]);
848
794
  }));
849
- return function (_x19) {
850
- return _ref18.apply(this, arguments);
795
+ return function (_x18) {
796
+ return _ref16.apply(this, arguments);
851
797
  };
852
798
  }());
853
799
  _defineProperty(_assertThisInitialized(_this), "createWallet", /*#__PURE__*/function () {
854
- var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(data) {
800
+ var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(data) {
855
801
  var wallet;
856
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
857
- while (1) switch (_context19.prev = _context19.next) {
802
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
803
+ while (1) switch (_context17.prev = _context17.next) {
858
804
  case 0:
859
- _context19.prev = 0;
860
- _context19.next = 3;
805
+ _context17.prev = 0;
806
+ _context17.next = 3;
861
807
  return _Auth.default.createWallet(data);
862
808
  case 3:
863
- wallet = _context19.sent;
864
- return _context19.abrupt("return", wallet);
809
+ wallet = _context17.sent;
810
+ return _context17.abrupt("return", wallet);
865
811
  case 7:
866
- _context19.prev = 7;
867
- _context19.t0 = _context19["catch"](0);
868
- console.log("Error creating wallet: ".concat(_context19.t0));
869
- throw _context19.t0;
812
+ _context17.prev = 7;
813
+ _context17.t0 = _context17["catch"](0);
814
+ console.log("Error creating wallet: ".concat(_context17.t0));
815
+ throw _context17.t0;
870
816
  case 11:
871
817
  case "end":
872
- return _context19.stop();
818
+ return _context17.stop();
873
819
  }
874
- }, _callee19, null, [[0, 7]]);
820
+ }, _callee17, null, [[0, 7]]);
875
821
  }));
876
- return function (_x20) {
877
- return _ref19.apply(this, arguments);
822
+ return function (_x19) {
823
+ return _ref17.apply(this, arguments);
878
824
  };
879
825
  }());
880
826
  _defineProperty(_assertThisInitialized(_this), "setUser", function (user) {
@@ -886,12 +832,12 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
886
832
  });
887
833
  });
888
834
  _defineProperty(_assertThisInitialized(_this), "fetchLastTime", /*#__PURE__*/function () {
889
- var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(projectName, page, userId) {
835
+ var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(projectName, page, userId) {
890
836
  var filterBody, response;
891
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
892
- while (1) switch (_context20.prev = _context20.next) {
837
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
838
+ while (1) switch (_context18.prev = _context18.next) {
893
839
  case 0:
894
- _context20.prev = 0;
840
+ _context18.prev = 0;
895
841
  filterBody = {
896
842
  projectName: projectName,
897
843
  page: page
@@ -899,25 +845,25 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
899
845
  if (userId) {
900
846
  filterBody.userId = userId;
901
847
  }
902
- _context20.next = 5;
848
+ _context18.next = 5;
903
849
  return _Auth.default.fetchTrackingUserLastTime({
904
850
  filter: filterBody
905
851
  });
906
852
  case 5:
907
- response = _context20.sent;
908
- return _context20.abrupt("return", response);
853
+ response = _context18.sent;
854
+ return _context18.abrupt("return", response);
909
855
  case 9:
910
- _context20.prev = 9;
911
- _context20.t0 = _context20["catch"](0);
912
- console.log(' error', _context20.t0);
856
+ _context18.prev = 9;
857
+ _context18.t0 = _context18["catch"](0);
858
+ console.log(' error', _context18.t0);
913
859
  case 12:
914
860
  case "end":
915
- return _context20.stop();
861
+ return _context18.stop();
916
862
  }
917
- }, _callee20, null, [[0, 9]]);
863
+ }, _callee18, null, [[0, 9]]);
918
864
  }));
919
- return function (_x21, _x22, _x23) {
920
- return _ref20.apply(this, arguments);
865
+ return function (_x20, _x21, _x22) {
866
+ return _ref18.apply(this, arguments);
921
867
  };
922
868
  }());
923
869
  return _this;
@@ -956,7 +902,7 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
956
902
  checkIfPrivateInvestor: this.checkIfPrivateInvestor,
957
903
  checkIfUserSubscribed: this.checkIfUserSubscribed,
958
904
  sendWelcomeEmail: this.sendWelcomeEmail,
959
- resendActivationEmail: this.resendActivationEmail,
905
+ resendActivationEmail: _Auth.default.resendActivationEmail,
960
906
  uploaProofOfAddress: this.uploaProofOfAddress,
961
907
  validateGreenWalletId: this.validateGreenWalletId,
962
908
  fetchLastTime: this.fetchLastTime,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stokr/components-library",
3
- "version": "2.0.0-beta.7",
3
+ "version": "2.0.0-beta.9",
4
4
  "description": "STOKR - Components Library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",