@stokr/components-library 3.0.77 → 3.1.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/components/Input/InputPassword.js +3 -5
  2. package/dist/components/Input/OtpInput.js +1 -3
  3. package/dist/components/MenuNav/MenuNav.styles.js +1 -2
  4. package/dist/components/Modal/Modal.styles.js +2 -3
  5. package/dist/components/Newsletter/Newsletter.js +1 -3
  6. package/dist/components/NotificationCounter/NotificationCounter.styles.js +1 -2
  7. package/dist/components/SmartLink/SmartLink.js +0 -2
  8. package/dist/components/StepController/StepController.js +3 -5
  9. package/dist/components/StepController/StepController.styles.js +102 -1
  10. package/dist/components/StepController/StepControllerProgress.js +1 -1
  11. package/dist/components/Switch/Switch.js +1 -3
  12. package/dist/components/ToDoList/ToDoListTask.js +15 -3
  13. package/dist/components/taxId/register-taxid.js +7 -5
  14. package/dist/index.js +67 -141
  15. package/dist/runtime-config.js +4 -70
  16. package/dist/styles/global.js +1 -2
  17. package/dist/utils/check-todo-status.js +1 -2
  18. package/package.json +8 -14
  19. package/dist/api/authenticationApi.js +0 -13
  20. package/dist/auth/index.js +0 -34
  21. package/dist/components/2FA/Connect2FA.js +0 -58
  22. package/dist/components/2FA/EnterCode.js +0 -74
  23. package/dist/components/2FA/InstallAuthApp.js +0 -68
  24. package/dist/components/2FA/ResetCode.js +0 -34
  25. package/dist/components/2FA/Sucess2FA.js +0 -63
  26. package/dist/components/2FA/disable-2fa-flow.js +0 -104
  27. package/dist/components/2FA/enable-2fa-flow.js +0 -167
  28. package/dist/components/2FA/login-with-otp-flow.js +0 -262
  29. package/dist/components/2FA/main-flow.js +0 -273
  30. package/dist/components/Footer/Footer.js +0 -69
  31. package/dist/components/Footer/Footer.styles.js +0 -277
  32. package/dist/components/Footer/FooterLayout.js +0 -150
  33. package/dist/components/Footer/FooterMenu.js +0 -107
  34. package/dist/components/Footer/FooterMenu.styles.js +0 -334
  35. package/dist/components/ForgotPasswordModal/ForgotPasswordModal.js +0 -121
  36. package/dist/components/Header/Header.js +0 -441
  37. package/dist/components/Header/Header.styles.js +0 -568
  38. package/dist/components/Layout/Layout.js +0 -76
  39. package/dist/components/LoginModal/LoginModal.js +0 -165
  40. package/dist/components/MainMenu/DynamicMainMenu.js +0 -38
  41. package/dist/components/MainMenu/MainMenu.js +0 -220
  42. package/dist/components/MainMenu/MainMenu.styles.js +0 -362
  43. package/dist/components/Modal/NewVentureModal/NewVentureModal.js +0 -273
  44. package/dist/components/RegisterConfirmModal/RegisterConfirmModal.js +0 -74
  45. package/dist/components/RegisterConfirmModal/RegisterConfirmModal.styles.js +0 -20
  46. package/dist/components/RegisterModal/RegisterModal.js +0 -278
  47. package/dist/components/ResetConfirmModal/ResetConfirmModal.js +0 -40
  48. package/dist/components/ResetConfirmModal/ResetConfirmModal.styles.js +0 -41
  49. package/dist/components/ResetPasswordModal/ResetPasswordModal.js +0 -145
  50. package/dist/components/StepsProgress/StepIndicator.js +0 -40
  51. package/dist/components/StepsProgress/StepIndicator.styles.js +0 -69
  52. package/dist/components/StepsProgress/StepsProgress.js +0 -67
  53. package/dist/components/StepsProgress/StepsProgress.styles.js +0 -105
  54. package/dist/components/TermsModal/TermsModal.js +0 -145
  55. package/dist/components/TermsModal/_styles.js +0 -313
  56. package/dist/components/VerifyEmailModal/VerifyEmailModal.js +0 -122
  57. package/dist/components/headerHo/HeaderHo.js +0 -707
  58. package/dist/config.js +0 -33
  59. package/dist/context/Auth.js +0 -423
  60. package/dist/context/AuthContext.js +0 -1016
  61. package/dist/firebase-config.js +0 -56
  62. package/dist/hooks/useNewVentureForm.js +0 -235
  63. package/dist/static/images/background3.png.js +0 -4
  64. package/dist/static/images/google_auth.png.js +0 -4
  65. package/dist/static/images/iso27001-black.svg.js +0 -4
  66. package/dist/static/images/mangopay.svg.js +0 -4
  67. package/dist/static/images/social/Facebook_Logo.png.js +0 -4
  68. package/dist/static/images/social/LI-In-Bug.png.js +0 -4
  69. package/dist/static/images/social/Telegram-Logo.png.js +0 -4
  70. package/dist/static/images/social/X-logo-black.png.js +0 -4
  71. package/dist/static/images/social/youtube_social_circle_red.png.js +0 -4
  72. package/dist/utils/show-account-locked-modal.js +0 -23
  73. package/dist/utils/user-identity.js +0 -10
  74. package/dist/utils/withRouter.js +0 -26
@@ -1,707 +0,0 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { Component } from "react";
3
- import styled, { css } from "styled-components";
4
- import { MAX_WIDTH, GRAY_BASE_HEX } from "../../constants/style.js";
5
- import stdin_default$4 from "../RegisterModal/RegisterModal.js";
6
- import stdin_default$6 from "../RegisterConfirmModal/RegisterConfirmModal.js";
7
- import stdin_default$5 from "../TermsModal/TermsModal.js";
8
- import stdin_default$7 from "../ForgotPasswordModal/ForgotPasswordModal.js";
9
- import stdin_default$8 from "../ResetPasswordModal/ResetPasswordModal.js";
10
- import stdin_default$9 from "../ResetConfirmModal/ResetConfirmModal.js";
11
- import stdin_default$1 from "../LoginModal/LoginModal.js";
12
- import stdin_default$a from "../VerifyEmailModal/VerifyEmailModal.js";
13
- import stdin_default from "../Header/Header.js";
14
- import stdin_default$2 from "../2FA/EnterCode.js";
15
- import stdin_default$3 from "../2FA/ResetCode.js";
16
- import { authenticationApi } from "../../api/authenticationApi.js";
17
- import fetchDataPublic from "../../api/fetchDataPublic.js";
18
- import { AuthContext } from "../../context/AuthContext.js";
19
- import { withRouter } from "../../utils/withRouter.js";
20
- import { cooldownHOC } from "../../utils/customHooks.js";
21
- import { checkActionCode } from "firebase/auth";
22
- import { auth } from "../../firebase-config.js";
23
- import { getConfig } from "../../runtime-config.js";
24
- import { getBackofficeAppUrl } from "../../utils/app-urls-analytics-backoffice.js";
25
- import { track } from "../../analytics/index.js";
26
- import { isAccountLockedError, showAccountLockedModal } from "../../utils/show-account-locked-modal.js";
27
- import { navigateToHref } from "../../routing/navigate-app.js";
28
- const Outer = styled.div.withConfig({
29
- shouldForwardProp: (props) => !["fixed"].includes(props)
30
- })`
31
- position: relative;
32
- ${({ fixed }) => fixed && css`
33
- position: fixed;
34
- z-index: 99;
35
- top: 0;
36
- left: 50%;
37
- width: 100%;
38
- background: white;
39
- max-width: ${MAX_WIDTH}px;
40
- transform: translateX(-50%);
41
- border-left: 1px solid ${GRAY_BASE_HEX};
42
- border-right: 1px solid ${GRAY_BASE_HEX};
43
- `}
44
- `;
45
- const _HeaderHoClass = class _HeaderHoClass extends Component {
46
- constructor() {
47
- super(...arguments);
48
- this.state = {
49
- mobileMenuOpen: false,
50
- isModalOpen: {
51
- login: false,
52
- signUp: false,
53
- terms: false,
54
- confirm: false,
55
- forgot: false,
56
- resetPassword: false,
57
- confirmReset: false,
58
- enter2fa: false,
59
- resetCode: false,
60
- verifyEmail: false
61
- },
62
- userInfo: {
63
- email: void 0,
64
- password: void 0,
65
- newsletter: void 0,
66
- terms: void 0
67
- },
68
- popupError: {
69
- popup: void 0,
70
- message: void 0,
71
- field: void 0
72
- },
73
- popupSuccess: {
74
- popup: void 0,
75
- message: void 0
76
- },
77
- isActionLoading: void 0,
78
- termsData: void 0,
79
- isResettingExpiredToken: false
80
- };
81
- this.checkForModals = () => {
82
- const { isLogin, isSignUp, isResetPassword, isVerifyEmail } = this.props;
83
- const { user } = this.context;
84
- const { isModalOpen } = this.state;
85
- const { login, signUp, resetPassword, verifyEmail } = isModalOpen;
86
- const isAnyModalOpen = Object.values(isModalOpen).some((value) => value === true);
87
- if (isAnyModalOpen) return;
88
- if (isLogin && !user && !login) {
89
- this.setState((prevState) => ({
90
- ...prevState,
91
- isModalOpen: {
92
- ...isModalOpen,
93
- login: true
94
- }
95
- }));
96
- }
97
- if (isSignUp && !user && !signUp) {
98
- this.setState((prevState) => ({
99
- ...prevState,
100
- isModalOpen: {
101
- ...isModalOpen,
102
- signUp: true
103
- }
104
- }));
105
- }
106
- if (isResetPassword && !user && !resetPassword) {
107
- this.setState((prevState) => ({
108
- ...prevState,
109
- isModalOpen: {
110
- ...isModalOpen,
111
- resetPassword: true
112
- }
113
- }));
114
- }
115
- if (isVerifyEmail && !verifyEmail) {
116
- this.setState((prevState) => ({
117
- ...prevState,
118
- isModalOpen: {
119
- ...isModalOpen,
120
- verifyEmail: true
121
- }
122
- }));
123
- }
124
- };
125
- this.setOpenModalStatus = (modalId, status) => {
126
- const { isModalOpen } = this.state;
127
- const { onSignupModalClose, navigate } = this.props;
128
- if (!onSignupModalClose) {
129
- window.history.pushState("", "", modalId === "login" ? "/login" : modalId === "signUp" ? "/signup" : "/");
130
- if ((modalId === "login" || modalId === "signUp" || modalId === "resetPassword" || modalId === "verifyEmail") && !status) {
131
- navigate("/");
132
- }
133
- }
134
- this.setState((prevState) => ({
135
- ...prevState,
136
- isModalOpen: {
137
- ...isModalOpen,
138
- [modalId]: status
139
- },
140
- // we need to reset the expired token flag when closing forgot password modal
141
- ...modalId === "forgot" && !status && { isResettingExpiredToken: false }
142
- }));
143
- };
144
- this.switchOpenModal = (prevModalId, nextModalId) => {
145
- const { isModalOpen } = this.state;
146
- if (nextModalId === "login" || nextModalId === "signUp") {
147
- window.history.pushState("", "", nextModalId === "login" ? "/login" : nextModalId === "signUp" ? "/signup" : "/");
148
- }
149
- this.setState((prevState) => ({
150
- ...prevState,
151
- isModalOpen: {
152
- ...isModalOpen,
153
- [prevModalId]: false,
154
- [nextModalId]: true
155
- }
156
- }));
157
- };
158
- this.setUserInfo = (userInfo) => {
159
- this.setState((prevState) => ({
160
- ...prevState,
161
- userInfo
162
- }));
163
- };
164
- this.setPopupError = (popup, message, field = null) => {
165
- this.setState((prevState) => ({
166
- ...prevState,
167
- popupError: {
168
- popup,
169
- message,
170
- field
171
- }
172
- }));
173
- };
174
- this.clearPopupError = () => {
175
- this.setState((prevState) => ({
176
- ...prevState,
177
- popupError: {
178
- popup: void 0,
179
- message: void 0,
180
- field: void 0
181
- }
182
- }));
183
- };
184
- this.setPopupSuccess = (popup, message) => {
185
- this.setState((prevState) => ({
186
- ...prevState,
187
- popupSuccess: {
188
- popup,
189
- message
190
- }
191
- }));
192
- };
193
- this.clearPopupSuccess = () => {
194
- this.setState((prevState) => ({
195
- ...prevState,
196
- popupSuccess: {
197
- popup: void 0,
198
- message: void 0
199
- }
200
- }));
201
- };
202
- this.setIsActionLoading = (popup) => {
203
- this.setState({
204
- isActionLoading: popup
205
- });
206
- };
207
- }
208
- componentWillUnmount() {
209
- document.body.style.overflow = "unset";
210
- }
211
- componentDidUpdate(prevProps, prevState) {
212
- const isOpenCurrent = Object.values(this.state.isModalOpen).some((popup) => popup);
213
- const isOpenPrev = Object.values(prevState.isModalOpen).some((popup) => popup);
214
- const { mobileMenuOpen } = this.state;
215
- const { isFetchingUser, verifyEmailError } = this.context;
216
- if (!mobileMenuOpen) {
217
- if (isOpenCurrent) {
218
- document.body.style.overflow = "hidden";
219
- } else if (isOpenPrev) {
220
- document.body.style.overflow = "unset";
221
- }
222
- }
223
- if (verifyEmailError?.code === "auth/invalid-action-code" && !window.location.href.includes("login")) {
224
- this.props.navigate("/login");
225
- }
226
- if (!isFetchingUser) {
227
- this.checkForModals();
228
- }
229
- }
230
- render() {
231
- const { isModalOpen, userInfo, isActionLoading, termsData, isResettingExpiredToken } = this.state;
232
- const {
233
- fixed,
234
- activateMenu,
235
- activeMenu,
236
- withoutLoginSignupButton,
237
- useRelativePathForMenu,
238
- isLoginModalOpen,
239
- setIsLoginModalOpen,
240
- cooldown
241
- } = this.props;
242
- const {
243
- getUser,
244
- user = {},
245
- avatar,
246
- logoutUser,
247
- loginUser,
248
- waitingFor2fa,
249
- firebaseError,
250
- loginUserWithTotp,
251
- createUser,
252
- handleResetPassword,
253
- resendActivationEmail,
254
- verifyEmailError,
255
- isVerifyingEmail
256
- } = this.context;
257
- return /* @__PURE__ */ jsxs(Outer, { fixed, children: [
258
- /* @__PURE__ */ jsx(
259
- stdin_default,
260
- {
261
- user,
262
- activeMenu,
263
- activateMenu,
264
- useRelativePathForMenu,
265
- userPhoto: avatar,
266
- logoutUser,
267
- noFixedPosition: true,
268
- withoutLoginSignupButton,
269
- onLoginClick: () => {
270
- this.setOpenModalStatus("login", true);
271
- },
272
- onSignUpClick: () => {
273
- this.setOpenModalStatus("signUp", true);
274
- }
275
- }
276
- ),
277
- /* @__PURE__ */ jsx(
278
- stdin_default$1,
279
- {
280
- isActionLoading,
281
- popupError: this.state.popupError,
282
- isModalOpen: !!(isModalOpen.login || isLoginModalOpen),
283
- onModalClose: () => {
284
- this.setOpenModalStatus("login", false);
285
- setIsLoginModalOpen?.(false);
286
- this.clearPopupError();
287
- this.setIsActionLoading(void 0);
288
- },
289
- onModalSwitch: () => {
290
- this.switchOpenModal("login", "signUp");
291
- setIsLoginModalOpen?.(false);
292
- this.clearPopupError();
293
- this.setIsActionLoading(void 0);
294
- },
295
- onForgotPassword: () => {
296
- this.switchOpenModal("login", "forgot");
297
- setIsLoginModalOpen?.(false);
298
- this.clearPopupError();
299
- this.setIsActionLoading(void 0);
300
- },
301
- onFormSend: async ({ email, password }) => {
302
- this.clearPopupError();
303
- this.setIsActionLoading("login");
304
- try {
305
- if (password.length > 128) {
306
- this.setPopupError("login", "Your password cannot exceed 128 characters");
307
- this.setIsActionLoading(void 0);
308
- return;
309
- }
310
- await loginUser(email, password);
311
- await getUser();
312
- this.setOpenModalStatus("login", false);
313
- setIsLoginModalOpen?.(false);
314
- this.clearPopupError();
315
- this.setIsActionLoading(void 0);
316
- } catch (error) {
317
- const errorMessage = error?.message;
318
- if (error?.code === "auth/multi-factor-auth-required") {
319
- this.switchOpenModal("login", "enter2fa");
320
- this.clearPopupError();
321
- this.setIsActionLoading(void 0);
322
- return;
323
- }
324
- if (isAccountLockedError(error)) {
325
- this.setOpenModalStatus("login", false);
326
- setIsLoginModalOpen?.(false);
327
- this.clearPopupError();
328
- this.setIsActionLoading(void 0);
329
- await showAccountLockedModal();
330
- this.setOpenModalStatus("login", true);
331
- return;
332
- }
333
- if (errorMessage) {
334
- this.setPopupError("login", errorMessage);
335
- } else {
336
- this.setPopupError("login", "Oops. Something's not right there. Try again?");
337
- }
338
- this.setIsActionLoading(void 0);
339
- }
340
- }
341
- }
342
- ),
343
- waitingFor2fa && /* @__PURE__ */ jsx(
344
- stdin_default$2,
345
- {
346
- isModal: true,
347
- popupError: this.state.popupError,
348
- isActionLoading,
349
- isModalOpen: isModalOpen.enter2fa,
350
- onModalClose: () => {
351
- this.setOpenModalStatus("enter2fa", false);
352
- this.clearPopupError();
353
- this.setIsActionLoading(void 0);
354
- },
355
- onModalSwitch: () => {
356
- this.switchOpenModal("enter2fa", "resetCode");
357
- this.clearPopupError();
358
- this.setIsActionLoading(void 0);
359
- },
360
- onFormSend: async ({ otpInput }) => {
361
- this.setIsActionLoading("enter2fa");
362
- try {
363
- await loginUserWithTotp(otpInput, firebaseError);
364
- await getUser();
365
- this.setOpenModalStatus("enter2fa", false);
366
- this.clearPopupError();
367
- this.setIsActionLoading(void 0);
368
- } catch (error) {
369
- console.log("🚀 ~ file: HeaderHo.jsx:364 ~ error:", error);
370
- if (error?.code === "auth/invalid-verification-code") {
371
- this.setPopupError("enter2fa", "That’s not the right 2FA code. Try again");
372
- } else if (error?.code === "auth/code-expired") {
373
- this.setPopupError("enter2fa", "Time out. Please restart the flow and log in again");
374
- } else {
375
- this.setPopupError("enter2fa", error?.message);
376
- }
377
- }
378
- this.setIsActionLoading(void 0);
379
- }
380
- }
381
- ),
382
- /* @__PURE__ */ jsx(
383
- stdin_default$3,
384
- {
385
- isModalOpen: isModalOpen.resetCode,
386
- onModalClose: () => {
387
- this.setOpenModalStatus("resetCode", false);
388
- this.clearPopupError();
389
- this.setIsActionLoading(void 0);
390
- },
391
- onModalSwitch: () => {
392
- this.clearPopupError();
393
- this.setIsActionLoading(void 0);
394
- this.switchOpenModal("resetCode", "enter2fa");
395
- }
396
- }
397
- ),
398
- /* @__PURE__ */ jsx(
399
- stdin_default$4,
400
- {
401
- isActionLoading,
402
- popupError: this.state.popupError,
403
- clearPopupError: this.clearPopupError,
404
- setPopupError: this.setPopupError,
405
- isModalOpen: isModalOpen.signUp,
406
- onModalClose: () => {
407
- const { location, navigate, onSignupModalClose } = this.props;
408
- var body = document.getElementsByTagName("body")[0];
409
- body.style.overflow = "unset";
410
- this.setOpenModalStatus("signUp", false);
411
- this.clearPopupError();
412
- this.setIsActionLoading(void 0);
413
- onSignupModalClose?.();
414
- if (location?.state?.isHowStokrWorksRedirect) {
415
- navigate("/how-stokr-works/for-investors");
416
- }
417
- },
418
- onTermsClicked: (_termsData) => {
419
- this.setState((prevState) => ({
420
- ...prevState,
421
- termsData: _termsData
422
- }));
423
- this.switchOpenModal("signUp", "terms");
424
- this.clearPopupError();
425
- this.setIsActionLoading(void 0);
426
- },
427
- onModalSwitch: () => {
428
- this.switchOpenModal("signUp", "login");
429
- this.clearPopupError();
430
- this.setIsActionLoading(void 0);
431
- const { onSignupModalClose } = this.props;
432
- onSignupModalClose?.();
433
- },
434
- onFormSend: async (_userInfo) => {
435
- this.clearPopupError();
436
- this.setIsActionLoading("signUp");
437
- try {
438
- if (_userInfo.password.length > 128) {
439
- this.setPopupError("register", "Your password cannot exceed 128 characters", "password");
440
- this.setIsActionLoading(void 0);
441
- return;
442
- }
443
- await createUser(_userInfo.email, _userInfo.password);
444
- cooldown?.startCooldown();
445
- if (_userInfo.newsletter) {
446
- await fetchDataPublic("emails/subscribe", {
447
- email: _userInfo.email,
448
- listName: "newsletter"
449
- });
450
- }
451
- track("signup_account_created", { newsletter_opt_in: !!_userInfo.newsletter });
452
- this.setUserInfo(_userInfo);
453
- this.switchOpenModal("signUp", "confirm");
454
- this.setIsActionLoading(void 0);
455
- } catch (error) {
456
- console.log(error);
457
- let errorMessage = "Oops, something went wrong";
458
- if (error?.response?.status === 429) {
459
- errorMessage = error.response.data?.message;
460
- }
461
- this.setIsActionLoading(void 0);
462
- if (error?.code === "auth/email-already-in-use") {
463
- this.setPopupError("register", "This email address is already taken", "email");
464
- } else if (error?.code === "auth/weak-password") {
465
- this.setPopupError("register", "The password is too weak. Please try again.", "password");
466
- } else if (error?.code === "auth/error-code:-47") {
467
- this.setPopupError("register", "Too many signup attempts. Please try again later.");
468
- } else {
469
- this.setPopupError("register", errorMessage);
470
- }
471
- }
472
- }
473
- }
474
- ),
475
- /* @__PURE__ */ jsx(
476
- stdin_default$5,
477
- {
478
- isModalOpen: isModalOpen.terms,
479
- termsData,
480
- onModalClose: () => {
481
- this.setOpenModalStatus("terms", false);
482
- },
483
- onModalSwitch: () => {
484
- this.switchOpenModal("terms", "signUp");
485
- }
486
- }
487
- ),
488
- /* @__PURE__ */ jsx(
489
- stdin_default$6,
490
- {
491
- id: "form-submitted-popup",
492
- isActionLoading,
493
- userInfo,
494
- cooldown,
495
- popupError: this.state.popupError,
496
- popupSuccess: this.state.popupSuccess,
497
- isModalOpen: isModalOpen.confirm,
498
- onModalClose: () => {
499
- this.setOpenModalStatus("confirm", false);
500
- this.clearPopupSuccess();
501
- this.clearPopupError();
502
- this.setIsActionLoading(void 0);
503
- },
504
- onResend: async () => {
505
- this.clearPopupSuccess();
506
- this.clearPopupError();
507
- this.setIsActionLoading("resend");
508
- try {
509
- const email = this.state.userInfo.email;
510
- await resendActivationEmail(email);
511
- cooldown?.startCooldown();
512
- this.setPopupSuccess("resend", "Email sent.");
513
- this.setIsActionLoading(void 0);
514
- } catch (error) {
515
- console.log(error);
516
- this.setPopupError("resend", "Something went wrong.");
517
- this.setIsActionLoading(void 0);
518
- }
519
- }
520
- }
521
- ),
522
- /* @__PURE__ */ jsx(
523
- stdin_default$7,
524
- {
525
- isActionLoading,
526
- popupError: this.state.popupError,
527
- popupSuccess: this.state.popupSuccess,
528
- isModalOpen: isModalOpen.forgot,
529
- isResettingExpiredToken,
530
- onModalClose: () => {
531
- this.setOpenModalStatus("forgot", false);
532
- this.clearPopupError();
533
- this.clearPopupSuccess();
534
- this.setIsActionLoading(void 0);
535
- if (isResettingExpiredToken) {
536
- this.setOpenModalStatus("resetPassword", false);
537
- }
538
- },
539
- onModalSwitch: () => {
540
- this.switchOpenModal("forgot", "login");
541
- this.clearPopupError();
542
- this.clearPopupSuccess();
543
- this.setIsActionLoading(void 0);
544
- },
545
- onFormSend: async ({ email }) => {
546
- this.clearPopupError();
547
- this.setIsActionLoading("forgot");
548
- const payload = { email };
549
- if (isResettingExpiredToken) {
550
- console.log("isResettingExpiredToken: ", isResettingExpiredToken);
551
- payload.ventureInvite = true;
552
- }
553
- try {
554
- await authenticationApi.post("forgotPass", payload);
555
- this.setPopupSuccess(
556
- "forgot",
557
- `We sent a message to ${email} (you might need to check your junk or spam folder) — tap the link inside to create a new password.`
558
- );
559
- this.setIsActionLoading(void 0);
560
- } catch (error) {
561
- console.log(error);
562
- let errorMessage = `Too many requests. Please try again later.`;
563
- console.log(error?.response);
564
- if (error?.response?.status === 429 || error?.includes("429")) {
565
- errorMessage = error.response.data?.message;
566
- }
567
- this.setPopupError("forgot", errorMessage);
568
- this.setIsActionLoading(void 0);
569
- }
570
- }
571
- }
572
- ),
573
- /* @__PURE__ */ jsx(
574
- stdin_default$8,
575
- {
576
- isActionLoading,
577
- popupError: this.state.popupError,
578
- isModalOpen: isModalOpen.resetPassword,
579
- onModalClose: () => {
580
- const url = new URL(window.location);
581
- url.searchParams.delete("oobCode");
582
- url.searchParams.delete("mode");
583
- window.history.replaceState({}, "", url.toString());
584
- this.setOpenModalStatus("resetPassword", false);
585
- this.clearPopupError();
586
- this.setIsActionLoading(void 0);
587
- },
588
- onModalSwitch: () => {
589
- window.history.pushState({}, null, "/login");
590
- this.switchOpenModal("resetPassword", "login");
591
- this.clearPopupError();
592
- this.setIsActionLoading(void 0);
593
- },
594
- onFormSend: async ({ password }) => {
595
- this.clearPopupError();
596
- this.setIsActionLoading("resetPassword");
597
- try {
598
- await handleResetPassword(password);
599
- this.switchOpenModal("resetPassword", "confirmReset");
600
- this.setIsActionLoading(void 0);
601
- } catch (error) {
602
- console.log(error);
603
- this.setPopupError("resetPassword", error?.message || "Something went wrong.");
604
- this.setIsActionLoading(void 0);
605
- }
606
- },
607
- onLoad: async () => {
608
- const { location } = this.props;
609
- const query = new URLSearchParams(location?.search);
610
- const oobCode = query.get("oobCode");
611
- if (oobCode && oobCode !== "") {
612
- this.setIsActionLoading("resetPassword");
613
- try {
614
- await checkActionCode(auth, oobCode);
615
- this.setIsActionLoading(void 0);
616
- } catch (error) {
617
- console.log("Password reset code error:", error);
618
- if (error?.code === "auth/expired-action-code") {
619
- this.setState((prevState) => ({
620
- ...prevState,
621
- isResettingExpiredToken: true
622
- }));
623
- const url = new URL(window.location);
624
- url.searchParams.delete("oobCode");
625
- url.searchParams.delete("mode");
626
- window.history.replaceState({}, "", url.toString());
627
- this.switchOpenModal("resetPassword", "forgot");
628
- } else {
629
- this.setPopupError(
630
- "resetPassword",
631
- "Something went wrong with the password reset link. Please try again."
632
- );
633
- }
634
- }
635
- this.setIsActionLoading(void 0);
636
- }
637
- }
638
- }
639
- ),
640
- /* @__PURE__ */ jsx(
641
- stdin_default$9,
642
- {
643
- isModalOpen: isModalOpen.confirmReset,
644
- onModalClose: () => {
645
- this.setOpenModalStatus("confirmReset", false);
646
- },
647
- onModalSwitch: () => {
648
- const { location } = this.props;
649
- const query = new URLSearchParams(location?.search);
650
- let userType = query.get("user_type");
651
- if (userType && userType === "sa") {
652
- navigateToHref(this.props.navigate, getBackofficeAppUrl());
653
- } else {
654
- this.switchOpenModal("confirmReset", "login");
655
- }
656
- }
657
- }
658
- ),
659
- !isVerifyingEmail && /* @__PURE__ */ jsx(
660
- stdin_default$a,
661
- {
662
- id: "verify-email-popup",
663
- isActionLoading,
664
- popupError: this.state.popupError,
665
- popupSuccess: this.state.popupSuccess,
666
- isModalOpen: isModalOpen.verifyEmail,
667
- continueUrl: `${getConfig("onboardingUrl")}/welcome`,
668
- error: verifyEmailError,
669
- isSuccess: !verifyEmailError,
670
- onModalSwitch: () => {
671
- this.switchOpenModal("verifyEmail", "login");
672
- this.clearPopupError();
673
- this.setIsActionLoading(void 0);
674
- },
675
- onModalClose: () => {
676
- this.setOpenModalStatus("verifyEmail", false);
677
- this.clearPopupSuccess();
678
- this.clearPopupError();
679
- this.setIsActionLoading(void 0);
680
- },
681
- onResend: async (values) => {
682
- this.clearPopupSuccess();
683
- this.clearPopupError();
684
- this.setIsActionLoading("resend");
685
- try {
686
- const email = values?.email;
687
- await resendActivationEmail(email);
688
- this.setPopupSuccess("resend", "Email sent.");
689
- this.setIsActionLoading(void 0);
690
- } catch (error) {
691
- console.log(error);
692
- this.setPopupError("resend", error?.message || "Something went wrong.");
693
- this.setIsActionLoading(void 0);
694
- }
695
- }
696
- }
697
- )
698
- ] });
699
- }
700
- };
701
- _HeaderHoClass.propTypes = {};
702
- _HeaderHoClass.contextType = AuthContext;
703
- let HeaderHoClass = _HeaderHoClass;
704
- const HeaderHo = withRouter(cooldownHOC(HeaderHoClass, 90));
705
- export {
706
- HeaderHo
707
- };