@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,56 +0,0 @@
1
- import { getApps, getApp, initializeApp } from "firebase/app";
2
- import { initializeAuth, inMemoryPersistence, getAuth } from "firebase/auth";
3
- import { getConfig } from "./runtime-config.js";
4
- let app = null;
5
- let auth = null;
6
- function isValidFirebaseConfig(config) {
7
- return config?.apiKey != null && String(config.apiKey).trim() !== "";
8
- }
9
- function getFirebaseAuth() {
10
- return auth;
11
- }
12
- function initFirebase(configOverride) {
13
- const firebaseConfig = configOverride != null ? configOverride : getConfig("firebase");
14
- if (!isValidFirebaseConfig(firebaseConfig)) {
15
- if (configOverride && typeof console !== "undefined" && console.warn) {
16
- console.warn(
17
- "[firebase-config] initFirebase() received a config with no valid apiKey. Ensure all VITE_FIREBASE_* variables are defined in your .env file and the dev server was restarted."
18
- );
19
- }
20
- return;
21
- }
22
- try {
23
- const existingApps = getApps();
24
- if (existingApps.length > 0) {
25
- app = getApp();
26
- } else {
27
- app = initializeApp(firebaseConfig);
28
- }
29
- try {
30
- auth = initializeAuth(app, { persistence: inMemoryPersistence });
31
- } catch (initErr) {
32
- auth = getAuth(app);
33
- if (typeof console !== "undefined" && console.warn) {
34
- console.warn(
35
- "[firebase-config] initializeAuth() failed (auth already initialized by another module). Falling back to getAuth() — if sign-in hangs for 30s, ensure this module loads BEFORE @stokr/components-library. Error:",
36
- initErr?.message || initErr
37
- );
38
- }
39
- }
40
- } catch (err) {
41
- app = null;
42
- auth = null;
43
- if (typeof console !== "undefined" && console.warn) {
44
- console.warn(
45
- "[firebase-config] Firebase init failed (e.g. invalid API key or duplicate app):",
46
- err?.code || err?.message || err
47
- );
48
- }
49
- }
50
- }
51
- export {
52
- auth,
53
- getFirebaseAuth,
54
- initFirebase,
55
- isValidFirebaseConfig
56
- };
@@ -1,235 +0,0 @@
1
- import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
- import { useState, useContext, useCallback, useEffect } from "react";
3
- import { AuthContext } from "../context/AuthContext.js";
4
- import fetchDataPublic from "../api/fetchDataPublic.js";
5
- import parse from "html-react-parser";
6
- import { useCheckboxes } from "../context/Checkbox/CheckboxContext.js";
7
- const initialState = {
8
- email: "",
9
- name: "",
10
- mailingList: false,
11
- privateInvestorList: false,
12
- mailingListText: /* @__PURE__ */ jsx(Fragment, { children: "You just want to be updated on the project. Subscribe here for further information going forward." }),
13
- privateInvestorListText: /* @__PURE__ */ jsxs(Fragment, { children: [
14
- "You are a professional investor or an investor willing to invest in private offerings. Subscribe here to be contacted by a dedicated team to help you confirm your eligibility for this investment.",
15
- /* @__PURE__ */ jsx("br", {}),
16
- " ",
17
- /* @__PURE__ */ jsx("br", {}),
18
- "You are seeking to invest on your own initiative and any potential investments arose as a result of your direct inquiry and outreach."
19
- ] }),
20
- mailingListDisabled: false,
21
- privateInvestorListDisabled: false,
22
- optionalCheckBox: false,
23
- optionalCheckBoxText: "",
24
- optionalCheckBoxChecked: false,
25
- checkedCheckboxes: [],
26
- isSubmitting: false,
27
- successMessage: null,
28
- errorMessage: null
29
- };
30
- const getProjectSubscription = (user, project) => {
31
- if (!user || !project?._id) {
32
- return {
33
- isPrivateInvestor: false,
34
- isSubscribed: false,
35
- privateInvestorStatus: null
36
- };
37
- }
38
- if (user.privateInvestorProjects && user.subscribedProjects) {
39
- const privateInvestorProject = user.privateInvestorProjects.find((p) => p.projectId === project._id);
40
- const subscribedProject = user.subscribedProjects[project.name];
41
- return {
42
- isPrivateInvestor: !!privateInvestorProject?.isAllowed,
43
- isSubscribed: !!subscribedProject,
44
- privateInvestorStatus: privateInvestorProject?.status
45
- };
46
- }
47
- return {
48
- isPrivateInvestor: user.isPrivateInvestor,
49
- isSubscribed: user.isSubscribed,
50
- privateInvestorStatus: user.privateInvestorStatus
51
- };
52
- };
53
- const updateUserSubscription = (user, project, updates) => {
54
- if (!user) return user;
55
- if (user.privateInvestorProjects && user.subscribedProjects) {
56
- const updatedUser = { ...user };
57
- if (updates.isPrivateInvestor !== void 0) {
58
- const existingIndex = updatedUser.privateInvestorProjects.findIndex((p) => p.projectId === project._id);
59
- if (existingIndex >= 0) {
60
- updatedUser.privateInvestorProjects[existingIndex] = {
61
- ...updatedUser.privateInvestorProjects[existingIndex],
62
- ...updates
63
- };
64
- } else {
65
- updatedUser.privateInvestorProjects = [
66
- ...updatedUser.privateInvestorProjects,
67
- { projectId: project._id, status: "New", ...updates }
68
- ];
69
- }
70
- }
71
- if (updates.isSubscribed !== void 0) {
72
- updatedUser.subscribedProjects[project.name] = updates.isSubscribed;
73
- }
74
- return updatedUser;
75
- }
76
- return { ...user, ...updates };
77
- };
78
- const resolveUserDisplayName = (user) => {
79
- if (!user) return "";
80
- const fullNameFromParts = `${user.firstName || ""} ${user.lastName || ""}`.trim();
81
- return user.username || user.name || user.fullName || fullNameFromParts || "";
82
- };
83
- const useNewVentureForm = ({ project, user, salesChannel, customSuccessMessage }) => {
84
- const [formValues, setFormValues] = useState(initialState);
85
- const { setUser, checkPrivateInvestorAll, checkIfUserSubscribedAll } = useContext(AuthContext);
86
- const { checkboxes, isLoading: isLoadingCheckboxes } = useCheckboxes("newVentureModal", {
87
- group: "newVentureModal"
88
- });
89
- const handleSubmit = useCallback(
90
- async (values) => {
91
- setFormValues((prev) => ({ ...prev, isSubmitting: true }));
92
- try {
93
- const dataToSend = {
94
- email: values.email || user?.email || "",
95
- projectId: project._id,
96
- name: values.name || resolveUserDisplayName(user),
97
- checkedCheckboxes: formValues.checkedCheckboxes,
98
- salesChannel: salesChannel ? salesChannel : window.location.pathname.includes("featured-assets") ? "featuredAssets" : "investor"
99
- };
100
- if (values.privateInvestorList && !formValues.privateInvestorListDisabled) {
101
- dataToSend.createPrivateInvestor = true;
102
- }
103
- if (values.mailingList && !formValues.mailingListDisabled) {
104
- dataToSend.subscribeToProject = true;
105
- }
106
- const response = await fetchDataPublic("private-investor/public/create", dataToSend);
107
- let updates = {};
108
- if (response?.privateInvestor) {
109
- updates.privateInvestorStatus = response.privateInvestor.status;
110
- updates.isPrivateInvestor = response.privateInvestor.isAllowed || false;
111
- }
112
- if (response?.subscribedToProject) {
113
- updates.isSubscribed = true;
114
- }
115
- const updatedUser = updateUserSubscription(user, project, updates);
116
- setUser(updatedUser);
117
- setFormValues((prev) => ({
118
- ...prev,
119
- successMessage: customSuccessMessage ? customSuccessMessage : /* @__PURE__ */ jsxs(Fragment, { children: [
120
- "Please continue onboarding, an account manager will reach out to you.",
121
- /* @__PURE__ */ jsx("br", {}),
122
- "If you are an existing account holder, kindly log in and make sure your account is fully verified."
123
- ] }),
124
- errorMessage: null,
125
- isSubmitting: false
126
- }));
127
- return response;
128
- } catch (error) {
129
- let errorMessage;
130
- if (error?.response?.status === 406) {
131
- errorMessage = error.response.data?.substring(7) || "You are already added to this project.";
132
- } else {
133
- errorMessage = /* @__PURE__ */ jsxs(Fragment, { children: [
134
- "Something went wrong. Please try again a bit later or contact us at",
135
- " ",
136
- /* @__PURE__ */ jsx("a", { href: "mailto:support@stokr.io", style: { color: "inherit" }, children: "support@stokr.io" }),
137
- " "
138
- ] });
139
- }
140
- setFormValues((prev) => ({
141
- ...prev,
142
- errorMessage,
143
- successMessage: null,
144
- isSubmitting: false
145
- }));
146
- throw error;
147
- }
148
- },
149
- // eslint-disable-next-line react-hooks/exhaustive-deps
150
- [
151
- project,
152
- formValues.checkedCheckboxes,
153
- formValues.privateInvestorListDisabled,
154
- formValues.mailingListDisabled,
155
- user,
156
- setUser
157
- ]
158
- );
159
- const checkUserProjectStatus = async () => {
160
- const promises = [];
161
- const projectSubscription = getProjectSubscription(user, project);
162
- const needsPrivateInvestorData = projectSubscription.isPrivateInvestor === void 0;
163
- const needsSubscriptionData = projectSubscription.isSubscribed === void 0;
164
- if (needsPrivateInvestorData) {
165
- promises.push(checkPrivateInvestorAll(user, true));
166
- }
167
- if (needsSubscriptionData) {
168
- promises.push(checkIfUserSubscribedAll(user, true));
169
- }
170
- if (promises.length === 0) return;
171
- try {
172
- const results = await Promise.all(promises);
173
- const updatedUser = { ...user };
174
- results.forEach((result) => {
175
- if (result) {
176
- Object.assign(updatedUser, result);
177
- }
178
- });
179
- setUser(updatedUser);
180
- } catch (error) {
181
- console.error("Failed to check user status for project:", error);
182
- }
183
- };
184
- useEffect(() => {
185
- if (!user || !user._id || !(project && project._id)) return;
186
- checkUserProjectStatus();
187
- }, [user, project]);
188
- useEffect(() => {
189
- let formValuesCopy = { ...formValues };
190
- if (checkboxes) {
191
- Object.values(checkboxes).forEach((checkbox) => {
192
- if (checkbox.label === "createPrivateInvestor" && !formValuesCopy.privateInvestorListDisabled) {
193
- formValuesCopy.privateInvestorListText = parse(checkbox.agreementText);
194
- } else if (checkbox.label === "subscribeToProject" && !formValuesCopy.mailingListDisabled) {
195
- formValuesCopy.mailingListText = parse(checkbox.agreementText);
196
- }
197
- });
198
- }
199
- if (user?._id) {
200
- formValuesCopy.email = user.email || "";
201
- formValuesCopy.name = resolveUserDisplayName(user);
202
- const projectSubscription = getProjectSubscription(user, project);
203
- if (projectSubscription.isPrivateInvestor) {
204
- formValuesCopy.privateInvestorListText = "You are already registered on the whitelist.";
205
- formValuesCopy.privateInvestorList = true;
206
- formValuesCopy.privateInvestorListDisabled = true;
207
- } else if (projectSubscription.privateInvestorStatus && projectSubscription.privateInvestorStatus !== "Admitted") {
208
- formValuesCopy.privateInvestorListText = "Your profile is under review. An account manager will reach out to you to confirm your eligibility.";
209
- formValuesCopy.privateInvestorList = true;
210
- formValuesCopy.privateInvestorListDisabled = true;
211
- }
212
- if (projectSubscription.isSubscribed) {
213
- formValuesCopy.mailingList = true;
214
- formValuesCopy.mailingListText = "You already subscribed to the email notification list.";
215
- formValuesCopy.mailingListDisabled = true;
216
- }
217
- }
218
- setFormValues(formValuesCopy);
219
- }, [user, checkboxes, project]);
220
- const updateCheckedCheckboxes = useCallback((_checkboxes) => {
221
- setFormValues((prev) => ({ ...prev, checkedCheckboxes: _checkboxes }));
222
- }, []);
223
- return {
224
- // Form state
225
- ...formValues,
226
- // Loading state
227
- isLoading: isLoadingCheckboxes,
228
- // Actions
229
- handleSubmit,
230
- updateCheckedCheckboxes
231
- };
232
- };
233
- export {
234
- useNewVentureForm
235
- };