@nocios/crudify-ui 1.0.60 → 1.0.61
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.
- package/dist/index.js +129 -133
- package/dist/index.mjs +98 -102
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -139,89 +139,8 @@ var useTranslation = () => {
|
|
|
139
139
|
};
|
|
140
140
|
|
|
141
141
|
// src/components/CrudifyLogin/Forms/LoginForm.tsx
|
|
142
|
-
var import_react4 = require("react");
|
|
143
|
-
var import_material = require("@mui/material");
|
|
144
|
-
|
|
145
|
-
// src/components/CrudifyLogin/hooks/useCrudifyLogin.ts
|
|
146
142
|
var import_react3 = require("react");
|
|
147
|
-
var
|
|
148
|
-
|
|
149
|
-
// src/components/CrudifyLogin/utils/cookies.ts
|
|
150
|
-
var getCookie = (name) => {
|
|
151
|
-
const match = document.cookie.match(new RegExp("(^|;)\\s*" + name + "=([^;]+)"));
|
|
152
|
-
return match ? match[2] : null;
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
// src/components/CrudifyLogin/hooks/useCrudifyLogin.ts
|
|
156
|
-
var useCrudifyLogin = (config, _options = {}) => {
|
|
157
|
-
const finalConfig = (0, import_react3.useMemo)(() => {
|
|
158
|
-
const publicApiKey = config.publicApiKey || getCookie("publicApiKey") || null;
|
|
159
|
-
const rawEnv = config.env || getCookie("environment") || "prod";
|
|
160
|
-
const env = ["dev", "stg", "prod"].includes(rawEnv) ? rawEnv : "prod";
|
|
161
|
-
const appName = config.appName || getCookie("appName") || "Crudia";
|
|
162
|
-
const loginActions = config.loginActions || (() => {
|
|
163
|
-
try {
|
|
164
|
-
const cookieValue = getCookie("loginActions");
|
|
165
|
-
return cookieValue ? cookieValue.split(",").map((action) => action.trim()).filter(Boolean) : [];
|
|
166
|
-
} catch {
|
|
167
|
-
return [];
|
|
168
|
-
}
|
|
169
|
-
})();
|
|
170
|
-
return {
|
|
171
|
-
publicApiKey,
|
|
172
|
-
env,
|
|
173
|
-
appName,
|
|
174
|
-
loginActions
|
|
175
|
-
};
|
|
176
|
-
}, [config]);
|
|
177
|
-
(0, import_react3.useEffect)(() => {
|
|
178
|
-
console.log("\u{1F527} useCrudifyLogin useEffect triggered:", {
|
|
179
|
-
publicApiKey: !!finalConfig.publicApiKey,
|
|
180
|
-
env: finalConfig.env,
|
|
181
|
-
hasPublicApiKey: !!finalConfig.publicApiKey
|
|
182
|
-
});
|
|
183
|
-
if (!finalConfig.publicApiKey) {
|
|
184
|
-
console.log("\u274C No publicApiKey, skipping crudify initialization");
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
try {
|
|
188
|
-
console.log("\u2699\uFE0F Configuring crudify with env:", finalConfig.env);
|
|
189
|
-
import_crudify_browser.default.config(finalConfig.env);
|
|
190
|
-
console.log("\u{1F680} Initializing crudify with publicApiKey:", finalConfig.publicApiKey.substring(0, 10) + "...");
|
|
191
|
-
import_crudify_browser.default.init(finalConfig.publicApiKey, "none");
|
|
192
|
-
console.log("\u2705 Crudify initialization completed");
|
|
193
|
-
console.log("\u{1F50D} Crudify state after init:", {
|
|
194
|
-
hasTransaction: typeof import_crudify_browser.default.transaction === "function",
|
|
195
|
-
hasLogin: typeof import_crudify_browser.default.login === "function",
|
|
196
|
-
crudifyObject: import_crudify_browser.default
|
|
197
|
-
});
|
|
198
|
-
} catch (error) {
|
|
199
|
-
console.error("\u274C Error initializing crudify:", error);
|
|
200
|
-
}
|
|
201
|
-
}, [finalConfig.publicApiKey, finalConfig.env]);
|
|
202
|
-
const crudifyMethods = (0, import_react3.useMemo)(() => {
|
|
203
|
-
console.log("\u{1F504} crudifyMethods useMemo triggered:", {
|
|
204
|
-
publicApiKey: !!finalConfig.publicApiKey,
|
|
205
|
-
crudifyLogin: typeof import_crudify_browser.default.login,
|
|
206
|
-
crudifyTransaction: typeof import_crudify_browser.default.transaction
|
|
207
|
-
});
|
|
208
|
-
if (!finalConfig.publicApiKey) {
|
|
209
|
-
console.log("\u274C No publicApiKey, returning null crudifyMethods");
|
|
210
|
-
return null;
|
|
211
|
-
}
|
|
212
|
-
const methods = {
|
|
213
|
-
login: import_crudify_browser.default.login,
|
|
214
|
-
transaction: import_crudify_browser.default.transaction
|
|
215
|
-
};
|
|
216
|
-
console.log("\u2705 Returning crudifyMethods:", {
|
|
217
|
-
hasLogin: typeof methods.login === "function",
|
|
218
|
-
hasTransaction: typeof methods.transaction === "function",
|
|
219
|
-
methods
|
|
220
|
-
});
|
|
221
|
-
return methods;
|
|
222
|
-
}, [finalConfig.publicApiKey]);
|
|
223
|
-
return { crudify: crudifyMethods };
|
|
224
|
-
};
|
|
143
|
+
var import_material = require("@mui/material");
|
|
225
144
|
|
|
226
145
|
// src/components/CrudifyLogin/utils/secureStorage.ts
|
|
227
146
|
var import_crypto_js = __toESM(require("crypto-js"));
|
|
@@ -334,19 +253,15 @@ var secureLocalStorage = new SecureStorage("localStorage");
|
|
|
334
253
|
|
|
335
254
|
// src/components/CrudifyLogin/Forms/LoginForm.tsx
|
|
336
255
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
337
|
-
var LoginForm = ({ config, onNavigate, onLoginSuccess, onError, redirectUrl = "/", searchParams }) => {
|
|
338
|
-
const [username, setUsername] = (0,
|
|
339
|
-
const [password, setPassword] = (0,
|
|
340
|
-
const [loading, setLoading] = (0,
|
|
341
|
-
const [errors, setErrors] = (0,
|
|
342
|
-
const [helperTextEmail, setHelperTextEmail] = (0,
|
|
343
|
-
const [helperTextPassword, setHelperTextPassword] = (0,
|
|
256
|
+
var LoginForm = ({ config, onNavigate, onLoginSuccess, onError, redirectUrl = "/", searchParams, crudify: crudify3 }) => {
|
|
257
|
+
const [username, setUsername] = (0, import_react3.useState)("");
|
|
258
|
+
const [password, setPassword] = (0, import_react3.useState)("");
|
|
259
|
+
const [loading, setLoading] = (0, import_react3.useState)(false);
|
|
260
|
+
const [errors, setErrors] = (0, import_react3.useState)([]);
|
|
261
|
+
const [helperTextEmail, setHelperTextEmail] = (0, import_react3.useState)(null);
|
|
262
|
+
const [helperTextPassword, setHelperTextPassword] = (0, import_react3.useState)(null);
|
|
344
263
|
const { t } = useTranslation();
|
|
345
|
-
const usernameInputRef = (0,
|
|
346
|
-
const { crudify: crudifyFromHook } = useCrudifyLogin(config, {
|
|
347
|
-
showErrorNotifications: false,
|
|
348
|
-
showSuccessNotifications: false
|
|
349
|
-
});
|
|
264
|
+
const usernameInputRef = (0, import_react3.useRef)(null);
|
|
350
265
|
const getRedirectUrl = () => {
|
|
351
266
|
if (searchParams) {
|
|
352
267
|
const redirectParam = searchParams.get("redirect");
|
|
@@ -362,7 +277,7 @@ var LoginForm = ({ config, onNavigate, onLoginSuccess, onError, redirectUrl = "/
|
|
|
362
277
|
}
|
|
363
278
|
return redirectUrl || "/";
|
|
364
279
|
};
|
|
365
|
-
(0,
|
|
280
|
+
(0, import_react3.useEffect)(() => {
|
|
366
281
|
const timer = setTimeout(() => {
|
|
367
282
|
if (usernameInputRef.current) usernameInputRef.current.focus();
|
|
368
283
|
}, 100);
|
|
@@ -399,10 +314,10 @@ var LoginForm = ({ config, onNavigate, onLoginSuccess, onError, redirectUrl = "/
|
|
|
399
314
|
setHelperTextPassword(null);
|
|
400
315
|
setLoading(true);
|
|
401
316
|
try {
|
|
402
|
-
if (!
|
|
317
|
+
if (!crudify3) {
|
|
403
318
|
throw new Error("Crudify not initialized");
|
|
404
319
|
}
|
|
405
|
-
const response = await
|
|
320
|
+
const response = await crudify3.login(username, password);
|
|
406
321
|
setLoading(false);
|
|
407
322
|
if (response.success) {
|
|
408
323
|
secureSessionStorage.setToken(response.data.token);
|
|
@@ -586,18 +501,17 @@ var LoginForm = ({ config, onNavigate, onLoginSuccess, onError, redirectUrl = "/
|
|
|
586
501
|
var LoginForm_default = LoginForm;
|
|
587
502
|
|
|
588
503
|
// src/components/CrudifyLogin/Forms/ForgotPasswordForm.tsx
|
|
589
|
-
var
|
|
504
|
+
var import_react4 = require("react");
|
|
590
505
|
var import_material2 = require("@mui/material");
|
|
591
506
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
592
|
-
var ForgotPasswordForm = ({ config, onNavigate, onError }) => {
|
|
593
|
-
const [email, setEmail] = (0,
|
|
594
|
-
const [loading, setLoading] = (0,
|
|
595
|
-
const [errors, setErrors] = (0,
|
|
596
|
-
const [helperTextEmail, setHelperTextEmail] = (0,
|
|
597
|
-
const [emailSent, setEmailSent] = (0,
|
|
598
|
-
const [codeAlreadyExists, setCodeAlreadyExists] = (0,
|
|
507
|
+
var ForgotPasswordForm = ({ config, onNavigate, onError, crudify: crudify3 }) => {
|
|
508
|
+
const [email, setEmail] = (0, import_react4.useState)("");
|
|
509
|
+
const [loading, setLoading] = (0, import_react4.useState)(false);
|
|
510
|
+
const [errors, setErrors] = (0, import_react4.useState)([]);
|
|
511
|
+
const [helperTextEmail, setHelperTextEmail] = (0, import_react4.useState)(null);
|
|
512
|
+
const [emailSent, setEmailSent] = (0, import_react4.useState)(false);
|
|
513
|
+
const [codeAlreadyExists, setCodeAlreadyExists] = (0, import_react4.useState)(false);
|
|
599
514
|
const { t } = useTranslation();
|
|
600
|
-
const { crudify: crudify3 } = useCrudifyLogin(config);
|
|
601
515
|
const validateEmail = (email2) => {
|
|
602
516
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
603
517
|
return emailRegex.test(email2);
|
|
@@ -739,25 +653,24 @@ var ForgotPasswordForm = ({ config, onNavigate, onError }) => {
|
|
|
739
653
|
var ForgotPasswordForm_default = ForgotPasswordForm;
|
|
740
654
|
|
|
741
655
|
// src/components/CrudifyLogin/Forms/ResetPasswordForm.tsx
|
|
742
|
-
var
|
|
656
|
+
var import_react5 = require("react");
|
|
743
657
|
var import_material3 = require("@mui/material");
|
|
744
658
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
745
|
-
var ResetPasswordForm = ({ config, onNavigate, onError, searchParams, onResetSuccess }) => {
|
|
746
|
-
const [newPassword, setNewPassword] = (0,
|
|
747
|
-
const [confirmPassword, setConfirmPassword] = (0,
|
|
748
|
-
const [loading, setLoading] = (0,
|
|
749
|
-
const [errors, setErrors] = (0,
|
|
750
|
-
const [helperTextNewPassword, setHelperTextNewPassword] = (0,
|
|
751
|
-
const [helperTextConfirmPassword, setHelperTextConfirmPassword] = (0,
|
|
752
|
-
const [email, setEmail] = (0,
|
|
753
|
-
const [code, setCode] = (0,
|
|
754
|
-
const [fromCodeVerification, setFromCodeVerification] = (0,
|
|
755
|
-
const [validatingCode, setValidatingCode] = (0,
|
|
756
|
-
const [codeValidated, setCodeValidated] = (0,
|
|
757
|
-
const [pendingValidation, setPendingValidation] = (0,
|
|
659
|
+
var ResetPasswordForm = ({ config, onNavigate, onError, searchParams, onResetSuccess, crudify: crudify3 }) => {
|
|
660
|
+
const [newPassword, setNewPassword] = (0, import_react5.useState)("");
|
|
661
|
+
const [confirmPassword, setConfirmPassword] = (0, import_react5.useState)("");
|
|
662
|
+
const [loading, setLoading] = (0, import_react5.useState)(false);
|
|
663
|
+
const [errors, setErrors] = (0, import_react5.useState)([]);
|
|
664
|
+
const [helperTextNewPassword, setHelperTextNewPassword] = (0, import_react5.useState)(null);
|
|
665
|
+
const [helperTextConfirmPassword, setHelperTextConfirmPassword] = (0, import_react5.useState)(null);
|
|
666
|
+
const [email, setEmail] = (0, import_react5.useState)("");
|
|
667
|
+
const [code, setCode] = (0, import_react5.useState)("");
|
|
668
|
+
const [fromCodeVerification, setFromCodeVerification] = (0, import_react5.useState)(false);
|
|
669
|
+
const [validatingCode, setValidatingCode] = (0, import_react5.useState)(true);
|
|
670
|
+
const [codeValidated, setCodeValidated] = (0, import_react5.useState)(false);
|
|
671
|
+
const [pendingValidation, setPendingValidation] = (0, import_react5.useState)(null);
|
|
758
672
|
const { t } = useTranslation();
|
|
759
|
-
|
|
760
|
-
(0, import_react6.useEffect)(() => {
|
|
673
|
+
(0, import_react5.useEffect)(() => {
|
|
761
674
|
if (searchParams) {
|
|
762
675
|
const fromCodeVerificationParam = searchParams.get("fromCodeVerification");
|
|
763
676
|
const emailParam = searchParams.get("email");
|
|
@@ -801,7 +714,7 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams, onResetSuc
|
|
|
801
714
|
setValidatingCode(false);
|
|
802
715
|
setTimeout(() => onNavigate?.("/login/forgotPassword"), 3e3);
|
|
803
716
|
}, [searchParams, crudify3, t, onNavigate]);
|
|
804
|
-
(0,
|
|
717
|
+
(0, import_react5.useEffect)(() => {
|
|
805
718
|
console.log("\u{1F504} Pending validation useEffect triggered:", {
|
|
806
719
|
crudify: !!crudify3,
|
|
807
720
|
pendingValidation,
|
|
@@ -1055,18 +968,17 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams, onResetSuc
|
|
|
1055
968
|
var ResetPasswordForm_default = ResetPasswordForm;
|
|
1056
969
|
|
|
1057
970
|
// src/components/CrudifyLogin/Forms/CheckCodeForm.tsx
|
|
1058
|
-
var
|
|
971
|
+
var import_react6 = require("react");
|
|
1059
972
|
var import_material4 = require("@mui/material");
|
|
1060
973
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1061
|
-
var CheckCodeForm = ({ config, onNavigate, onError, searchParams }) => {
|
|
1062
|
-
const [code, setCode] = (0,
|
|
1063
|
-
const [loading, setLoading] = (0,
|
|
1064
|
-
const [errors, setErrors] = (0,
|
|
1065
|
-
const [helperTextCode, setHelperTextCode] = (0,
|
|
1066
|
-
const [email, setEmail] = (0,
|
|
974
|
+
var CheckCodeForm = ({ config, onNavigate, onError, searchParams, crudify: crudify3 }) => {
|
|
975
|
+
const [code, setCode] = (0, import_react6.useState)("");
|
|
976
|
+
const [loading, setLoading] = (0, import_react6.useState)(false);
|
|
977
|
+
const [errors, setErrors] = (0, import_react6.useState)([]);
|
|
978
|
+
const [helperTextCode, setHelperTextCode] = (0, import_react6.useState)(null);
|
|
979
|
+
const [email, setEmail] = (0, import_react6.useState)("");
|
|
1067
980
|
const { t } = useTranslation();
|
|
1068
|
-
|
|
1069
|
-
(0, import_react7.useEffect)(() => {
|
|
981
|
+
(0, import_react6.useEffect)(() => {
|
|
1070
982
|
const emailParam = searchParams?.get("email");
|
|
1071
983
|
if (emailParam) {
|
|
1072
984
|
setEmail(emailParam);
|
|
@@ -1194,6 +1106,87 @@ var CheckCodeForm = ({ config, onNavigate, onError, searchParams }) => {
|
|
|
1194
1106
|
};
|
|
1195
1107
|
var CheckCodeForm_default = CheckCodeForm;
|
|
1196
1108
|
|
|
1109
|
+
// src/components/CrudifyLogin/hooks/useCrudifyLogin.ts
|
|
1110
|
+
var import_react7 = require("react");
|
|
1111
|
+
var import_crudify_browser = __toESM(require("@nocios/crudify-browser"));
|
|
1112
|
+
|
|
1113
|
+
// src/components/CrudifyLogin/utils/cookies.ts
|
|
1114
|
+
var getCookie = (name) => {
|
|
1115
|
+
const match = document.cookie.match(new RegExp("(^|;)\\s*" + name + "=([^;]+)"));
|
|
1116
|
+
return match ? match[2] : null;
|
|
1117
|
+
};
|
|
1118
|
+
|
|
1119
|
+
// src/components/CrudifyLogin/hooks/useCrudifyLogin.ts
|
|
1120
|
+
var useCrudifyLogin = (config, _options = {}) => {
|
|
1121
|
+
const finalConfig = (0, import_react7.useMemo)(() => {
|
|
1122
|
+
const publicApiKey = config.publicApiKey || getCookie("publicApiKey") || null;
|
|
1123
|
+
const rawEnv = config.env || getCookie("environment") || "prod";
|
|
1124
|
+
const env = ["dev", "stg", "prod"].includes(rawEnv) ? rawEnv : "prod";
|
|
1125
|
+
const appName = config.appName || getCookie("appName") || "Crudia";
|
|
1126
|
+
const loginActions = config.loginActions || (() => {
|
|
1127
|
+
try {
|
|
1128
|
+
const cookieValue = getCookie("loginActions");
|
|
1129
|
+
return cookieValue ? cookieValue.split(",").map((action) => action.trim()).filter(Boolean) : [];
|
|
1130
|
+
} catch {
|
|
1131
|
+
return [];
|
|
1132
|
+
}
|
|
1133
|
+
})();
|
|
1134
|
+
return {
|
|
1135
|
+
publicApiKey,
|
|
1136
|
+
env,
|
|
1137
|
+
appName,
|
|
1138
|
+
loginActions
|
|
1139
|
+
};
|
|
1140
|
+
}, [config]);
|
|
1141
|
+
(0, import_react7.useEffect)(() => {
|
|
1142
|
+
console.log("\u{1F527} useCrudifyLogin useEffect triggered:", {
|
|
1143
|
+
publicApiKey: !!finalConfig.publicApiKey,
|
|
1144
|
+
env: finalConfig.env,
|
|
1145
|
+
hasPublicApiKey: !!finalConfig.publicApiKey
|
|
1146
|
+
});
|
|
1147
|
+
if (!finalConfig.publicApiKey) {
|
|
1148
|
+
console.log("\u274C No publicApiKey, skipping crudify initialization");
|
|
1149
|
+
return;
|
|
1150
|
+
}
|
|
1151
|
+
try {
|
|
1152
|
+
console.log("\u2699\uFE0F Configuring crudify with env:", finalConfig.env);
|
|
1153
|
+
import_crudify_browser.default.config(finalConfig.env);
|
|
1154
|
+
console.log("\u{1F680} Initializing crudify with publicApiKey:", finalConfig.publicApiKey.substring(0, 10) + "...");
|
|
1155
|
+
import_crudify_browser.default.init(finalConfig.publicApiKey, "none");
|
|
1156
|
+
console.log("\u2705 Crudify initialization completed");
|
|
1157
|
+
console.log("\u{1F50D} Crudify state after init:", {
|
|
1158
|
+
hasTransaction: typeof import_crudify_browser.default.transaction === "function",
|
|
1159
|
+
hasLogin: typeof import_crudify_browser.default.login === "function",
|
|
1160
|
+
crudifyObject: import_crudify_browser.default
|
|
1161
|
+
});
|
|
1162
|
+
} catch (error) {
|
|
1163
|
+
console.error("\u274C Error initializing crudify:", error);
|
|
1164
|
+
}
|
|
1165
|
+
}, [finalConfig.publicApiKey, finalConfig.env]);
|
|
1166
|
+
const crudifyMethods = (0, import_react7.useMemo)(() => {
|
|
1167
|
+
console.log("\u{1F504} crudifyMethods useMemo triggered:", {
|
|
1168
|
+
publicApiKey: !!finalConfig.publicApiKey,
|
|
1169
|
+
crudifyLogin: typeof import_crudify_browser.default.login,
|
|
1170
|
+
crudifyTransaction: typeof import_crudify_browser.default.transaction
|
|
1171
|
+
});
|
|
1172
|
+
if (!finalConfig.publicApiKey) {
|
|
1173
|
+
console.log("\u274C No publicApiKey, returning null crudifyMethods");
|
|
1174
|
+
return null;
|
|
1175
|
+
}
|
|
1176
|
+
const methods = {
|
|
1177
|
+
login: import_crudify_browser.default.login,
|
|
1178
|
+
transaction: import_crudify_browser.default.transaction
|
|
1179
|
+
};
|
|
1180
|
+
console.log("\u2705 Returning crudifyMethods:", {
|
|
1181
|
+
hasLogin: typeof methods.login === "function",
|
|
1182
|
+
hasTransaction: typeof methods.transaction === "function",
|
|
1183
|
+
methods
|
|
1184
|
+
});
|
|
1185
|
+
return methods;
|
|
1186
|
+
}, [finalConfig.publicApiKey]);
|
|
1187
|
+
return { crudify: crudifyMethods };
|
|
1188
|
+
};
|
|
1189
|
+
|
|
1197
1190
|
// src/components/CrudifyLogin/index.tsx
|
|
1198
1191
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1199
1192
|
var CrudifyLoginInternal = ({
|
|
@@ -1269,6 +1262,7 @@ var CrudifyLoginInternal = ({
|
|
|
1269
1262
|
loginActions: providedConfig?.loginActions
|
|
1270
1263
|
};
|
|
1271
1264
|
}, [providedConfig, autoReadFromCookies]);
|
|
1265
|
+
const { crudify: crudify3 } = useCrudifyLogin(finalConfig);
|
|
1272
1266
|
const handleNavigate = (path) => {
|
|
1273
1267
|
console.log("\u{1F680} INTERNAL handleNavigate called with:", path);
|
|
1274
1268
|
const [basePath, queryString] = path.split("?");
|
|
@@ -1302,7 +1296,9 @@ var CrudifyLoginInternal = ({
|
|
|
1302
1296
|
onNavigate: handleNavigate,
|
|
1303
1297
|
// Navegación interna
|
|
1304
1298
|
onError,
|
|
1305
|
-
redirectUrl
|
|
1299
|
+
redirectUrl,
|
|
1300
|
+
crudify: crudify3
|
|
1301
|
+
// Pasar la instancia compartida de crudify
|
|
1306
1302
|
};
|
|
1307
1303
|
switch (currentScreen) {
|
|
1308
1304
|
case "forgotPassword":
|
package/dist/index.mjs
CHANGED
|
@@ -95,90 +95,9 @@ var useTranslation = () => {
|
|
|
95
95
|
};
|
|
96
96
|
|
|
97
97
|
// src/components/CrudifyLogin/Forms/LoginForm.tsx
|
|
98
|
-
import { useState as useState2, useEffect as
|
|
98
|
+
import { useState as useState2, useEffect as useEffect2, useRef } from "react";
|
|
99
99
|
import { Typography, TextField, Button, Box, CircularProgress, Alert, Link } from "@mui/material";
|
|
100
100
|
|
|
101
|
-
// src/components/CrudifyLogin/hooks/useCrudifyLogin.ts
|
|
102
|
-
import { useMemo as useMemo2, useEffect as useEffect2 } from "react";
|
|
103
|
-
import crudify from "@nocios/crudify-browser";
|
|
104
|
-
|
|
105
|
-
// src/components/CrudifyLogin/utils/cookies.ts
|
|
106
|
-
var getCookie = (name) => {
|
|
107
|
-
const match = document.cookie.match(new RegExp("(^|;)\\s*" + name + "=([^;]+)"));
|
|
108
|
-
return match ? match[2] : null;
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
// src/components/CrudifyLogin/hooks/useCrudifyLogin.ts
|
|
112
|
-
var useCrudifyLogin = (config, _options = {}) => {
|
|
113
|
-
const finalConfig = useMemo2(() => {
|
|
114
|
-
const publicApiKey = config.publicApiKey || getCookie("publicApiKey") || null;
|
|
115
|
-
const rawEnv = config.env || getCookie("environment") || "prod";
|
|
116
|
-
const env = ["dev", "stg", "prod"].includes(rawEnv) ? rawEnv : "prod";
|
|
117
|
-
const appName = config.appName || getCookie("appName") || "Crudia";
|
|
118
|
-
const loginActions = config.loginActions || (() => {
|
|
119
|
-
try {
|
|
120
|
-
const cookieValue = getCookie("loginActions");
|
|
121
|
-
return cookieValue ? cookieValue.split(",").map((action) => action.trim()).filter(Boolean) : [];
|
|
122
|
-
} catch {
|
|
123
|
-
return [];
|
|
124
|
-
}
|
|
125
|
-
})();
|
|
126
|
-
return {
|
|
127
|
-
publicApiKey,
|
|
128
|
-
env,
|
|
129
|
-
appName,
|
|
130
|
-
loginActions
|
|
131
|
-
};
|
|
132
|
-
}, [config]);
|
|
133
|
-
useEffect2(() => {
|
|
134
|
-
console.log("\u{1F527} useCrudifyLogin useEffect triggered:", {
|
|
135
|
-
publicApiKey: !!finalConfig.publicApiKey,
|
|
136
|
-
env: finalConfig.env,
|
|
137
|
-
hasPublicApiKey: !!finalConfig.publicApiKey
|
|
138
|
-
});
|
|
139
|
-
if (!finalConfig.publicApiKey) {
|
|
140
|
-
console.log("\u274C No publicApiKey, skipping crudify initialization");
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
try {
|
|
144
|
-
console.log("\u2699\uFE0F Configuring crudify with env:", finalConfig.env);
|
|
145
|
-
crudify.config(finalConfig.env);
|
|
146
|
-
console.log("\u{1F680} Initializing crudify with publicApiKey:", finalConfig.publicApiKey.substring(0, 10) + "...");
|
|
147
|
-
crudify.init(finalConfig.publicApiKey, "none");
|
|
148
|
-
console.log("\u2705 Crudify initialization completed");
|
|
149
|
-
console.log("\u{1F50D} Crudify state after init:", {
|
|
150
|
-
hasTransaction: typeof crudify.transaction === "function",
|
|
151
|
-
hasLogin: typeof crudify.login === "function",
|
|
152
|
-
crudifyObject: crudify
|
|
153
|
-
});
|
|
154
|
-
} catch (error) {
|
|
155
|
-
console.error("\u274C Error initializing crudify:", error);
|
|
156
|
-
}
|
|
157
|
-
}, [finalConfig.publicApiKey, finalConfig.env]);
|
|
158
|
-
const crudifyMethods = useMemo2(() => {
|
|
159
|
-
console.log("\u{1F504} crudifyMethods useMemo triggered:", {
|
|
160
|
-
publicApiKey: !!finalConfig.publicApiKey,
|
|
161
|
-
crudifyLogin: typeof crudify.login,
|
|
162
|
-
crudifyTransaction: typeof crudify.transaction
|
|
163
|
-
});
|
|
164
|
-
if (!finalConfig.publicApiKey) {
|
|
165
|
-
console.log("\u274C No publicApiKey, returning null crudifyMethods");
|
|
166
|
-
return null;
|
|
167
|
-
}
|
|
168
|
-
const methods = {
|
|
169
|
-
login: crudify.login,
|
|
170
|
-
transaction: crudify.transaction
|
|
171
|
-
};
|
|
172
|
-
console.log("\u2705 Returning crudifyMethods:", {
|
|
173
|
-
hasLogin: typeof methods.login === "function",
|
|
174
|
-
hasTransaction: typeof methods.transaction === "function",
|
|
175
|
-
methods
|
|
176
|
-
});
|
|
177
|
-
return methods;
|
|
178
|
-
}, [finalConfig.publicApiKey]);
|
|
179
|
-
return { crudify: crudifyMethods };
|
|
180
|
-
};
|
|
181
|
-
|
|
182
101
|
// src/components/CrudifyLogin/utils/secureStorage.ts
|
|
183
102
|
import CryptoJS from "crypto-js";
|
|
184
103
|
var SecureStorage = class {
|
|
@@ -290,7 +209,7 @@ var secureLocalStorage = new SecureStorage("localStorage");
|
|
|
290
209
|
|
|
291
210
|
// src/components/CrudifyLogin/Forms/LoginForm.tsx
|
|
292
211
|
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
293
|
-
var LoginForm = ({ config, onNavigate, onLoginSuccess, onError, redirectUrl = "/", searchParams }) => {
|
|
212
|
+
var LoginForm = ({ config, onNavigate, onLoginSuccess, onError, redirectUrl = "/", searchParams, crudify: crudify3 }) => {
|
|
294
213
|
const [username, setUsername] = useState2("");
|
|
295
214
|
const [password, setPassword] = useState2("");
|
|
296
215
|
const [loading, setLoading] = useState2(false);
|
|
@@ -299,10 +218,6 @@ var LoginForm = ({ config, onNavigate, onLoginSuccess, onError, redirectUrl = "/
|
|
|
299
218
|
const [helperTextPassword, setHelperTextPassword] = useState2(null);
|
|
300
219
|
const { t } = useTranslation();
|
|
301
220
|
const usernameInputRef = useRef(null);
|
|
302
|
-
const { crudify: crudifyFromHook } = useCrudifyLogin(config, {
|
|
303
|
-
showErrorNotifications: false,
|
|
304
|
-
showSuccessNotifications: false
|
|
305
|
-
});
|
|
306
221
|
const getRedirectUrl = () => {
|
|
307
222
|
if (searchParams) {
|
|
308
223
|
const redirectParam = searchParams.get("redirect");
|
|
@@ -318,7 +233,7 @@ var LoginForm = ({ config, onNavigate, onLoginSuccess, onError, redirectUrl = "/
|
|
|
318
233
|
}
|
|
319
234
|
return redirectUrl || "/";
|
|
320
235
|
};
|
|
321
|
-
|
|
236
|
+
useEffect2(() => {
|
|
322
237
|
const timer = setTimeout(() => {
|
|
323
238
|
if (usernameInputRef.current) usernameInputRef.current.focus();
|
|
324
239
|
}, 100);
|
|
@@ -355,10 +270,10 @@ var LoginForm = ({ config, onNavigate, onLoginSuccess, onError, redirectUrl = "/
|
|
|
355
270
|
setHelperTextPassword(null);
|
|
356
271
|
setLoading(true);
|
|
357
272
|
try {
|
|
358
|
-
if (!
|
|
273
|
+
if (!crudify3) {
|
|
359
274
|
throw new Error("Crudify not initialized");
|
|
360
275
|
}
|
|
361
|
-
const response = await
|
|
276
|
+
const response = await crudify3.login(username, password);
|
|
362
277
|
setLoading(false);
|
|
363
278
|
if (response.success) {
|
|
364
279
|
secureSessionStorage.setToken(response.data.token);
|
|
@@ -545,7 +460,7 @@ var LoginForm_default = LoginForm;
|
|
|
545
460
|
import { useState as useState3 } from "react";
|
|
546
461
|
import { Typography as Typography2, TextField as TextField2, Button as Button2, Box as Box2, CircularProgress as CircularProgress2, Alert as Alert2, Link as Link2 } from "@mui/material";
|
|
547
462
|
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
548
|
-
var ForgotPasswordForm = ({ config, onNavigate, onError }) => {
|
|
463
|
+
var ForgotPasswordForm = ({ config, onNavigate, onError, crudify: crudify3 }) => {
|
|
549
464
|
const [email, setEmail] = useState3("");
|
|
550
465
|
const [loading, setLoading] = useState3(false);
|
|
551
466
|
const [errors, setErrors] = useState3([]);
|
|
@@ -553,7 +468,6 @@ var ForgotPasswordForm = ({ config, onNavigate, onError }) => {
|
|
|
553
468
|
const [emailSent, setEmailSent] = useState3(false);
|
|
554
469
|
const [codeAlreadyExists, setCodeAlreadyExists] = useState3(false);
|
|
555
470
|
const { t } = useTranslation();
|
|
556
|
-
const { crudify: crudify3 } = useCrudifyLogin(config);
|
|
557
471
|
const validateEmail = (email2) => {
|
|
558
472
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
559
473
|
return emailRegex.test(email2);
|
|
@@ -695,10 +609,10 @@ var ForgotPasswordForm = ({ config, onNavigate, onError }) => {
|
|
|
695
609
|
var ForgotPasswordForm_default = ForgotPasswordForm;
|
|
696
610
|
|
|
697
611
|
// src/components/CrudifyLogin/Forms/ResetPasswordForm.tsx
|
|
698
|
-
import { useState as useState4, useEffect as
|
|
612
|
+
import { useState as useState4, useEffect as useEffect3 } from "react";
|
|
699
613
|
import { Typography as Typography3, TextField as TextField3, Button as Button3, Box as Box3, CircularProgress as CircularProgress3, Alert as Alert3, Link as Link3 } from "@mui/material";
|
|
700
614
|
import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
701
|
-
var ResetPasswordForm = ({ config, onNavigate, onError, searchParams, onResetSuccess }) => {
|
|
615
|
+
var ResetPasswordForm = ({ config, onNavigate, onError, searchParams, onResetSuccess, crudify: crudify3 }) => {
|
|
702
616
|
const [newPassword, setNewPassword] = useState4("");
|
|
703
617
|
const [confirmPassword, setConfirmPassword] = useState4("");
|
|
704
618
|
const [loading, setLoading] = useState4(false);
|
|
@@ -712,8 +626,7 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams, onResetSuc
|
|
|
712
626
|
const [codeValidated, setCodeValidated] = useState4(false);
|
|
713
627
|
const [pendingValidation, setPendingValidation] = useState4(null);
|
|
714
628
|
const { t } = useTranslation();
|
|
715
|
-
|
|
716
|
-
useEffect4(() => {
|
|
629
|
+
useEffect3(() => {
|
|
717
630
|
if (searchParams) {
|
|
718
631
|
const fromCodeVerificationParam = searchParams.get("fromCodeVerification");
|
|
719
632
|
const emailParam = searchParams.get("email");
|
|
@@ -757,7 +670,7 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams, onResetSuc
|
|
|
757
670
|
setValidatingCode(false);
|
|
758
671
|
setTimeout(() => onNavigate?.("/login/forgotPassword"), 3e3);
|
|
759
672
|
}, [searchParams, crudify3, t, onNavigate]);
|
|
760
|
-
|
|
673
|
+
useEffect3(() => {
|
|
761
674
|
console.log("\u{1F504} Pending validation useEffect triggered:", {
|
|
762
675
|
crudify: !!crudify3,
|
|
763
676
|
pendingValidation,
|
|
@@ -1011,18 +924,17 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams, onResetSuc
|
|
|
1011
924
|
var ResetPasswordForm_default = ResetPasswordForm;
|
|
1012
925
|
|
|
1013
926
|
// src/components/CrudifyLogin/Forms/CheckCodeForm.tsx
|
|
1014
|
-
import { useState as useState5, useEffect as
|
|
927
|
+
import { useState as useState5, useEffect as useEffect4 } from "react";
|
|
1015
928
|
import { Typography as Typography4, TextField as TextField4, Button as Button4, Box as Box4, CircularProgress as CircularProgress4, Alert as Alert4, Link as Link4 } from "@mui/material";
|
|
1016
929
|
import { Fragment as Fragment4, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1017
|
-
var CheckCodeForm = ({ config, onNavigate, onError, searchParams }) => {
|
|
930
|
+
var CheckCodeForm = ({ config, onNavigate, onError, searchParams, crudify: crudify3 }) => {
|
|
1018
931
|
const [code, setCode] = useState5("");
|
|
1019
932
|
const [loading, setLoading] = useState5(false);
|
|
1020
933
|
const [errors, setErrors] = useState5([]);
|
|
1021
934
|
const [helperTextCode, setHelperTextCode] = useState5(null);
|
|
1022
935
|
const [email, setEmail] = useState5("");
|
|
1023
936
|
const { t } = useTranslation();
|
|
1024
|
-
|
|
1025
|
-
useEffect5(() => {
|
|
937
|
+
useEffect4(() => {
|
|
1026
938
|
const emailParam = searchParams?.get("email");
|
|
1027
939
|
if (emailParam) {
|
|
1028
940
|
setEmail(emailParam);
|
|
@@ -1150,6 +1062,87 @@ var CheckCodeForm = ({ config, onNavigate, onError, searchParams }) => {
|
|
|
1150
1062
|
};
|
|
1151
1063
|
var CheckCodeForm_default = CheckCodeForm;
|
|
1152
1064
|
|
|
1065
|
+
// src/components/CrudifyLogin/hooks/useCrudifyLogin.ts
|
|
1066
|
+
import { useMemo as useMemo2, useEffect as useEffect5 } from "react";
|
|
1067
|
+
import crudify from "@nocios/crudify-browser";
|
|
1068
|
+
|
|
1069
|
+
// src/components/CrudifyLogin/utils/cookies.ts
|
|
1070
|
+
var getCookie = (name) => {
|
|
1071
|
+
const match = document.cookie.match(new RegExp("(^|;)\\s*" + name + "=([^;]+)"));
|
|
1072
|
+
return match ? match[2] : null;
|
|
1073
|
+
};
|
|
1074
|
+
|
|
1075
|
+
// src/components/CrudifyLogin/hooks/useCrudifyLogin.ts
|
|
1076
|
+
var useCrudifyLogin = (config, _options = {}) => {
|
|
1077
|
+
const finalConfig = useMemo2(() => {
|
|
1078
|
+
const publicApiKey = config.publicApiKey || getCookie("publicApiKey") || null;
|
|
1079
|
+
const rawEnv = config.env || getCookie("environment") || "prod";
|
|
1080
|
+
const env = ["dev", "stg", "prod"].includes(rawEnv) ? rawEnv : "prod";
|
|
1081
|
+
const appName = config.appName || getCookie("appName") || "Crudia";
|
|
1082
|
+
const loginActions = config.loginActions || (() => {
|
|
1083
|
+
try {
|
|
1084
|
+
const cookieValue = getCookie("loginActions");
|
|
1085
|
+
return cookieValue ? cookieValue.split(",").map((action) => action.trim()).filter(Boolean) : [];
|
|
1086
|
+
} catch {
|
|
1087
|
+
return [];
|
|
1088
|
+
}
|
|
1089
|
+
})();
|
|
1090
|
+
return {
|
|
1091
|
+
publicApiKey,
|
|
1092
|
+
env,
|
|
1093
|
+
appName,
|
|
1094
|
+
loginActions
|
|
1095
|
+
};
|
|
1096
|
+
}, [config]);
|
|
1097
|
+
useEffect5(() => {
|
|
1098
|
+
console.log("\u{1F527} useCrudifyLogin useEffect triggered:", {
|
|
1099
|
+
publicApiKey: !!finalConfig.publicApiKey,
|
|
1100
|
+
env: finalConfig.env,
|
|
1101
|
+
hasPublicApiKey: !!finalConfig.publicApiKey
|
|
1102
|
+
});
|
|
1103
|
+
if (!finalConfig.publicApiKey) {
|
|
1104
|
+
console.log("\u274C No publicApiKey, skipping crudify initialization");
|
|
1105
|
+
return;
|
|
1106
|
+
}
|
|
1107
|
+
try {
|
|
1108
|
+
console.log("\u2699\uFE0F Configuring crudify with env:", finalConfig.env);
|
|
1109
|
+
crudify.config(finalConfig.env);
|
|
1110
|
+
console.log("\u{1F680} Initializing crudify with publicApiKey:", finalConfig.publicApiKey.substring(0, 10) + "...");
|
|
1111
|
+
crudify.init(finalConfig.publicApiKey, "none");
|
|
1112
|
+
console.log("\u2705 Crudify initialization completed");
|
|
1113
|
+
console.log("\u{1F50D} Crudify state after init:", {
|
|
1114
|
+
hasTransaction: typeof crudify.transaction === "function",
|
|
1115
|
+
hasLogin: typeof crudify.login === "function",
|
|
1116
|
+
crudifyObject: crudify
|
|
1117
|
+
});
|
|
1118
|
+
} catch (error) {
|
|
1119
|
+
console.error("\u274C Error initializing crudify:", error);
|
|
1120
|
+
}
|
|
1121
|
+
}, [finalConfig.publicApiKey, finalConfig.env]);
|
|
1122
|
+
const crudifyMethods = useMemo2(() => {
|
|
1123
|
+
console.log("\u{1F504} crudifyMethods useMemo triggered:", {
|
|
1124
|
+
publicApiKey: !!finalConfig.publicApiKey,
|
|
1125
|
+
crudifyLogin: typeof crudify.login,
|
|
1126
|
+
crudifyTransaction: typeof crudify.transaction
|
|
1127
|
+
});
|
|
1128
|
+
if (!finalConfig.publicApiKey) {
|
|
1129
|
+
console.log("\u274C No publicApiKey, returning null crudifyMethods");
|
|
1130
|
+
return null;
|
|
1131
|
+
}
|
|
1132
|
+
const methods = {
|
|
1133
|
+
login: crudify.login,
|
|
1134
|
+
transaction: crudify.transaction
|
|
1135
|
+
};
|
|
1136
|
+
console.log("\u2705 Returning crudifyMethods:", {
|
|
1137
|
+
hasLogin: typeof methods.login === "function",
|
|
1138
|
+
hasTransaction: typeof methods.transaction === "function",
|
|
1139
|
+
methods
|
|
1140
|
+
});
|
|
1141
|
+
return methods;
|
|
1142
|
+
}, [finalConfig.publicApiKey]);
|
|
1143
|
+
return { crudify: crudifyMethods };
|
|
1144
|
+
};
|
|
1145
|
+
|
|
1153
1146
|
// src/components/CrudifyLogin/index.tsx
|
|
1154
1147
|
import { Fragment as Fragment5, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1155
1148
|
var CrudifyLoginInternal = ({
|
|
@@ -1225,6 +1218,7 @@ var CrudifyLoginInternal = ({
|
|
|
1225
1218
|
loginActions: providedConfig?.loginActions
|
|
1226
1219
|
};
|
|
1227
1220
|
}, [providedConfig, autoReadFromCookies]);
|
|
1221
|
+
const { crudify: crudify3 } = useCrudifyLogin(finalConfig);
|
|
1228
1222
|
const handleNavigate = (path) => {
|
|
1229
1223
|
console.log("\u{1F680} INTERNAL handleNavigate called with:", path);
|
|
1230
1224
|
const [basePath, queryString] = path.split("?");
|
|
@@ -1258,7 +1252,9 @@ var CrudifyLoginInternal = ({
|
|
|
1258
1252
|
onNavigate: handleNavigate,
|
|
1259
1253
|
// Navegación interna
|
|
1260
1254
|
onError,
|
|
1261
|
-
redirectUrl
|
|
1255
|
+
redirectUrl,
|
|
1256
|
+
crudify: crudify3
|
|
1257
|
+
// Pasar la instancia compartida de crudify
|
|
1262
1258
|
};
|
|
1263
1259
|
switch (currentScreen) {
|
|
1264
1260
|
case "forgotPassword":
|