@nocios/crudify-ui 1.0.55 → 1.0.56
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 +77 -12
- package/dist/index.mjs +84 -19
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -47,7 +47,7 @@ var import_crudify_browser3 = __toESM(require("@nocios/crudify-browser"));
|
|
|
47
47
|
__reExport(index_exports, require("@nocios/crudify-browser"), module.exports);
|
|
48
48
|
|
|
49
49
|
// src/components/CrudifyLogin/index.tsx
|
|
50
|
-
var import_react8 = require("react");
|
|
50
|
+
var import_react8 = __toESM(require("react"));
|
|
51
51
|
var import_material5 = require("@mui/material");
|
|
52
52
|
|
|
53
53
|
// src/components/CrudifyLogin/context/I18nProvider.tsx
|
|
@@ -632,21 +632,27 @@ var ForgotPasswordForm = ({ config, onNavigate, onError }) => {
|
|
|
632
632
|
onNavigate?.("/login");
|
|
633
633
|
};
|
|
634
634
|
const handleGoToCheckCode = () => {
|
|
635
|
+
console.log("\u{1F680} handleGoToCheckCode called:", { email, emailSent, codeAlreadyExists });
|
|
635
636
|
if (emailSent || codeAlreadyExists) {
|
|
637
|
+
console.log("\u2705 Navigating from success state");
|
|
636
638
|
onNavigate?.(`/login/checkCode?email=${encodeURIComponent(email)}`);
|
|
637
639
|
return;
|
|
638
640
|
}
|
|
639
641
|
if (!email) {
|
|
642
|
+
console.log("\u274C Email required");
|
|
640
643
|
setHelperTextEmail(t("forgotPassword.emailRequired"));
|
|
641
644
|
return;
|
|
642
645
|
}
|
|
643
646
|
if (!validateEmail(email)) {
|
|
647
|
+
console.log("\u274C Invalid email");
|
|
644
648
|
setHelperTextEmail(t("forgotPassword.invalidEmail"));
|
|
645
649
|
return;
|
|
646
650
|
}
|
|
651
|
+
console.log("\u2705 Navigating with valid email");
|
|
647
652
|
onNavigate?.(`/login/checkCode?email=${encodeURIComponent(email)}`);
|
|
648
653
|
};
|
|
649
654
|
if (emailSent || codeAlreadyExists) {
|
|
655
|
+
console.log("\u{1F4E7} Rendering SUCCESS state:", { emailSent, codeAlreadyExists });
|
|
650
656
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_material2.Box, { sx: { width: "100%", display: "flex", flexDirection: "column", gap: 2, textAlign: "center" }, children: [
|
|
651
657
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_material2.Box, { sx: { mb: 2 }, children: [
|
|
652
658
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material2.Typography, { variant: "h5", component: "h1", sx: { mb: 1, fontWeight: 600 }, children: codeAlreadyExists ? t("forgotPassword.codeAlreadyExistsMessage") : t("forgotPassword.emailSentMessage") }),
|
|
@@ -656,6 +662,7 @@ var ForgotPasswordForm = ({ config, onNavigate, onError }) => {
|
|
|
656
662
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material2.Box, { sx: { display: "flex", justifyContent: "center", alignItems: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material2.Link, { sx: { cursor: "pointer" }, onClick: handleBack, variant: "body2", color: "secondary", children: t("common.back") }) })
|
|
657
663
|
] }) });
|
|
658
664
|
}
|
|
665
|
+
console.log("\u{1F4DD} Rendering FORM state");
|
|
659
666
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
660
667
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_material2.Box, { component: "form", noValidate: true, sx: { width: "100%", display: "flex", flexDirection: "column", gap: 2 }, children: [
|
|
661
668
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_material2.Box, { sx: { mb: 2 }, children: [
|
|
@@ -707,7 +714,7 @@ var ForgotPasswordForm_default = ForgotPasswordForm;
|
|
|
707
714
|
var import_react6 = require("react");
|
|
708
715
|
var import_material3 = require("@mui/material");
|
|
709
716
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
710
|
-
var ResetPasswordForm = ({ config, onNavigate, onError, searchParams }) => {
|
|
717
|
+
var ResetPasswordForm = ({ config, onNavigate, onError, searchParams, onResetSuccess }) => {
|
|
711
718
|
const [newPassword, setNewPassword] = (0, import_react6.useState)("");
|
|
712
719
|
const [confirmPassword, setConfirmPassword] = (0, import_react6.useState)("");
|
|
713
720
|
const [loading, setLoading] = (0, import_react6.useState)(false);
|
|
@@ -724,6 +731,7 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams }) => {
|
|
|
724
731
|
(0, import_react6.useEffect)(() => {
|
|
725
732
|
const validateCode = async (emailToValidate, codeToValidate) => {
|
|
726
733
|
if (!crudify3) return;
|
|
734
|
+
console.log("\u{1F50D} Validating reset code:", { emailToValidate, codeToValidate });
|
|
727
735
|
try {
|
|
728
736
|
const data = [
|
|
729
737
|
{
|
|
@@ -731,10 +739,14 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams }) => {
|
|
|
731
739
|
data: { email: emailToValidate, codePassword: codeToValidate }
|
|
732
740
|
}
|
|
733
741
|
];
|
|
742
|
+
console.log("\u{1F4E4} Sending validation request:", data);
|
|
734
743
|
const response = await crudify3.transaction(data);
|
|
744
|
+
console.log("\u{1F4E5} Validation response:", response);
|
|
735
745
|
if (response.success) {
|
|
746
|
+
console.log("\u2705 Code validation successful");
|
|
736
747
|
setCodeValidated(true);
|
|
737
748
|
} else {
|
|
749
|
+
console.log("\u274C Code validation failed:", response);
|
|
738
750
|
if (response.data?.response?.status === "TOO_MANY_REQUESTS") {
|
|
739
751
|
setErrors([t("errors.auth.TOO_MANY_REQUESTS")]);
|
|
740
752
|
} else {
|
|
@@ -782,6 +794,7 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams }) => {
|
|
|
782
794
|
const decodedLink = decodeURIComponent(linkParam);
|
|
783
795
|
const [linkCode, linkEmail] = decodedLink.split("/");
|
|
784
796
|
if (linkCode && linkEmail && linkCode.length === 6) {
|
|
797
|
+
console.log("\u{1F517} Reset link detected:", { linkCode, linkEmail });
|
|
785
798
|
setCode(linkCode);
|
|
786
799
|
setEmail(linkEmail);
|
|
787
800
|
setFromCodeVerification(false);
|
|
@@ -789,6 +802,7 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams }) => {
|
|
|
789
802
|
return;
|
|
790
803
|
}
|
|
791
804
|
} catch (error) {
|
|
805
|
+
console.error("Failed to parse reset link:", error);
|
|
792
806
|
}
|
|
793
807
|
}
|
|
794
808
|
if (emailParam && codeParam) {
|
|
@@ -845,9 +859,7 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams }) => {
|
|
|
845
859
|
if (response.success) {
|
|
846
860
|
setErrors([]);
|
|
847
861
|
setTimeout(() => {
|
|
848
|
-
|
|
849
|
-
const loginPath = redirectParam ? `/login?redirect=${redirectParam}` : "/login";
|
|
850
|
-
onNavigate?.(loginPath + "?resetSuccess=true");
|
|
862
|
+
onResetSuccess?.();
|
|
851
863
|
}, 1e3);
|
|
852
864
|
} else {
|
|
853
865
|
const errorMessages = [];
|
|
@@ -1142,6 +1154,25 @@ var CrudifyLoginInternal = ({
|
|
|
1142
1154
|
const { t } = useTranslation();
|
|
1143
1155
|
const [currentScreen, setCurrentScreen] = (0, import_react8.useState)(initialScreen);
|
|
1144
1156
|
const [searchParams, setSearchParams] = (0, import_react8.useState)();
|
|
1157
|
+
console.log("\u{1F504} CrudifyLoginInternal RENDER:", { currentScreen, initialScreen });
|
|
1158
|
+
import_react8.default.useEffect(() => {
|
|
1159
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
1160
|
+
if (initialScreen === "checkCode") {
|
|
1161
|
+
const email = urlParams.get("email");
|
|
1162
|
+
const code = urlParams.get("code");
|
|
1163
|
+
console.log("\u{1F517} CheckCode link detected:", { email, code });
|
|
1164
|
+
if (email) {
|
|
1165
|
+
setSearchParams(urlParams);
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
if (initialScreen === "resetPassword") {
|
|
1169
|
+
const link = urlParams.get("link");
|
|
1170
|
+
console.log("\u{1F517} ResetPassword link detected:", { link });
|
|
1171
|
+
if (link) {
|
|
1172
|
+
setSearchParams(urlParams);
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
}, [initialScreen]);
|
|
1145
1176
|
const finalConfig = (0, import_react8.useMemo)(() => {
|
|
1146
1177
|
let cookieConfig = {};
|
|
1147
1178
|
if (autoReadFromCookies) {
|
|
@@ -1185,39 +1216,73 @@ var CrudifyLoginInternal = ({
|
|
|
1185
1216
|
};
|
|
1186
1217
|
}, [providedConfig, autoReadFromCookies]);
|
|
1187
1218
|
const handleNavigate = (path) => {
|
|
1219
|
+
console.log("\u{1F680} INTERNAL handleNavigate called with:", path);
|
|
1188
1220
|
const [basePath, queryString] = path.split("?");
|
|
1189
1221
|
if (queryString) {
|
|
1190
1222
|
setSearchParams(new URLSearchParams(queryString));
|
|
1191
1223
|
} else {
|
|
1192
1224
|
setSearchParams(void 0);
|
|
1193
1225
|
}
|
|
1226
|
+
let newScreen = "login";
|
|
1194
1227
|
if (basePath.includes("/forgotPassword")) {
|
|
1195
|
-
|
|
1228
|
+
newScreen = "forgotPassword";
|
|
1196
1229
|
} else if (basePath.includes("/checkCode")) {
|
|
1197
|
-
|
|
1230
|
+
newScreen = "checkCode";
|
|
1198
1231
|
} else if (basePath.includes("/resetPassword")) {
|
|
1199
|
-
|
|
1232
|
+
newScreen = "resetPassword";
|
|
1200
1233
|
} else {
|
|
1201
|
-
|
|
1234
|
+
newScreen = "login";
|
|
1202
1235
|
}
|
|
1236
|
+
console.log("\u{1F3AF} INTERNAL Setting currentScreen from", currentScreen, "to", newScreen);
|
|
1237
|
+
setCurrentScreen(newScreen);
|
|
1238
|
+
console.log("\u{1F512} All navigation handled internally - no external calls");
|
|
1239
|
+
};
|
|
1240
|
+
const notifyExternal = (path, reason) => {
|
|
1241
|
+
console.log(`\u{1F4E2} Notifying external: ${reason} - ${path}`);
|
|
1203
1242
|
onNavigate?.(path);
|
|
1204
1243
|
};
|
|
1205
1244
|
const renderCurrentForm = () => {
|
|
1245
|
+
console.log("\u{1F3A8} renderCurrentForm for screen:", currentScreen);
|
|
1206
1246
|
const commonProps = {
|
|
1207
1247
|
config: finalConfig,
|
|
1208
1248
|
onNavigate: handleNavigate,
|
|
1249
|
+
// Navegación interna
|
|
1209
1250
|
onError,
|
|
1210
1251
|
redirectUrl
|
|
1211
1252
|
};
|
|
1212
1253
|
switch (currentScreen) {
|
|
1213
1254
|
case "forgotPassword":
|
|
1255
|
+
console.log("\u{1F4CB} Rendering ForgotPasswordForm");
|
|
1214
1256
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ForgotPasswordForm_default, { ...commonProps });
|
|
1215
1257
|
case "checkCode":
|
|
1216
|
-
|
|
1258
|
+
console.log("\u{1F522} Rendering CheckCodeForm");
|
|
1259
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CheckCodeForm_default, { ...commonProps, searchParams });
|
|
1217
1260
|
case "resetPassword":
|
|
1218
|
-
|
|
1261
|
+
console.log("\u{1F510} Rendering ResetPasswordForm");
|
|
1262
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1263
|
+
ResetPasswordForm_default,
|
|
1264
|
+
{
|
|
1265
|
+
...commonProps,
|
|
1266
|
+
searchParams,
|
|
1267
|
+
onResetSuccess: () => {
|
|
1268
|
+
notifyExternal(redirectUrl, "Password reset successful");
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
);
|
|
1219
1272
|
default:
|
|
1220
|
-
|
|
1273
|
+
console.log("\u{1F511} Rendering LoginForm");
|
|
1274
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1275
|
+
LoginForm_default,
|
|
1276
|
+
{
|
|
1277
|
+
...commonProps,
|
|
1278
|
+
onLoginSuccess: (result) => {
|
|
1279
|
+
if (onLoginSuccess) {
|
|
1280
|
+
onLoginSuccess(result);
|
|
1281
|
+
}
|
|
1282
|
+
notifyExternal(redirectUrl, "Login successful");
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
);
|
|
1221
1286
|
}
|
|
1222
1287
|
};
|
|
1223
1288
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { default as default2 } from "@nocios/crudify-browser";
|
|
|
3
3
|
export * from "@nocios/crudify-browser";
|
|
4
4
|
|
|
5
5
|
// src/components/CrudifyLogin/index.tsx
|
|
6
|
-
import { useState as useState6, useMemo as useMemo3 } from "react";
|
|
6
|
+
import React2, { useState as useState6, useMemo as useMemo3 } from "react";
|
|
7
7
|
import { Box as Box5, Typography as Typography5 } from "@mui/material";
|
|
8
8
|
|
|
9
9
|
// src/components/CrudifyLogin/context/I18nProvider.tsx
|
|
@@ -588,21 +588,27 @@ var ForgotPasswordForm = ({ config, onNavigate, onError }) => {
|
|
|
588
588
|
onNavigate?.("/login");
|
|
589
589
|
};
|
|
590
590
|
const handleGoToCheckCode = () => {
|
|
591
|
+
console.log("\u{1F680} handleGoToCheckCode called:", { email, emailSent, codeAlreadyExists });
|
|
591
592
|
if (emailSent || codeAlreadyExists) {
|
|
593
|
+
console.log("\u2705 Navigating from success state");
|
|
592
594
|
onNavigate?.(`/login/checkCode?email=${encodeURIComponent(email)}`);
|
|
593
595
|
return;
|
|
594
596
|
}
|
|
595
597
|
if (!email) {
|
|
598
|
+
console.log("\u274C Email required");
|
|
596
599
|
setHelperTextEmail(t("forgotPassword.emailRequired"));
|
|
597
600
|
return;
|
|
598
601
|
}
|
|
599
602
|
if (!validateEmail(email)) {
|
|
603
|
+
console.log("\u274C Invalid email");
|
|
600
604
|
setHelperTextEmail(t("forgotPassword.invalidEmail"));
|
|
601
605
|
return;
|
|
602
606
|
}
|
|
607
|
+
console.log("\u2705 Navigating with valid email");
|
|
603
608
|
onNavigate?.(`/login/checkCode?email=${encodeURIComponent(email)}`);
|
|
604
609
|
};
|
|
605
610
|
if (emailSent || codeAlreadyExists) {
|
|
611
|
+
console.log("\u{1F4E7} Rendering SUCCESS state:", { emailSent, codeAlreadyExists });
|
|
606
612
|
return /* @__PURE__ */ jsx3(Fragment2, { children: /* @__PURE__ */ jsxs2(Box2, { sx: { width: "100%", display: "flex", flexDirection: "column", gap: 2, textAlign: "center" }, children: [
|
|
607
613
|
/* @__PURE__ */ jsxs2(Box2, { sx: { mb: 2 }, children: [
|
|
608
614
|
/* @__PURE__ */ jsx3(Typography2, { variant: "h5", component: "h1", sx: { mb: 1, fontWeight: 600 }, children: codeAlreadyExists ? t("forgotPassword.codeAlreadyExistsMessage") : t("forgotPassword.emailSentMessage") }),
|
|
@@ -612,6 +618,7 @@ var ForgotPasswordForm = ({ config, onNavigate, onError }) => {
|
|
|
612
618
|
/* @__PURE__ */ jsx3(Box2, { sx: { display: "flex", justifyContent: "center", alignItems: "center" }, children: /* @__PURE__ */ jsx3(Link2, { sx: { cursor: "pointer" }, onClick: handleBack, variant: "body2", color: "secondary", children: t("common.back") }) })
|
|
613
619
|
] }) });
|
|
614
620
|
}
|
|
621
|
+
console.log("\u{1F4DD} Rendering FORM state");
|
|
615
622
|
return /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
616
623
|
/* @__PURE__ */ jsxs2(Box2, { component: "form", noValidate: true, sx: { width: "100%", display: "flex", flexDirection: "column", gap: 2 }, children: [
|
|
617
624
|
/* @__PURE__ */ jsxs2(Box2, { sx: { mb: 2 }, children: [
|
|
@@ -660,10 +667,10 @@ var ForgotPasswordForm = ({ config, onNavigate, onError }) => {
|
|
|
660
667
|
var ForgotPasswordForm_default = ForgotPasswordForm;
|
|
661
668
|
|
|
662
669
|
// src/components/CrudifyLogin/Forms/ResetPasswordForm.tsx
|
|
663
|
-
import { useState as useState4, useEffect as
|
|
670
|
+
import { useState as useState4, useEffect as useEffect4 } from "react";
|
|
664
671
|
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";
|
|
665
672
|
import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
666
|
-
var ResetPasswordForm = ({ config, onNavigate, onError, searchParams }) => {
|
|
673
|
+
var ResetPasswordForm = ({ config, onNavigate, onError, searchParams, onResetSuccess }) => {
|
|
667
674
|
const [newPassword, setNewPassword] = useState4("");
|
|
668
675
|
const [confirmPassword, setConfirmPassword] = useState4("");
|
|
669
676
|
const [loading, setLoading] = useState4(false);
|
|
@@ -677,9 +684,10 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams }) => {
|
|
|
677
684
|
const [codeValidated, setCodeValidated] = useState4(false);
|
|
678
685
|
const { t } = useTranslation();
|
|
679
686
|
const { crudify: crudify3 } = useCrudifyLogin(config);
|
|
680
|
-
|
|
687
|
+
useEffect4(() => {
|
|
681
688
|
const validateCode = async (emailToValidate, codeToValidate) => {
|
|
682
689
|
if (!crudify3) return;
|
|
690
|
+
console.log("\u{1F50D} Validating reset code:", { emailToValidate, codeToValidate });
|
|
683
691
|
try {
|
|
684
692
|
const data = [
|
|
685
693
|
{
|
|
@@ -687,10 +695,14 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams }) => {
|
|
|
687
695
|
data: { email: emailToValidate, codePassword: codeToValidate }
|
|
688
696
|
}
|
|
689
697
|
];
|
|
698
|
+
console.log("\u{1F4E4} Sending validation request:", data);
|
|
690
699
|
const response = await crudify3.transaction(data);
|
|
700
|
+
console.log("\u{1F4E5} Validation response:", response);
|
|
691
701
|
if (response.success) {
|
|
702
|
+
console.log("\u2705 Code validation successful");
|
|
692
703
|
setCodeValidated(true);
|
|
693
704
|
} else {
|
|
705
|
+
console.log("\u274C Code validation failed:", response);
|
|
694
706
|
if (response.data?.response?.status === "TOO_MANY_REQUESTS") {
|
|
695
707
|
setErrors([t("errors.auth.TOO_MANY_REQUESTS")]);
|
|
696
708
|
} else {
|
|
@@ -738,6 +750,7 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams }) => {
|
|
|
738
750
|
const decodedLink = decodeURIComponent(linkParam);
|
|
739
751
|
const [linkCode, linkEmail] = decodedLink.split("/");
|
|
740
752
|
if (linkCode && linkEmail && linkCode.length === 6) {
|
|
753
|
+
console.log("\u{1F517} Reset link detected:", { linkCode, linkEmail });
|
|
741
754
|
setCode(linkCode);
|
|
742
755
|
setEmail(linkEmail);
|
|
743
756
|
setFromCodeVerification(false);
|
|
@@ -745,6 +758,7 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams }) => {
|
|
|
745
758
|
return;
|
|
746
759
|
}
|
|
747
760
|
} catch (error) {
|
|
761
|
+
console.error("Failed to parse reset link:", error);
|
|
748
762
|
}
|
|
749
763
|
}
|
|
750
764
|
if (emailParam && codeParam) {
|
|
@@ -801,9 +815,7 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams }) => {
|
|
|
801
815
|
if (response.success) {
|
|
802
816
|
setErrors([]);
|
|
803
817
|
setTimeout(() => {
|
|
804
|
-
|
|
805
|
-
const loginPath = redirectParam ? `/login?redirect=${redirectParam}` : "/login";
|
|
806
|
-
onNavigate?.(loginPath + "?resetSuccess=true");
|
|
818
|
+
onResetSuccess?.();
|
|
807
819
|
}, 1e3);
|
|
808
820
|
} else {
|
|
809
821
|
const errorMessages = [];
|
|
@@ -945,7 +957,7 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams }) => {
|
|
|
945
957
|
var ResetPasswordForm_default = ResetPasswordForm;
|
|
946
958
|
|
|
947
959
|
// src/components/CrudifyLogin/Forms/CheckCodeForm.tsx
|
|
948
|
-
import { useState as useState5, useEffect as
|
|
960
|
+
import { useState as useState5, useEffect as useEffect5 } from "react";
|
|
949
961
|
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";
|
|
950
962
|
import { Fragment as Fragment4, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
951
963
|
var CheckCodeForm = ({ config, onNavigate, onError, searchParams }) => {
|
|
@@ -956,7 +968,7 @@ var CheckCodeForm = ({ config, onNavigate, onError, searchParams }) => {
|
|
|
956
968
|
const [email, setEmail] = useState5("");
|
|
957
969
|
const { t } = useTranslation();
|
|
958
970
|
const { crudify: crudify3 } = useCrudifyLogin(config);
|
|
959
|
-
|
|
971
|
+
useEffect5(() => {
|
|
960
972
|
const emailParam = searchParams?.get("email");
|
|
961
973
|
if (emailParam) {
|
|
962
974
|
setEmail(emailParam);
|
|
@@ -1098,6 +1110,25 @@ var CrudifyLoginInternal = ({
|
|
|
1098
1110
|
const { t } = useTranslation();
|
|
1099
1111
|
const [currentScreen, setCurrentScreen] = useState6(initialScreen);
|
|
1100
1112
|
const [searchParams, setSearchParams] = useState6();
|
|
1113
|
+
console.log("\u{1F504} CrudifyLoginInternal RENDER:", { currentScreen, initialScreen });
|
|
1114
|
+
React2.useEffect(() => {
|
|
1115
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
1116
|
+
if (initialScreen === "checkCode") {
|
|
1117
|
+
const email = urlParams.get("email");
|
|
1118
|
+
const code = urlParams.get("code");
|
|
1119
|
+
console.log("\u{1F517} CheckCode link detected:", { email, code });
|
|
1120
|
+
if (email) {
|
|
1121
|
+
setSearchParams(urlParams);
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
if (initialScreen === "resetPassword") {
|
|
1125
|
+
const link = urlParams.get("link");
|
|
1126
|
+
console.log("\u{1F517} ResetPassword link detected:", { link });
|
|
1127
|
+
if (link) {
|
|
1128
|
+
setSearchParams(urlParams);
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
}, [initialScreen]);
|
|
1101
1132
|
const finalConfig = useMemo3(() => {
|
|
1102
1133
|
let cookieConfig = {};
|
|
1103
1134
|
if (autoReadFromCookies) {
|
|
@@ -1141,39 +1172,73 @@ var CrudifyLoginInternal = ({
|
|
|
1141
1172
|
};
|
|
1142
1173
|
}, [providedConfig, autoReadFromCookies]);
|
|
1143
1174
|
const handleNavigate = (path) => {
|
|
1175
|
+
console.log("\u{1F680} INTERNAL handleNavigate called with:", path);
|
|
1144
1176
|
const [basePath, queryString] = path.split("?");
|
|
1145
1177
|
if (queryString) {
|
|
1146
1178
|
setSearchParams(new URLSearchParams(queryString));
|
|
1147
1179
|
} else {
|
|
1148
1180
|
setSearchParams(void 0);
|
|
1149
1181
|
}
|
|
1182
|
+
let newScreen = "login";
|
|
1150
1183
|
if (basePath.includes("/forgotPassword")) {
|
|
1151
|
-
|
|
1184
|
+
newScreen = "forgotPassword";
|
|
1152
1185
|
} else if (basePath.includes("/checkCode")) {
|
|
1153
|
-
|
|
1186
|
+
newScreen = "checkCode";
|
|
1154
1187
|
} else if (basePath.includes("/resetPassword")) {
|
|
1155
|
-
|
|
1188
|
+
newScreen = "resetPassword";
|
|
1156
1189
|
} else {
|
|
1157
|
-
|
|
1190
|
+
newScreen = "login";
|
|
1158
1191
|
}
|
|
1192
|
+
console.log("\u{1F3AF} INTERNAL Setting currentScreen from", currentScreen, "to", newScreen);
|
|
1193
|
+
setCurrentScreen(newScreen);
|
|
1194
|
+
console.log("\u{1F512} All navigation handled internally - no external calls");
|
|
1195
|
+
};
|
|
1196
|
+
const notifyExternal = (path, reason) => {
|
|
1197
|
+
console.log(`\u{1F4E2} Notifying external: ${reason} - ${path}`);
|
|
1159
1198
|
onNavigate?.(path);
|
|
1160
1199
|
};
|
|
1161
1200
|
const renderCurrentForm = () => {
|
|
1201
|
+
console.log("\u{1F3A8} renderCurrentForm for screen:", currentScreen);
|
|
1162
1202
|
const commonProps = {
|
|
1163
1203
|
config: finalConfig,
|
|
1164
1204
|
onNavigate: handleNavigate,
|
|
1205
|
+
// Navegación interna
|
|
1165
1206
|
onError,
|
|
1166
1207
|
redirectUrl
|
|
1167
1208
|
};
|
|
1168
1209
|
switch (currentScreen) {
|
|
1169
1210
|
case "forgotPassword":
|
|
1211
|
+
console.log("\u{1F4CB} Rendering ForgotPasswordForm");
|
|
1170
1212
|
return /* @__PURE__ */ jsx6(ForgotPasswordForm_default, { ...commonProps });
|
|
1171
1213
|
case "checkCode":
|
|
1172
|
-
|
|
1214
|
+
console.log("\u{1F522} Rendering CheckCodeForm");
|
|
1215
|
+
return /* @__PURE__ */ jsx6(CheckCodeForm_default, { ...commonProps, searchParams });
|
|
1173
1216
|
case "resetPassword":
|
|
1174
|
-
|
|
1217
|
+
console.log("\u{1F510} Rendering ResetPasswordForm");
|
|
1218
|
+
return /* @__PURE__ */ jsx6(
|
|
1219
|
+
ResetPasswordForm_default,
|
|
1220
|
+
{
|
|
1221
|
+
...commonProps,
|
|
1222
|
+
searchParams,
|
|
1223
|
+
onResetSuccess: () => {
|
|
1224
|
+
notifyExternal(redirectUrl, "Password reset successful");
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
);
|
|
1175
1228
|
default:
|
|
1176
|
-
|
|
1229
|
+
console.log("\u{1F511} Rendering LoginForm");
|
|
1230
|
+
return /* @__PURE__ */ jsx6(
|
|
1231
|
+
LoginForm_default,
|
|
1232
|
+
{
|
|
1233
|
+
...commonProps,
|
|
1234
|
+
onLoginSuccess: (result) => {
|
|
1235
|
+
if (onLoginSuccess) {
|
|
1236
|
+
onLoginSuccess(result);
|
|
1237
|
+
}
|
|
1238
|
+
notifyExternal(redirectUrl, "Login successful");
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
);
|
|
1177
1242
|
}
|
|
1178
1243
|
};
|
|
1179
1244
|
return /* @__PURE__ */ jsxs5(Fragment5, { children: [
|
|
@@ -1229,7 +1294,7 @@ var CrudifyLogin = ({
|
|
|
1229
1294
|
var CrudifyLogin_default = CrudifyLogin;
|
|
1230
1295
|
|
|
1231
1296
|
// src/hooks/useUserProfile.ts
|
|
1232
|
-
import { useState as useState7, useEffect as
|
|
1297
|
+
import { useState as useState7, useEffect as useEffect6, useCallback, useRef as useRef2 } from "react";
|
|
1233
1298
|
import crudify2 from "@nocios/crudify-browser";
|
|
1234
1299
|
|
|
1235
1300
|
// src/utils/jwtUtils.ts
|
|
@@ -1349,12 +1414,12 @@ var useUserProfile = (options = {}) => {
|
|
|
1349
1414
|
}
|
|
1350
1415
|
}
|
|
1351
1416
|
}, [retryOnError, maxRetries]);
|
|
1352
|
-
|
|
1417
|
+
useEffect6(() => {
|
|
1353
1418
|
if (autoFetch) {
|
|
1354
1419
|
refreshProfile();
|
|
1355
1420
|
}
|
|
1356
1421
|
}, [autoFetch, refreshProfile]);
|
|
1357
|
-
|
|
1422
|
+
useEffect6(() => {
|
|
1358
1423
|
mountedRef.current = true;
|
|
1359
1424
|
return () => {
|
|
1360
1425
|
mountedRef.current = false;
|