@stokr/components-library 2.3.41-beta.15 → 2.3.41-beta.17

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,48 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.ResendConfirmationCodeModalDefault = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _ComponentWrapper = require("../ComponentWrapper/ComponentWrapper.styles");
9
+ var _global = _interopRequireDefault(require("../../styles/global"));
10
+ var _ResendConfirmationCodeModal = _interopRequireDefault(require("./ResendConfirmationCodeModal"));
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ var _default = {
13
+ title: 'Components Library/Resend Confirmation Code Modal',
14
+ component: _ResendConfirmationCodeModal.default,
15
+ argTypes: {
16
+ isModalOpen: {
17
+ type: 'boolean',
18
+ defaultValue: true
19
+ },
20
+ onModalClose: {
21
+ type: 'function',
22
+ action: 'onModalClose',
23
+ required: true
24
+ },
25
+ onFormSend: {
26
+ type: 'function',
27
+ action: 'onFormSend',
28
+ required: true
29
+ },
30
+ onModalSwitch: {
31
+ type: 'function',
32
+ action: 'onModalSwitch',
33
+ required: true
34
+ }
35
+ }
36
+ };
37
+ exports.default = _default;
38
+ var Template = function Template(args) {
39
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_global.default, null), /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, null, /*#__PURE__*/_react.default.createElement(_ResendConfirmationCodeModal.default, args)));
40
+ };
41
+ var ResendConfirmationCodeModalDefault = Template.bind({});
42
+ exports.ResendConfirmationCodeModalDefault = ResendConfirmationCodeModalDefault;
43
+ ResendConfirmationCodeModalDefault.args = {
44
+ isModalOpen: true,
45
+ onModalClose: function onModalClose() {},
46
+ onFormSend: function onFormSend() {},
47
+ onModalSwitch: function onModalSwitch() {}
48
+ };
@@ -5,9 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _react = _interopRequireWildcard(require("react"));
8
+ var _react = _interopRequireDefault(require("react"));
9
9
  var _propTypes = _interopRequireDefault(require("prop-types"));
10
10
  var _formik = require("formik");
11
+ var _formikPersist = require("formik-persist");
11
12
  var Yup = _interopRequireWildcard(require("yup"));
12
13
  var _Modal = require("../Modal/Modal");
13
14
  var _Form = _interopRequireWildcard(require("../Form/Form"));
@@ -16,64 +17,26 @@ var _InputPassword = _interopRequireDefault(require("../Input/InputPassword"));
16
17
  var _Button = _interopRequireDefault(require("../Button/Button.styles"));
17
18
  var _Grid = require("../Grid/Grid.styles");
18
19
  var _ComponentWrapper = _interopRequireDefault(require("../ComponentWrapper/ComponentWrapper.styles"));
19
- var _AuthContext = require("../../context/AuthContext");
20
- var _reactRouterDom = require("react-router-dom");
21
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
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); }
23
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; }
24
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
25
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
26
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
27
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
28
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
29
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
30
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
31
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
32
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
33
- 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; } }
34
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35
23
  var ResetPasswordModal = function ResetPasswordModal(_ref) {
36
24
  var isModalOpen = _ref.isModalOpen,
37
25
  onModalClose = _ref.onModalClose,
38
26
  onFormSend = _ref.onFormSend,
39
27
  onModalSwitch = _ref.onModalSwitch,
40
- _ref$popupError = _ref.popupError,
41
- popupError = _ref$popupError === void 0 ? {
42
- popup: null,
43
- message: ''
44
- } : _ref$popupError,
45
- _ref$isActionLoading = _ref.isActionLoading,
46
- isActionLoading = _ref$isActionLoading === void 0 ? false : _ref$isActionLoading;
47
- var _useState = (0, _react.useState)(false),
48
- _useState2 = _slicedToArray(_useState, 2),
49
- passwordResetSuccess = _useState2[0],
50
- setPasswordResetSuccess = _useState2[1];
51
- var location = (0, _reactRouterDom.useLocation)();
28
+ popupError = _ref.popupError,
29
+ isActionLoading = _ref.isActionLoading;
52
30
  var initialValues = {
53
31
  password: '',
54
32
  confirmPassword: ''
55
33
  };
56
34
  var validationSchema = Yup.object().shape({
57
- password: Yup.string().required("Oops, this can't be blank"),
58
- confirmPassword: Yup.string().required("Oops, this can't be blank")
35
+ password: Yup.string().required('Oops, this cant be blank'),
36
+ confirmPassword: Yup.string().required('Oops, this cant be blank')
59
37
  });
60
-
61
- // close modal after successful reset
62
- (0, _react.useEffect)(function () {
63
- if (passwordResetSuccess) {
64
- var timer = setTimeout(function () {
65
- onModalClose();
66
- }, 1500);
67
- return function () {
68
- return clearTimeout(timer);
69
- };
70
- }
71
- }, [passwordResetSuccess, onModalClose]);
72
- if (!isModalOpen) {
73
- return null;
74
- }
75
38
  return /*#__PURE__*/_react.default.createElement(_Modal.Modal, {
76
- isOpen: true,
39
+ isOpen: isModalOpen,
77
40
  onClose: onModalClose
78
41
  }, /*#__PURE__*/_react.default.createElement(_Grid.Row, null, /*#__PURE__*/_react.default.createElement(_Grid.Column, {
79
42
  part: 8
@@ -87,25 +50,11 @@ var ResetPasswordModal = function ResetPasswordModal(_ref) {
87
50
  onClick: onModalSwitch
88
51
  }, "Log in")))), /*#__PURE__*/_react.default.createElement(_Grid.Column, {
89
52
  part: 8
90
- }, /*#__PURE__*/_react.default.createElement(_Modal.ModalInner, null, passwordResetSuccess ? /*#__PURE__*/_react.default.createElement(_Text.default, null, /*#__PURE__*/_react.default.createElement("h3", null, "SUCCESS!"), /*#__PURE__*/_react.default.createElement("p", null, "Your password has been reset successfully."), /*#__PURE__*/_react.default.createElement("p", null, "Proceeding to login...")) : /*#__PURE__*/_react.default.createElement(_formik.Formik, {
53
+ }, /*#__PURE__*/_react.default.createElement(_Modal.ModalInner, null, /*#__PURE__*/_react.default.createElement(_formik.Formik, {
91
54
  initialValues: initialValues,
92
55
  validationSchema: validationSchema,
93
56
  onSubmit: function onSubmit(values) {
94
- var search = location.search;
95
- var query = new URLSearchParams(search);
96
- var oobCode = query.get('oobCode');
97
- var promise = onFormSend(_objectSpread(_objectSpread({}, values), {}, {
98
- oobCode: oobCode
99
- }));
100
- if (promise && typeof promise.then === 'function') {
101
- promise.then(function (response) {
102
- setPasswordResetSuccess(true);
103
- }).catch(function (err) {
104
- console.error('Error during password reset:', err);
105
- });
106
- } else {
107
- setPasswordResetSuccess(true);
108
- }
57
+ onFormSend(values);
109
58
  }
110
59
  }, function (_ref2) {
111
60
  var values = _ref2.values,
@@ -119,6 +68,12 @@ var ResetPasswordModal = function ResetPasswordModal(_ref) {
119
68
  setFieldValue(field.name, field.value, false);
120
69
  setFieldTouched(field.name);
121
70
  };
71
+
72
+ // const submitDisabled =
73
+ // passwordStrengthMeter(values.password) !== 5 ||
74
+ // values.password !== values.confirmPassword ||
75
+ // isActionLoading === 'resetPassword'
76
+
122
77
  var submitDisabled = values.password.length <= 5 || values.password !== values.confirmPassword || isActionLoading === 'resetPassword';
123
78
  return /*#__PURE__*/_react.default.createElement(_Form.default, null, /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement(_ComponentWrapper.default, {
124
79
  noPadding: true
@@ -133,9 +88,16 @@ var ResetPasswordModal = function ResetPasswordModal(_ref) {
133
88
  error: !!errors.password,
134
89
  touched: !!touched.password,
135
90
  info: "For a stronger password, try a mix of lowercase, capitals, numbers and special characters."
91
+ // showStrength
136
92
  }), /*#__PURE__*/_react.default.createElement(_Form.FormError, {
137
93
  show: errors.password && touched.password
138
- }, errors.password), /*#__PURE__*/_react.default.createElement(_Form.FormError, {
94
+ }, errors.password), /*#__PURE__*/_react.default.createElement(_Form.FormError
95
+ // show={
96
+ // !errors.password &&
97
+ // touched.password &&
98
+ // passwordStrengthMeter(values.password) !== 5
99
+ // }
100
+ , {
139
101
  show: !errors.password && touched.password && values.password.length <= 5
140
102
  }, "The password must be at least 6 characters long"))), /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement(_ComponentWrapper.default, {
141
103
  noPadding: true
@@ -149,6 +111,8 @@ var ResetPasswordModal = function ResetPasswordModal(_ref) {
149
111
  onBlur: handleBlur,
150
112
  error: !!errors.confirmPassword,
151
113
  touched: !!touched.confirmPassword
114
+ // info="Password input popup"
115
+ // showStrength
152
116
  }), /*#__PURE__*/_react.default.createElement(_Form.FormError, {
153
117
  show: errors.confirmPassword && touched.confirmPassword
154
118
  }, errors.confirmPassword))), /*#__PURE__*/_react.default.createElement(_ComponentWrapper.default, {
@@ -175,16 +139,7 @@ ResetPasswordModal.propTypes = {
175
139
  isModalOpen: _propTypes.default.bool.isRequired,
176
140
  onModalClose: _propTypes.default.func.isRequired,
177
141
  onFormSend: _propTypes.default.func.isRequired,
178
- onModalSwitch: _propTypes.default.func.isRequired,
179
- popupError: _propTypes.default.object,
180
- isActionLoading: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.string])
181
- };
182
- ResetPasswordModal.defaultProps = {
183
- popupError: {
184
- popup: null,
185
- message: ''
186
- },
187
- isActionLoading: false
142
+ onModalSwitch: _propTypes.default.func.isRequired
188
143
  };
189
144
  var _default = ResetPasswordModal;
190
145
  exports.default = _default;
@@ -17,7 +17,6 @@ var _LoginModal = _interopRequireDefault(require("../LoginModal/LoginModal"));
17
17
  var _VerifyEmailModal = _interopRequireDefault(require("../VerifyEmailModal/VerifyEmailModal"));
18
18
  var _Header = _interopRequireDefault(require("../Header/Header"));
19
19
  var _FA = require("../2FA");
20
- var _ResendConfirmationCodeModal = _interopRequireDefault(require("../ResendConfirmationCodeModal/ResendConfirmationCodeModal"));
21
20
  var _auth = _interopRequireDefault(require("../../api/auth"));
22
21
  var _fetchDataPublic = _interopRequireDefault(require("../../api/fetchDataPublic"));
23
22
  var _AuthContext = require("../../context/AuthContext");
@@ -27,9 +26,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
27
26
  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); }
28
27
  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; }
29
28
  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); }
29
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
30
30
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
31
31
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
32
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
33
32
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
34
33
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
35
34
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -56,7 +55,6 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
56
55
  _inherits(HeaderHoClass, _Component);
57
56
  var _super = _createSuper(HeaderHoClass);
58
57
  function HeaderHoClass() {
59
- var _isModalOpen;
60
58
  var _this;
61
59
  _classCallCheck(this, HeaderHoClass);
62
60
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
@@ -65,7 +63,7 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
65
63
  _this = _super.call.apply(_super, [this].concat(args));
66
64
  _defineProperty(_assertThisInitialized(_this), "state", {
67
65
  mobileMenuOpen: false,
68
- isModalOpen: (_isModalOpen = {
66
+ isModalOpen: _defineProperty({
69
67
  login: false,
70
68
  signUp: false,
71
69
  terms: false,
@@ -76,7 +74,7 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
76
74
  enter2fa: false,
77
75
  resetCode: false,
78
76
  verifyEmail: false
79
- }, _defineProperty(_isModalOpen, "resetPassword", false), _defineProperty(_isModalOpen, "resendConfirmation", false), _isModalOpen),
77
+ }, "resetPassword", false),
80
78
  userInfo: {
81
79
  email: undefined,
82
80
  password: undefined,
@@ -93,70 +91,112 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
93
91
  message: undefined
94
92
  },
95
93
  isActionLoading: undefined,
96
- termsData: undefined
94
+ termsData: undefined,
95
+ isPasswordResetLinkExpired: false
97
96
  });
98
- _defineProperty(_assertThisInitialized(_this), "checkTokenExpiration", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
99
- var location, search, query, oobCode, result;
97
+ _defineProperty(_assertThisInitialized(_this), "componentDidMount", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
98
+ var _this$props, isResetPassword, urlParams, oobCode, tokenStatus;
100
99
  return _regeneratorRuntime().wrap(function _callee$(_context) {
101
100
  while (1) switch (_context.prev = _context.next) {
102
101
  case 0:
103
- location = _this.props.location;
104
- if (location) {
105
- _context.next = 3;
102
+ _this$props = _this.props, isResetPassword = _this$props.isResetPassword, urlParams = _this$props.urlParams; // check if reset password modal and extract oobCode from URL params
103
+ if (!isResetPassword) {
104
+ _context.next = 15;
105
+ break;
106
+ }
107
+ oobCode = urlParams === null || urlParams === void 0 ? void 0 : urlParams.getUrlParam('oobCode');
108
+ if (!(oobCode && oobCode !== '')) {
109
+ _context.next = 15;
106
110
  break;
107
111
  }
108
- return _context.abrupt("return", {
112
+ _context.prev = 4;
113
+ _context.next = 7;
114
+ return _this.checkTokenExpiration();
115
+ case 7:
116
+ tokenStatus = _context.sent;
117
+ _this.setState(function (prevState) {
118
+ return _objectSpread(_objectSpread({}, prevState), {}, {
119
+ isPasswordResetLinkExpired: tokenStatus.expired
120
+ });
121
+ });
122
+ _context.next = 15;
123
+ break;
124
+ case 11:
125
+ _context.prev = 11;
126
+ _context.t0 = _context["catch"](4);
127
+ console.error('Error checking token expiration in componentDidMount:', _context.t0);
128
+ // if there's an error checking the token, assume it's expired
129
+ _this.setState(function (prevState) {
130
+ return _objectSpread(_objectSpread({}, prevState), {}, {
131
+ isPasswordResetLinkExpired: true
132
+ });
133
+ });
134
+ case 15:
135
+ case "end":
136
+ return _context.stop();
137
+ }
138
+ }, _callee, null, [[4, 11]]);
139
+ })));
140
+ _defineProperty(_assertThisInitialized(_this), "checkTokenExpiration", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
141
+ var urlParams, oobCode, result;
142
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
143
+ while (1) switch (_context2.prev = _context2.next) {
144
+ case 0:
145
+ urlParams = _this.props.urlParams;
146
+ if (urlParams) {
147
+ _context2.next = 3;
148
+ break;
149
+ }
150
+ return _context2.abrupt("return", {
109
151
  expired: true
110
152
  });
111
153
  case 3:
112
- _context.prev = 3;
113
- search = location.search;
114
- query = new URLSearchParams(search);
115
- oobCode = query.get('oobCode');
154
+ _context2.prev = 3;
155
+ oobCode = urlParams.getUrlParam('oobCode');
116
156
  if (oobCode) {
117
- _context.next = 9;
157
+ _context2.next = 7;
118
158
  break;
119
159
  }
120
- return _context.abrupt("return", {
160
+ return _context2.abrupt("return", {
121
161
  expired: true
122
162
  });
123
- case 9:
124
- _context.next = 11;
163
+ case 7:
164
+ _context2.next = 9;
125
165
  return _this.context.checkActivationLinkExpired(oobCode);
126
- case 11:
127
- result = _context.sent;
128
- return _context.abrupt("return", result);
129
- case 15:
130
- _context.prev = 15;
131
- _context.t0 = _context["catch"](3);
132
- console.error('Error checking token expiration:', _context.t0);
133
- return _context.abrupt("return", {
166
+ case 9:
167
+ result = _context2.sent;
168
+ return _context2.abrupt("return", result);
169
+ case 13:
170
+ _context2.prev = 13;
171
+ _context2.t0 = _context2["catch"](3);
172
+ console.error('Error checking token expiration:', _context2.t0);
173
+ return _context2.abrupt("return", {
134
174
  expired: true
135
175
  });
136
- case 19:
176
+ case 17:
137
177
  case "end":
138
- return _context.stop();
178
+ return _context2.stop();
139
179
  }
140
- }, _callee, null, [[3, 15]]);
180
+ }, _callee2, null, [[3, 13]]);
141
181
  })));
142
- _defineProperty(_assertThisInitialized(_this), "checkForModals", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
143
- var _this$props, isLogin, isSignUp, isResetPassword, isVerifyEmail, user, isModalOpen, login, signUp, resetPassword, verifyEmail, resendConfirmation, isAnyModalOpen, tokenStatus;
144
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
145
- while (1) switch (_context2.prev = _context2.next) {
182
+ _defineProperty(_assertThisInitialized(_this), "checkForModals", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
183
+ var _this$props2, isLogin, isSignUp, isResetPassword, isVerifyEmail, user, _this$state, isModalOpen, isPasswordResetLinkExpired, login, signUp, resetPassword, verifyEmail, isAnyModalOpen;
184
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
185
+ while (1) switch (_context3.prev = _context3.next) {
146
186
  case 0:
147
- _this$props = _this.props, isLogin = _this$props.isLogin, isSignUp = _this$props.isSignUp, isResetPassword = _this$props.isResetPassword, isVerifyEmail = _this$props.isVerifyEmail;
187
+ _this$props2 = _this.props, isLogin = _this$props2.isLogin, isSignUp = _this$props2.isSignUp, isResetPassword = _this$props2.isResetPassword, isVerifyEmail = _this$props2.isVerifyEmail;
148
188
  user = _this.context.user;
149
- isModalOpen = _this.state.isModalOpen;
150
- login = isModalOpen.login, signUp = isModalOpen.signUp, resetPassword = isModalOpen.resetPassword, verifyEmail = isModalOpen.verifyEmail, resendConfirmation = isModalOpen.resendConfirmation; //checks if any modal is open
189
+ _this$state = _this.state, isModalOpen = _this$state.isModalOpen, isPasswordResetLinkExpired = _this$state.isPasswordResetLinkExpired;
190
+ login = isModalOpen.login, signUp = isModalOpen.signUp, resetPassword = isModalOpen.resetPassword, verifyEmail = isModalOpen.verifyEmail; //checks if any modal is open
151
191
  //if true we won't open any modal from below
152
192
  isAnyModalOpen = Object.values(isModalOpen).some(function (value) {
153
193
  return value === true;
154
194
  });
155
195
  if (!isAnyModalOpen) {
156
- _context2.next = 7;
196
+ _context3.next = 7;
157
197
  break;
158
198
  }
159
- return _context2.abrupt("return");
199
+ return _context3.abrupt("return");
160
200
  case 7:
161
201
  //dont open if modal is already open or user is logged in
162
202
  if (isLogin && !user && !login) {
@@ -177,34 +217,27 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
177
217
  });
178
218
  });
179
219
  }
180
- if (!(isResetPassword && !user && !resetPassword && !resendConfirmation)) {
181
- _context2.next = 14;
182
- break;
183
- }
184
- _context2.next = 12;
185
- return _this.checkTokenExpiration();
186
- case 12:
187
- tokenStatus = _context2.sent;
188
- if (tokenStatus.expired) {
189
- // Open resend confirmation modal if token is expired
190
- _this.setState(function (prevState) {
191
- return _objectSpread(_objectSpread({}, prevState), {}, {
192
- isModalOpen: _objectSpread(_objectSpread({}, isModalOpen), {}, {
193
- resendConfirmation: true
194
- })
220
+ if (isResetPassword && !user && !resetPassword) {
221
+ if (isPasswordResetLinkExpired) {
222
+ // open special version of forgot password modal if token is expired
223
+ _this.setState(function (prevState) {
224
+ return _objectSpread(_objectSpread({}, prevState), {}, {
225
+ isModalOpen: _objectSpread(_objectSpread({}, isModalOpen), {}, {
226
+ forgot: true
227
+ })
228
+ });
195
229
  });
196
- });
197
- } else {
198
- // Open reset password modal if token is valid
199
- _this.setState(function (prevState) {
200
- return _objectSpread(_objectSpread({}, prevState), {}, {
201
- isModalOpen: _objectSpread(_objectSpread({}, isModalOpen), {}, {
202
- resetPassword: true
203
- })
230
+ } else {
231
+ // open usual reset password modal if token is valid
232
+ _this.setState(function (prevState) {
233
+ return _objectSpread(_objectSpread({}, prevState), {}, {
234
+ isModalOpen: _objectSpread(_objectSpread({}, isModalOpen), {}, {
235
+ resetPassword: true
236
+ })
237
+ });
204
238
  });
205
- });
239
+ }
206
240
  }
207
- case 14:
208
241
  if (isVerifyEmail && !verifyEmail) {
209
242
  _this.setState(function (prevState) {
210
243
  return _objectSpread(_objectSpread({}, prevState), {}, {
@@ -214,17 +247,17 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
214
247
  });
215
248
  });
216
249
  }
217
- case 15:
250
+ case 11:
218
251
  case "end":
219
- return _context2.stop();
252
+ return _context3.stop();
220
253
  }
221
- }, _callee2);
254
+ }, _callee3);
222
255
  })));
223
256
  _defineProperty(_assertThisInitialized(_this), "setOpenModalStatus", function (modalId, status) {
224
257
  var isModalOpen = _this.state.isModalOpen;
225
- var _this$props2 = _this.props,
226
- onSignupModalClose = _this$props2.onSignupModalClose,
227
- navigate = _this$props2.navigate;
258
+ var _this$props3 = _this.props,
259
+ onSignupModalClose = _this$props3.onSignupModalClose,
260
+ navigate = _this$props3.navigate;
228
261
 
229
262
  //if we pass custom onSignupModalClose, we don't want any modification in the url
230
263
  if (!onSignupModalClose) {
@@ -349,20 +382,20 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
349
382
  key: "render",
350
383
  value: function render() {
351
384
  var _this2 = this;
352
- var _this$state = this.state,
353
- isModalOpen = _this$state.isModalOpen,
354
- userInfo = _this$state.userInfo,
355
- isActionLoading = _this$state.isActionLoading,
356
- termsData = _this$state.termsData;
357
- var _this$props3 = this.props,
358
- fixed = _this$props3.fixed,
359
- activateMenu = _this$props3.activateMenu,
360
- activeMenu = _this$props3.activeMenu,
361
- withoutLoginSignupButton = _this$props3.withoutLoginSignupButton,
362
- useRelativePathForMenu = _this$props3.useRelativePathForMenu,
363
- isLoginModalOpen = _this$props3.isLoginModalOpen,
364
- setIsLoginModalOpen = _this$props3.setIsLoginModalOpen,
365
- cooldown = _this$props3.cooldown;
385
+ var _this$state2 = this.state,
386
+ isModalOpen = _this$state2.isModalOpen,
387
+ userInfo = _this$state2.userInfo,
388
+ isActionLoading = _this$state2.isActionLoading,
389
+ termsData = _this$state2.termsData;
390
+ var _this$props4 = this.props,
391
+ fixed = _this$props4.fixed,
392
+ activateMenu = _this$props4.activateMenu,
393
+ activeMenu = _this$props4.activeMenu,
394
+ withoutLoginSignupButton = _this$props4.withoutLoginSignupButton,
395
+ useRelativePathForMenu = _this$props4.useRelativePathForMenu,
396
+ isLoginModalOpen = _this$props4.isLoginModalOpen,
397
+ setIsLoginModalOpen = _this$props4.setIsLoginModalOpen,
398
+ cooldown = _this$props4.cooldown;
366
399
  var _this$context2 = this.context,
367
400
  getUser = _this$context2.getUser,
368
401
  _this$context2$user = _this$context2.user,
@@ -418,47 +451,47 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
418
451
  _this2.setIsActionLoading(undefined);
419
452
  },
420
453
  onFormSend: /*#__PURE__*/function () {
421
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref4) {
454
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref5) {
422
455
  var email, password, errorMessage;
423
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
424
- while (1) switch (_context3.prev = _context3.next) {
456
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
457
+ while (1) switch (_context4.prev = _context4.next) {
425
458
  case 0:
426
- email = _ref4.email, password = _ref4.password;
459
+ email = _ref5.email, password = _ref5.password;
427
460
  _this2.clearPopupError();
428
461
  _this2.setIsActionLoading('login');
429
- _context3.prev = 3;
462
+ _context4.prev = 3;
430
463
  if (!(password.length > 128)) {
431
- _context3.next = 8;
464
+ _context4.next = 8;
432
465
  break;
433
466
  }
434
467
  _this2.setPopupError('login', 'Your password cannot exceed 128 characters');
435
468
  _this2.setIsActionLoading(undefined);
436
- return _context3.abrupt("return");
469
+ return _context4.abrupt("return");
437
470
  case 8:
438
- _context3.next = 10;
471
+ _context4.next = 10;
439
472
  return loginUser(email, password);
440
473
  case 10:
441
- _context3.next = 12;
474
+ _context4.next = 12;
442
475
  return getUser();
443
476
  case 12:
444
477
  _this2.setOpenModalStatus('login', false);
445
478
  setIsLoginModalOpen && setIsLoginModalOpen(false);
446
479
  _this2.clearPopupError();
447
480
  _this2.setIsActionLoading(undefined);
448
- _context3.next = 28;
481
+ _context4.next = 28;
449
482
  break;
450
483
  case 18:
451
- _context3.prev = 18;
452
- _context3.t0 = _context3["catch"](3);
453
- errorMessage = _context3.t0 === null || _context3.t0 === void 0 ? void 0 : _context3.t0.message; //handle switch modal correctly
454
- if (!((_context3.t0 === null || _context3.t0 === void 0 ? void 0 : _context3.t0.code) === 'auth/multi-factor-auth-required')) {
455
- _context3.next = 26;
484
+ _context4.prev = 18;
485
+ _context4.t0 = _context4["catch"](3);
486
+ errorMessage = _context4.t0 === null || _context4.t0 === void 0 ? void 0 : _context4.t0.message; //handle switch modal correctly
487
+ if (!((_context4.t0 === null || _context4.t0 === void 0 ? void 0 : _context4.t0.code) === 'auth/multi-factor-auth-required')) {
488
+ _context4.next = 26;
456
489
  break;
457
490
  }
458
491
  _this2.switchOpenModal('login', 'enter2fa');
459
492
  _this2.clearPopupError();
460
493
  _this2.setIsActionLoading(undefined);
461
- return _context3.abrupt("return");
494
+ return _context4.abrupt("return");
462
495
  case 26:
463
496
  if (errorMessage) {
464
497
  _this2.setPopupError('login', errorMessage);
@@ -468,12 +501,12 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
468
501
  _this2.setIsActionLoading(undefined);
469
502
  case 28:
470
503
  case "end":
471
- return _context3.stop();
504
+ return _context4.stop();
472
505
  }
473
- }, _callee3, null, [[3, 18]]);
506
+ }, _callee4, null, [[3, 18]]);
474
507
  }));
475
508
  return function (_x) {
476
- return _ref5.apply(this, arguments);
509
+ return _ref6.apply(this, arguments);
477
510
  };
478
511
  }()
479
512
  }), waitingFor2fa && /*#__PURE__*/_react.default.createElement(_FA.EnterCode, {
@@ -492,46 +525,46 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
492
525
  _this2.setIsActionLoading(undefined);
493
526
  },
494
527
  onFormSend: /*#__PURE__*/function () {
495
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref6) {
528
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref7) {
496
529
  var otpInput;
497
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
498
- while (1) switch (_context4.prev = _context4.next) {
530
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
531
+ while (1) switch (_context5.prev = _context5.next) {
499
532
  case 0:
500
- otpInput = _ref6.otpInput;
533
+ otpInput = _ref7.otpInput;
501
534
  _this2.setIsActionLoading('enter2fa');
502
- _context4.prev = 2;
503
- _context4.next = 5;
535
+ _context5.prev = 2;
536
+ _context5.next = 5;
504
537
  return loginUserWithTotp(otpInput, firebaseError);
505
538
  case 5:
506
- _context4.next = 7;
539
+ _context5.next = 7;
507
540
  return getUser();
508
541
  case 7:
509
542
  _this2.setOpenModalStatus('enter2fa', false);
510
543
  _this2.clearPopupError();
511
544
  _this2.setIsActionLoading(undefined);
512
- _context4.next = 16;
545
+ _context5.next = 16;
513
546
  break;
514
547
  case 12:
515
- _context4.prev = 12;
516
- _context4.t0 = _context4["catch"](2);
517
- console.log('🚀 ~ file: HeaderHo.jsx:364 ~ error:', _context4.t0);
518
- if ((_context4.t0 === null || _context4.t0 === void 0 ? void 0 : _context4.t0.code) === 'auth/invalid-verification-code') {
519
- _this2.setPopupError('enter2fa', 'That’s not the right 2FA code. Try again');
520
- } else if ((_context4.t0 === null || _context4.t0 === void 0 ? void 0 : _context4.t0.code) === 'auth/code-expired') {
548
+ _context5.prev = 12;
549
+ _context5.t0 = _context5["catch"](2);
550
+ console.log('🚀 ~ file: HeaderHo.jsx:364 ~ error:', _context5.t0);
551
+ if ((_context5.t0 === null || _context5.t0 === void 0 ? void 0 : _context5.t0.code) === 'auth/invalid-verification-code') {
552
+ _this2.setPopupError('enter2fa', "That's not the right 2FA code. Try again");
553
+ } else if ((_context5.t0 === null || _context5.t0 === void 0 ? void 0 : _context5.t0.code) === 'auth/code-expired') {
521
554
  _this2.setPopupError('enter2fa', 'Time out. Please restart the flow and log in again');
522
555
  } else {
523
- _this2.setPopupError('enter2fa', _context4.t0 === null || _context4.t0 === void 0 ? void 0 : _context4.t0.message);
556
+ _this2.setPopupError('enter2fa', _context5.t0 === null || _context5.t0 === void 0 ? void 0 : _context5.t0.message);
524
557
  }
525
558
  case 16:
526
559
  _this2.setIsActionLoading(undefined);
527
560
  case 17:
528
561
  case "end":
529
- return _context4.stop();
562
+ return _context5.stop();
530
563
  }
531
- }, _callee4, null, [[2, 12]]);
564
+ }, _callee5, null, [[2, 12]]);
532
565
  }));
533
566
  return function (_x2) {
534
- return _ref7.apply(this, arguments);
567
+ return _ref8.apply(this, arguments);
535
568
  };
536
569
  }()
537
570
  }), /*#__PURE__*/_react.default.createElement(_FA.ResetCode, {
@@ -586,24 +619,24 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
586
619
  onSignupModalClose && onSignupModalClose();
587
620
  },
588
621
  onFormSend: /*#__PURE__*/function () {
589
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(userInfo) {
590
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
591
- while (1) switch (_context5.prev = _context5.next) {
622
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(userInfo) {
623
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
624
+ while (1) switch (_context6.prev = _context6.next) {
592
625
  case 0:
593
626
  _this2.clearPopupError();
594
627
  _this2.setIsActionLoading('signUp');
595
628
 
596
629
  //check password
597
- _context5.prev = 2;
630
+ _context6.prev = 2;
598
631
  if (!(userInfo.password.length > 128)) {
599
- _context5.next = 7;
632
+ _context6.next = 7;
600
633
  break;
601
634
  }
602
635
  _this2.setPopupError('register', 'Your password cannot exceed 128 characters', 'password');
603
636
  _this2.setIsActionLoading(undefined);
604
- return _context5.abrupt("return");
637
+ return _context6.abrupt("return");
605
638
  case 7:
606
- _context5.next = 9;
639
+ _context6.next = 9;
607
640
  return createUser(userInfo.email, userInfo.password);
608
641
  case 9:
609
642
  //start the timer to count when user can resend email
@@ -611,10 +644,10 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
611
644
 
612
645
  //if user checked newsletter checkbox
613
646
  if (!userInfo.newsletter) {
614
- _context5.next = 13;
647
+ _context6.next = 13;
615
648
  break;
616
649
  }
617
- _context5.next = 13;
650
+ _context6.next = 13;
618
651
  return (0, _fetchDataPublic.default)('emails/subscribe', {
619
652
  email: userInfo.email,
620
653
  listName: 'newsletter'
@@ -623,28 +656,28 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
623
656
  _this2.setUserInfo(userInfo);
624
657
  _this2.switchOpenModal('signUp', 'confirm');
625
658
  _this2.setIsActionLoading(undefined);
626
- _context5.next = 23;
659
+ _context6.next = 23;
627
660
  break;
628
661
  case 18:
629
- _context5.prev = 18;
630
- _context5.t0 = _context5["catch"](2);
631
- console.log(_context5.t0);
662
+ _context6.prev = 18;
663
+ _context6.t0 = _context6["catch"](2);
664
+ console.log(_context6.t0);
632
665
  _this2.setIsActionLoading(undefined);
633
- if ((_context5.t0 === null || _context5.t0 === void 0 ? void 0 : _context5.t0.code) === 'auth/email-already-in-use') {
666
+ if ((_context6.t0 === null || _context6.t0 === void 0 ? void 0 : _context6.t0.code) === 'auth/email-already-in-use') {
634
667
  _this2.setPopupError('register', 'This email address is already taken', 'email');
635
- } else if ((_context5.t0 === null || _context5.t0 === void 0 ? void 0 : _context5.t0.code) === 'auth/weak-password') {
668
+ } else if ((_context6.t0 === null || _context6.t0 === void 0 ? void 0 : _context6.t0.code) === 'auth/weak-password') {
636
669
  _this2.setPopupError('register', 'The password is too weak. Please try again.', 'password');
637
670
  } else {
638
671
  _this2.setPopupError('register', 'Oops, something went wrong');
639
672
  }
640
673
  case 23:
641
674
  case "end":
642
- return _context5.stop();
675
+ return _context6.stop();
643
676
  }
644
- }, _callee5, null, [[2, 18]]);
677
+ }, _callee6, null, [[2, 18]]);
645
678
  }));
646
679
  return function (_x3) {
647
- return _ref8.apply(this, arguments);
680
+ return _ref9.apply(this, arguments);
648
681
  };
649
682
  }()
650
683
  }), /*#__PURE__*/_react.default.createElement(_TermsModal.default, {
@@ -670,35 +703,35 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
670
703
  _this2.clearPopupError();
671
704
  _this2.setIsActionLoading(undefined);
672
705
  },
673
- onResend: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
706
+ onResend: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
674
707
  var email;
675
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
676
- while (1) switch (_context6.prev = _context6.next) {
708
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
709
+ while (1) switch (_context7.prev = _context7.next) {
677
710
  case 0:
678
711
  _this2.clearPopupSuccess();
679
712
  _this2.clearPopupError();
680
713
  _this2.setIsActionLoading('resend');
681
- _context6.prev = 3;
714
+ _context7.prev = 3;
682
715
  email = _this2.state.userInfo.email;
683
- _context6.next = 7;
716
+ _context7.next = 7;
684
717
  return resendActivationEmail(email);
685
718
  case 7:
686
719
  cooldown === null || cooldown === void 0 || cooldown.startCooldown();
687
720
  _this2.setPopupSuccess('resend', 'Email sent.');
688
721
  _this2.setIsActionLoading(undefined);
689
- _context6.next = 17;
722
+ _context7.next = 17;
690
723
  break;
691
724
  case 12:
692
- _context6.prev = 12;
693
- _context6.t0 = _context6["catch"](3);
694
- console.log(_context6.t0);
725
+ _context7.prev = 12;
726
+ _context7.t0 = _context7["catch"](3);
727
+ console.log(_context7.t0);
695
728
  _this2.setPopupError('resend', 'Something went wrong.');
696
729
  _this2.setIsActionLoading(undefined);
697
730
  case 17:
698
731
  case "end":
699
- return _context6.stop();
732
+ return _context7.stop();
700
733
  }
701
- }, _callee6, null, [[3, 12]]);
734
+ }, _callee7, null, [[3, 12]]);
702
735
  }))
703
736
  }), /*#__PURE__*/_react.default.createElement(_ForgotPasswordModal.default, {
704
737
  isActionLoading: isActionLoading,
@@ -718,38 +751,38 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
718
751
  _this2.setIsActionLoading(undefined);
719
752
  },
720
753
  onFormSend: /*#__PURE__*/function () {
721
- var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_ref10) {
754
+ var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(_ref11) {
722
755
  var email;
723
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
724
- while (1) switch (_context7.prev = _context7.next) {
756
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
757
+ while (1) switch (_context8.prev = _context8.next) {
725
758
  case 0:
726
- email = _ref10.email;
759
+ email = _ref11.email;
727
760
  _this2.clearPopupError();
728
761
  _this2.setIsActionLoading('forgot');
729
- _context7.prev = 3;
730
- _context7.next = 6;
762
+ _context8.prev = 3;
763
+ _context8.next = 6;
731
764
  return (0, _auth.default)('forgotPass', {
732
765
  email: email
733
766
  });
734
767
  case 6:
735
768
  _this2.setPopupSuccess('forgot', "We sent a message to ".concat(email, " (you might need to check your junk or spam folder) \u2014 tap the link inside to create a new password."));
736
769
  _this2.setIsActionLoading(undefined);
737
- _context7.next = 15;
770
+ _context8.next = 15;
738
771
  break;
739
772
  case 10:
740
- _context7.prev = 10;
741
- _context7.t0 = _context7["catch"](3);
742
- console.log(_context7.t0);
773
+ _context8.prev = 10;
774
+ _context8.t0 = _context8["catch"](3);
775
+ console.log(_context8.t0);
743
776
  _this2.setPopupError('forgot', 'This email is not registered.');
744
777
  _this2.setIsActionLoading(undefined);
745
778
  case 15:
746
779
  case "end":
747
- return _context7.stop();
780
+ return _context8.stop();
748
781
  }
749
- }, _callee7, null, [[3, 10]]);
782
+ }, _callee8, null, [[3, 10]]);
750
783
  }));
751
784
  return function (_x4) {
752
- return _ref11.apply(this, arguments);
785
+ return _ref12.apply(this, arguments);
753
786
  };
754
787
  }()
755
788
  }), /*#__PURE__*/_react.default.createElement(_ResetPasswordModal.default, {
@@ -768,36 +801,36 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
768
801
  _this2.setIsActionLoading(undefined);
769
802
  },
770
803
  onFormSend: /*#__PURE__*/function () {
771
- var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(_ref12) {
804
+ var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref13) {
772
805
  var password, oobCode;
773
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
774
- while (1) switch (_context8.prev = _context8.next) {
806
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
807
+ while (1) switch (_context9.prev = _context9.next) {
775
808
  case 0:
776
- password = _ref12.password, oobCode = _ref12.oobCode;
809
+ password = _ref13.password, oobCode = _ref13.oobCode;
777
810
  _this2.clearPopupError();
778
811
  _this2.setIsActionLoading('resetPassword');
779
- _context8.prev = 3;
780
- _context8.next = 6;
812
+ _context9.prev = 3;
813
+ _context9.next = 6;
781
814
  return handleResetPassword(password, oobCode);
782
815
  case 6:
783
816
  _this2.switchOpenModal('resetPassword', 'confirmReset');
784
817
  _this2.setIsActionLoading(undefined);
785
- _context8.next = 15;
818
+ _context9.next = 15;
786
819
  break;
787
820
  case 10:
788
- _context8.prev = 10;
789
- _context8.t0 = _context8["catch"](3);
790
- console.log(_context8.t0);
791
- _this2.setPopupError('resetPassword', (_context8.t0 === null || _context8.t0 === void 0 ? void 0 : _context8.t0.message) || 'Something went wrong.');
821
+ _context9.prev = 10;
822
+ _context9.t0 = _context9["catch"](3);
823
+ console.log(_context9.t0);
824
+ _this2.setPopupError('resetPassword', (_context9.t0 === null || _context9.t0 === void 0 ? void 0 : _context9.t0.message) || 'Something went wrong.');
792
825
  _this2.setIsActionLoading(undefined);
793
826
  case 15:
794
827
  case "end":
795
- return _context8.stop();
828
+ return _context9.stop();
796
829
  }
797
- }, _callee8, null, [[3, 10]]);
830
+ }, _callee9, null, [[3, 10]]);
798
831
  }));
799
832
  return function (_x5) {
800
- return _ref13.apply(this, arguments);
833
+ return _ref14.apply(this, arguments);
801
834
  };
802
835
  }()
803
836
  }), /*#__PURE__*/_react.default.createElement(_ResetConfirmModal.default, {
@@ -836,58 +869,39 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
836
869
  _this2.setIsActionLoading(undefined);
837
870
  },
838
871
  onResend: /*#__PURE__*/function () {
839
- var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(values) {
872
+ var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(values) {
840
873
  var email;
841
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
842
- while (1) switch (_context9.prev = _context9.next) {
874
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
875
+ while (1) switch (_context10.prev = _context10.next) {
843
876
  case 0:
844
877
  _this2.clearPopupSuccess();
845
878
  _this2.clearPopupError();
846
879
  _this2.setIsActionLoading('resend');
847
- _context9.prev = 3;
880
+ _context10.prev = 3;
848
881
  email = values === null || values === void 0 ? void 0 : values.email;
849
- _context9.next = 7;
882
+ _context10.next = 7;
850
883
  return resendActivationEmail(email);
851
884
  case 7:
852
885
  _this2.setPopupSuccess('resend', 'Email sent.');
853
886
  _this2.setIsActionLoading(undefined);
854
- _context9.next = 16;
887
+ _context10.next = 16;
855
888
  break;
856
889
  case 11:
857
- _context9.prev = 11;
858
- _context9.t0 = _context9["catch"](3);
859
- console.log(_context9.t0);
860
- _this2.setPopupError('resend', (_context9.t0 === null || _context9.t0 === void 0 ? void 0 : _context9.t0.message) || 'Something went wrong.');
890
+ _context10.prev = 11;
891
+ _context10.t0 = _context10["catch"](3);
892
+ console.log(_context10.t0);
893
+ _this2.setPopupError('resend', (_context10.t0 === null || _context10.t0 === void 0 ? void 0 : _context10.t0.message) || 'Something went wrong.');
861
894
  _this2.setIsActionLoading(undefined);
862
895
  case 16:
863
896
  case "end":
864
- return _context9.stop();
897
+ return _context10.stop();
865
898
  }
866
- }, _callee9, null, [[3, 11]]);
899
+ }, _callee10, null, [[3, 11]]);
867
900
  }));
868
901
  return function (_x6) {
869
- return _ref14.apply(this, arguments);
902
+ return _ref15.apply(this, arguments);
870
903
  };
871
904
  }()
872
- }), /*#__PURE__*/_react.default.createElement(_ResendConfirmationCodeModal.default, {
873
- isActionLoading: isActionLoading,
874
- popupError: this.state.popupError,
875
- isModalOpen: isModalOpen.resendConfirmation,
876
- onModalClose: function onModalClose() {
877
- _this2.setOpenModalStatus('resendConfirmation', false);
878
- _this2.clearPopupError();
879
- _this2.setIsActionLoading(undefined);
880
- },
881
- onModalSwitch: function onModalSwitch() {
882
- window.history.pushState({}, null, '/login');
883
- _this2.switchOpenModal('resendConfirmation', 'login');
884
- _this2.clearPopupError();
885
- _this2.setIsActionLoading(undefined);
886
- },
887
- onTokenRefreshed: function onTokenRefreshed() {
888
- // Switch to reset password modal after token is refreshed
889
- _this2.switchOpenModal('resendConfirmation', 'resetPassword');
890
- }
891
905
  }));
892
906
  }
893
907
  }]);
@@ -895,7 +909,7 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
895
909
  }(_react.Component);
896
910
  _defineProperty(HeaderHoClass, "propTypes", {});
897
911
  _defineProperty(HeaderHoClass, "contextType", _AuthContext.AuthContext);
898
- var HeaderHo = (0, _withRouter.withRouter)((0, _customHooks.cooldownHOC)(HeaderHoClass, 90));
912
+ var HeaderHo = (0, _withRouter.withRouter)((0, _customHooks.cooldownHOC)((0, _customHooks.withUrlParams)(HeaderHoClass), 90));
899
913
  exports.HeaderHo = HeaderHo;
900
914
  var _default = HeaderHo;
901
915
  exports.default = _default;
@@ -767,35 +767,31 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
767
767
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
768
768
  while (1) switch (_context15.prev = _context15.next) {
769
769
  case 0:
770
- console.log('does this even run??');
771
- _context15.prev = 1;
772
- _context15.next = 4;
770
+ _context15.prev = 0;
771
+ _context15.next = 3;
773
772
  return (0, _auth.checkActionCode)(_firebaseConfig.auth, actionCode);
774
- case 4:
773
+ case 3:
775
774
  actionCodeInfo = _context15.sent;
776
- console.log('actionCodeInfo', actionCodeInfo);
777
775
  return _context15.abrupt("return", {
778
776
  expired: false,
779
777
  info: actionCodeInfo
780
778
  });
781
- case 9:
782
- _context15.prev = 9;
783
- _context15.t0 = _context15["catch"](1);
784
- console.log('checkActivationLinkExpired error:', _context15.t0);
779
+ case 7:
780
+ _context15.prev = 7;
781
+ _context15.t0 = _context15["catch"](0);
785
782
  if (!(_context15.t0.code === 'auth/expired-action-code' || _context15.t0.code === 'auth/invalid-action-code')) {
786
- _context15.next = 15;
783
+ _context15.next = 11;
787
784
  break;
788
785
  }
789
- console.log('checkActivationLink error was either auth/expired-action-code or auth/invalid-action-code, setting token to EXPIRED! ');
790
786
  return _context15.abrupt("return", {
791
787
  expired: true,
792
788
  error: _context15.t0
793
789
  });
794
- case 15:
790
+ case 11:
795
791
  case "end":
796
792
  return _context15.stop();
797
793
  }
798
- }, _callee15, null, [[1, 9]]);
794
+ }, _callee15, null, [[0, 7]]);
799
795
  }));
800
796
  return function (_x18) {
801
797
  return _ref15.apply(this, arguments);
@@ -6,8 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.useMobileView = exports.useCooldown = exports.cooldownHOC = void 0;
8
8
  exports.usePrevious = usePrevious;
9
+ exports.withUrlParams = exports.useUrlParams = void 0;
9
10
  var _react = _interopRequireWildcard(require("react"));
10
11
  var _rwd = _interopRequireWildcard(require("../styles/rwd"));
12
+ var _reactRouterDom = require("react-router-dom");
11
13
  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); }
12
14
  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; }
13
15
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
@@ -116,4 +118,34 @@ var cooldownHOC = function cooldownHOC(Component) {
116
118
  };
117
119
  return Wrapper;
118
120
  };
119
- exports.cooldownHOC = cooldownHOC;
121
+ exports.cooldownHOC = cooldownHOC;
122
+ var useUrlParams = function useUrlParams() {
123
+ var location = (0, _reactRouterDom.useLocation)();
124
+ var getUrlParam = function getUrlParam(paramName) {
125
+ var searchParams = new URLSearchParams(location.search);
126
+ return searchParams.get(paramName);
127
+ };
128
+ var getAllParams = function getAllParams() {
129
+ var searchParams = new URLSearchParams(location.search);
130
+ return Object.fromEntries(searchParams.entries());
131
+ };
132
+ return {
133
+ location: location,
134
+ pathname: location.pathname,
135
+ search: location.search,
136
+ getUrlParam: getUrlParam,
137
+ getAllParams: getAllParams
138
+ };
139
+ };
140
+
141
+ // HOC to inject URL data
142
+ exports.useUrlParams = useUrlParams;
143
+ var withUrlParams = function withUrlParams(Component) {
144
+ return function (props) {
145
+ var urlParams = useUrlParams();
146
+ return /*#__PURE__*/_react.default.createElement(Component, _extends({}, props, {
147
+ urlParams: urlParams
148
+ }));
149
+ };
150
+ };
151
+ exports.withUrlParams = withUrlParams;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stokr/components-library",
3
- "version": "2.3.41-beta.15",
3
+ "version": "2.3.41-beta.17",
4
4
  "description": "STOKR - Components Library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",