@nocios/crudify-ui 1.0.55 → 1.0.57

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 (3) hide show
  1. package/dist/index.js +141 -14
  2. package/dist/index.mjs +148 -21
  3. 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);
@@ -719,11 +726,16 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams }) => {
719
726
  const [fromCodeVerification, setFromCodeVerification] = (0, import_react6.useState)(false);
720
727
  const [validatingCode, setValidatingCode] = (0, import_react6.useState)(true);
721
728
  const [codeValidated, setCodeValidated] = (0, import_react6.useState)(false);
729
+ const [pendingValidation, setPendingValidation] = (0, import_react6.useState)(null);
722
730
  const { t } = useTranslation();
723
731
  const { crudify: crudify3 } = useCrudifyLogin(config);
724
732
  (0, import_react6.useEffect)(() => {
725
733
  const validateCode = async (emailToValidate, codeToValidate) => {
726
- if (!crudify3) return;
734
+ if (!crudify3) {
735
+ console.log("\u23F3 Crudify not ready yet, skipping validation");
736
+ return;
737
+ }
738
+ console.log("\u{1F50D} Validating reset code:", { emailToValidate, codeToValidate });
727
739
  try {
728
740
  const data = [
729
741
  {
@@ -731,10 +743,14 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams }) => {
731
743
  data: { email: emailToValidate, codePassword: codeToValidate }
732
744
  }
733
745
  ];
746
+ console.log("\u{1F4E4} Sending validation request:", data);
734
747
  const response = await crudify3.transaction(data);
748
+ console.log("\u{1F4E5} Validation response:", response);
735
749
  if (response.success) {
750
+ console.log("\u2705 Code validation successful");
736
751
  setCodeValidated(true);
737
752
  } else {
753
+ console.log("\u274C Code validation failed:", response);
738
754
  if (response.data?.response?.status === "TOO_MANY_REQUESTS") {
739
755
  setErrors([t("errors.auth.TOO_MANY_REQUESTS")]);
740
756
  } else {
@@ -782,13 +798,20 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams }) => {
782
798
  const decodedLink = decodeURIComponent(linkParam);
783
799
  const [linkCode, linkEmail] = decodedLink.split("/");
784
800
  if (linkCode && linkEmail && linkCode.length === 6) {
801
+ console.log("\u{1F517} Reset link detected:", { linkCode, linkEmail });
785
802
  setCode(linkCode);
786
803
  setEmail(linkEmail);
787
804
  setFromCodeVerification(false);
788
- validateCode(linkEmail, linkCode);
805
+ if (!crudify3) {
806
+ console.log("\u23F3 Crudify not ready, saving pending validation");
807
+ setPendingValidation({ email: linkEmail, code: linkCode });
808
+ } else {
809
+ validateCode(linkEmail, linkCode);
810
+ }
789
811
  return;
790
812
  }
791
813
  } catch (error) {
814
+ console.error("Failed to parse reset link:", error);
792
815
  }
793
816
  }
794
817
  if (emailParam && codeParam) {
@@ -803,6 +826,59 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams }) => {
803
826
  setValidatingCode(false);
804
827
  setTimeout(() => onNavigate?.("/login/forgotPassword"), 3e3);
805
828
  }, [searchParams, crudify3, t, onNavigate]);
829
+ (0, import_react6.useEffect)(() => {
830
+ if (crudify3 && pendingValidation) {
831
+ console.log("\u{1F680} Crudify ready! Executing pending validation:", pendingValidation);
832
+ const validateCode = async (emailToValidate, codeToValidate) => {
833
+ console.log("\u{1F50D} Validating reset code:", { emailToValidate, codeToValidate });
834
+ try {
835
+ const data = [
836
+ {
837
+ operation: "validatePasswordResetCode",
838
+ data: { email: emailToValidate, codePassword: codeToValidate }
839
+ }
840
+ ];
841
+ console.log("\u{1F4E4} Sending validation request:", data);
842
+ const response = await crudify3.transaction(data);
843
+ console.log("\u{1F4E5} Validation response:", response);
844
+ if (response.success) {
845
+ console.log("\u2705 Code validation successful");
846
+ setCodeValidated(true);
847
+ } else {
848
+ console.log("\u274C Code validation failed:", response);
849
+ if (response.data?.response?.status === "TOO_MANY_REQUESTS") {
850
+ setErrors([t("errors.auth.TOO_MANY_REQUESTS")]);
851
+ } else {
852
+ let errorMessage = t("resetPassword.invalidCode");
853
+ if (response.errors?._error) {
854
+ const error = response.errors._error[0];
855
+ if (error === "TOO_MANY_REQUESTS") {
856
+ errorMessage = t("errors.auth.TOO_MANY_REQUESTS");
857
+ } else {
858
+ const errorMsg = error?.toLowerCase() || "";
859
+ if (errorMsg.includes("expired")) {
860
+ errorMessage = t("resetPassword.codeExpiredOrInvalid");
861
+ } else if (errorMsg.includes("invalid")) {
862
+ errorMessage = t("resetPassword.invalidCode");
863
+ }
864
+ }
865
+ }
866
+ setErrors([errorMessage]);
867
+ }
868
+ setTimeout(() => onNavigate?.("/login/forgotPassword"), 3e3);
869
+ }
870
+ } catch (error) {
871
+ console.error("Code validation error:", error);
872
+ setErrors([t("resetPassword.invalidCode")]);
873
+ setTimeout(() => onNavigate?.("/login/forgotPassword"), 3e3);
874
+ } finally {
875
+ setValidatingCode(false);
876
+ setPendingValidation(null);
877
+ }
878
+ };
879
+ validateCode(pendingValidation.email, pendingValidation.code);
880
+ }
881
+ }, [crudify3, pendingValidation, t, onNavigate]);
806
882
  const validatePassword = (password) => {
807
883
  if (password.length < 8) {
808
884
  return t("resetPassword.passwordTooShort");
@@ -845,9 +921,7 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams }) => {
845
921
  if (response.success) {
846
922
  setErrors([]);
847
923
  setTimeout(() => {
848
- const redirectParam = searchParams?.get("redirect");
849
- const loginPath = redirectParam ? `/login?redirect=${redirectParam}` : "/login";
850
- onNavigate?.(loginPath + "?resetSuccess=true");
924
+ onResetSuccess?.();
851
925
  }, 1e3);
852
926
  } else {
853
927
  const errorMessages = [];
@@ -1142,6 +1216,25 @@ var CrudifyLoginInternal = ({
1142
1216
  const { t } = useTranslation();
1143
1217
  const [currentScreen, setCurrentScreen] = (0, import_react8.useState)(initialScreen);
1144
1218
  const [searchParams, setSearchParams] = (0, import_react8.useState)();
1219
+ console.log("\u{1F504} CrudifyLoginInternal RENDER:", { currentScreen, initialScreen });
1220
+ import_react8.default.useEffect(() => {
1221
+ const urlParams = new URLSearchParams(window.location.search);
1222
+ if (initialScreen === "checkCode") {
1223
+ const email = urlParams.get("email");
1224
+ const code = urlParams.get("code");
1225
+ console.log("\u{1F517} CheckCode link detected:", { email, code });
1226
+ if (email) {
1227
+ setSearchParams(urlParams);
1228
+ }
1229
+ }
1230
+ if (initialScreen === "resetPassword") {
1231
+ const link = urlParams.get("link");
1232
+ console.log("\u{1F517} ResetPassword link detected:", { link });
1233
+ if (link) {
1234
+ setSearchParams(urlParams);
1235
+ }
1236
+ }
1237
+ }, [initialScreen]);
1145
1238
  const finalConfig = (0, import_react8.useMemo)(() => {
1146
1239
  let cookieConfig = {};
1147
1240
  if (autoReadFromCookies) {
@@ -1185,39 +1278,73 @@ var CrudifyLoginInternal = ({
1185
1278
  };
1186
1279
  }, [providedConfig, autoReadFromCookies]);
1187
1280
  const handleNavigate = (path) => {
1281
+ console.log("\u{1F680} INTERNAL handleNavigate called with:", path);
1188
1282
  const [basePath, queryString] = path.split("?");
1189
1283
  if (queryString) {
1190
1284
  setSearchParams(new URLSearchParams(queryString));
1191
1285
  } else {
1192
1286
  setSearchParams(void 0);
1193
1287
  }
1288
+ let newScreen = "login";
1194
1289
  if (basePath.includes("/forgotPassword")) {
1195
- setCurrentScreen("forgotPassword");
1290
+ newScreen = "forgotPassword";
1196
1291
  } else if (basePath.includes("/checkCode")) {
1197
- setCurrentScreen("checkCode");
1292
+ newScreen = "checkCode";
1198
1293
  } else if (basePath.includes("/resetPassword")) {
1199
- setCurrentScreen("resetPassword");
1294
+ newScreen = "resetPassword";
1200
1295
  } else {
1201
- setCurrentScreen("login");
1296
+ newScreen = "login";
1202
1297
  }
1298
+ console.log("\u{1F3AF} INTERNAL Setting currentScreen from", currentScreen, "to", newScreen);
1299
+ setCurrentScreen(newScreen);
1300
+ console.log("\u{1F512} All navigation handled internally - no external calls");
1301
+ };
1302
+ const notifyExternal = (path, reason) => {
1303
+ console.log(`\u{1F4E2} Notifying external: ${reason} - ${path}`);
1203
1304
  onNavigate?.(path);
1204
1305
  };
1205
1306
  const renderCurrentForm = () => {
1307
+ console.log("\u{1F3A8} renderCurrentForm for screen:", currentScreen);
1206
1308
  const commonProps = {
1207
1309
  config: finalConfig,
1208
1310
  onNavigate: handleNavigate,
1311
+ // Navegación interna
1209
1312
  onError,
1210
1313
  redirectUrl
1211
1314
  };
1212
1315
  switch (currentScreen) {
1213
1316
  case "forgotPassword":
1317
+ console.log("\u{1F4CB} Rendering ForgotPasswordForm");
1214
1318
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ForgotPasswordForm_default, { ...commonProps });
1215
1319
  case "checkCode":
1216
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CheckCodeForm_default, { ...commonProps });
1320
+ console.log("\u{1F522} Rendering CheckCodeForm");
1321
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CheckCodeForm_default, { ...commonProps, searchParams });
1217
1322
  case "resetPassword":
1218
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ResetPasswordForm_default, { ...commonProps, searchParams });
1323
+ console.log("\u{1F510} Rendering ResetPasswordForm");
1324
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1325
+ ResetPasswordForm_default,
1326
+ {
1327
+ ...commonProps,
1328
+ searchParams,
1329
+ onResetSuccess: () => {
1330
+ notifyExternal(redirectUrl, "Password reset successful");
1331
+ }
1332
+ }
1333
+ );
1219
1334
  default:
1220
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(LoginForm_default, { ...commonProps, onLoginSuccess });
1335
+ console.log("\u{1F511} Rendering LoginForm");
1336
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1337
+ LoginForm_default,
1338
+ {
1339
+ ...commonProps,
1340
+ onLoginSuccess: (result) => {
1341
+ if (onLoginSuccess) {
1342
+ onLoginSuccess(result);
1343
+ }
1344
+ notifyExternal(redirectUrl, "Login successful");
1345
+ }
1346
+ }
1347
+ );
1221
1348
  }
1222
1349
  };
1223
1350
  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 useEffect5 } from "react";
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);
@@ -675,11 +682,16 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams }) => {
675
682
  const [fromCodeVerification, setFromCodeVerification] = useState4(false);
676
683
  const [validatingCode, setValidatingCode] = useState4(true);
677
684
  const [codeValidated, setCodeValidated] = useState4(false);
685
+ const [pendingValidation, setPendingValidation] = useState4(null);
678
686
  const { t } = useTranslation();
679
687
  const { crudify: crudify3 } = useCrudifyLogin(config);
680
- useEffect5(() => {
688
+ useEffect4(() => {
681
689
  const validateCode = async (emailToValidate, codeToValidate) => {
682
- if (!crudify3) return;
690
+ if (!crudify3) {
691
+ console.log("\u23F3 Crudify not ready yet, skipping validation");
692
+ return;
693
+ }
694
+ console.log("\u{1F50D} Validating reset code:", { emailToValidate, codeToValidate });
683
695
  try {
684
696
  const data = [
685
697
  {
@@ -687,10 +699,14 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams }) => {
687
699
  data: { email: emailToValidate, codePassword: codeToValidate }
688
700
  }
689
701
  ];
702
+ console.log("\u{1F4E4} Sending validation request:", data);
690
703
  const response = await crudify3.transaction(data);
704
+ console.log("\u{1F4E5} Validation response:", response);
691
705
  if (response.success) {
706
+ console.log("\u2705 Code validation successful");
692
707
  setCodeValidated(true);
693
708
  } else {
709
+ console.log("\u274C Code validation failed:", response);
694
710
  if (response.data?.response?.status === "TOO_MANY_REQUESTS") {
695
711
  setErrors([t("errors.auth.TOO_MANY_REQUESTS")]);
696
712
  } else {
@@ -738,13 +754,20 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams }) => {
738
754
  const decodedLink = decodeURIComponent(linkParam);
739
755
  const [linkCode, linkEmail] = decodedLink.split("/");
740
756
  if (linkCode && linkEmail && linkCode.length === 6) {
757
+ console.log("\u{1F517} Reset link detected:", { linkCode, linkEmail });
741
758
  setCode(linkCode);
742
759
  setEmail(linkEmail);
743
760
  setFromCodeVerification(false);
744
- validateCode(linkEmail, linkCode);
761
+ if (!crudify3) {
762
+ console.log("\u23F3 Crudify not ready, saving pending validation");
763
+ setPendingValidation({ email: linkEmail, code: linkCode });
764
+ } else {
765
+ validateCode(linkEmail, linkCode);
766
+ }
745
767
  return;
746
768
  }
747
769
  } catch (error) {
770
+ console.error("Failed to parse reset link:", error);
748
771
  }
749
772
  }
750
773
  if (emailParam && codeParam) {
@@ -759,6 +782,59 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams }) => {
759
782
  setValidatingCode(false);
760
783
  setTimeout(() => onNavigate?.("/login/forgotPassword"), 3e3);
761
784
  }, [searchParams, crudify3, t, onNavigate]);
785
+ useEffect4(() => {
786
+ if (crudify3 && pendingValidation) {
787
+ console.log("\u{1F680} Crudify ready! Executing pending validation:", pendingValidation);
788
+ const validateCode = async (emailToValidate, codeToValidate) => {
789
+ console.log("\u{1F50D} Validating reset code:", { emailToValidate, codeToValidate });
790
+ try {
791
+ const data = [
792
+ {
793
+ operation: "validatePasswordResetCode",
794
+ data: { email: emailToValidate, codePassword: codeToValidate }
795
+ }
796
+ ];
797
+ console.log("\u{1F4E4} Sending validation request:", data);
798
+ const response = await crudify3.transaction(data);
799
+ console.log("\u{1F4E5} Validation response:", response);
800
+ if (response.success) {
801
+ console.log("\u2705 Code validation successful");
802
+ setCodeValidated(true);
803
+ } else {
804
+ console.log("\u274C Code validation failed:", response);
805
+ if (response.data?.response?.status === "TOO_MANY_REQUESTS") {
806
+ setErrors([t("errors.auth.TOO_MANY_REQUESTS")]);
807
+ } else {
808
+ let errorMessage = t("resetPassword.invalidCode");
809
+ if (response.errors?._error) {
810
+ const error = response.errors._error[0];
811
+ if (error === "TOO_MANY_REQUESTS") {
812
+ errorMessage = t("errors.auth.TOO_MANY_REQUESTS");
813
+ } else {
814
+ const errorMsg = error?.toLowerCase() || "";
815
+ if (errorMsg.includes("expired")) {
816
+ errorMessage = t("resetPassword.codeExpiredOrInvalid");
817
+ } else if (errorMsg.includes("invalid")) {
818
+ errorMessage = t("resetPassword.invalidCode");
819
+ }
820
+ }
821
+ }
822
+ setErrors([errorMessage]);
823
+ }
824
+ setTimeout(() => onNavigate?.("/login/forgotPassword"), 3e3);
825
+ }
826
+ } catch (error) {
827
+ console.error("Code validation error:", error);
828
+ setErrors([t("resetPassword.invalidCode")]);
829
+ setTimeout(() => onNavigate?.("/login/forgotPassword"), 3e3);
830
+ } finally {
831
+ setValidatingCode(false);
832
+ setPendingValidation(null);
833
+ }
834
+ };
835
+ validateCode(pendingValidation.email, pendingValidation.code);
836
+ }
837
+ }, [crudify3, pendingValidation, t, onNavigate]);
762
838
  const validatePassword = (password) => {
763
839
  if (password.length < 8) {
764
840
  return t("resetPassword.passwordTooShort");
@@ -801,9 +877,7 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams }) => {
801
877
  if (response.success) {
802
878
  setErrors([]);
803
879
  setTimeout(() => {
804
- const redirectParam = searchParams?.get("redirect");
805
- const loginPath = redirectParam ? `/login?redirect=${redirectParam}` : "/login";
806
- onNavigate?.(loginPath + "?resetSuccess=true");
880
+ onResetSuccess?.();
807
881
  }, 1e3);
808
882
  } else {
809
883
  const errorMessages = [];
@@ -945,7 +1019,7 @@ var ResetPasswordForm = ({ config, onNavigate, onError, searchParams }) => {
945
1019
  var ResetPasswordForm_default = ResetPasswordForm;
946
1020
 
947
1021
  // src/components/CrudifyLogin/Forms/CheckCodeForm.tsx
948
- import { useState as useState5, useEffect as useEffect6 } from "react";
1022
+ import { useState as useState5, useEffect as useEffect5 } from "react";
949
1023
  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
1024
  import { Fragment as Fragment4, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
951
1025
  var CheckCodeForm = ({ config, onNavigate, onError, searchParams }) => {
@@ -956,7 +1030,7 @@ var CheckCodeForm = ({ config, onNavigate, onError, searchParams }) => {
956
1030
  const [email, setEmail] = useState5("");
957
1031
  const { t } = useTranslation();
958
1032
  const { crudify: crudify3 } = useCrudifyLogin(config);
959
- useEffect6(() => {
1033
+ useEffect5(() => {
960
1034
  const emailParam = searchParams?.get("email");
961
1035
  if (emailParam) {
962
1036
  setEmail(emailParam);
@@ -1098,6 +1172,25 @@ var CrudifyLoginInternal = ({
1098
1172
  const { t } = useTranslation();
1099
1173
  const [currentScreen, setCurrentScreen] = useState6(initialScreen);
1100
1174
  const [searchParams, setSearchParams] = useState6();
1175
+ console.log("\u{1F504} CrudifyLoginInternal RENDER:", { currentScreen, initialScreen });
1176
+ React2.useEffect(() => {
1177
+ const urlParams = new URLSearchParams(window.location.search);
1178
+ if (initialScreen === "checkCode") {
1179
+ const email = urlParams.get("email");
1180
+ const code = urlParams.get("code");
1181
+ console.log("\u{1F517} CheckCode link detected:", { email, code });
1182
+ if (email) {
1183
+ setSearchParams(urlParams);
1184
+ }
1185
+ }
1186
+ if (initialScreen === "resetPassword") {
1187
+ const link = urlParams.get("link");
1188
+ console.log("\u{1F517} ResetPassword link detected:", { link });
1189
+ if (link) {
1190
+ setSearchParams(urlParams);
1191
+ }
1192
+ }
1193
+ }, [initialScreen]);
1101
1194
  const finalConfig = useMemo3(() => {
1102
1195
  let cookieConfig = {};
1103
1196
  if (autoReadFromCookies) {
@@ -1141,39 +1234,73 @@ var CrudifyLoginInternal = ({
1141
1234
  };
1142
1235
  }, [providedConfig, autoReadFromCookies]);
1143
1236
  const handleNavigate = (path) => {
1237
+ console.log("\u{1F680} INTERNAL handleNavigate called with:", path);
1144
1238
  const [basePath, queryString] = path.split("?");
1145
1239
  if (queryString) {
1146
1240
  setSearchParams(new URLSearchParams(queryString));
1147
1241
  } else {
1148
1242
  setSearchParams(void 0);
1149
1243
  }
1244
+ let newScreen = "login";
1150
1245
  if (basePath.includes("/forgotPassword")) {
1151
- setCurrentScreen("forgotPassword");
1246
+ newScreen = "forgotPassword";
1152
1247
  } else if (basePath.includes("/checkCode")) {
1153
- setCurrentScreen("checkCode");
1248
+ newScreen = "checkCode";
1154
1249
  } else if (basePath.includes("/resetPassword")) {
1155
- setCurrentScreen("resetPassword");
1250
+ newScreen = "resetPassword";
1156
1251
  } else {
1157
- setCurrentScreen("login");
1252
+ newScreen = "login";
1158
1253
  }
1254
+ console.log("\u{1F3AF} INTERNAL Setting currentScreen from", currentScreen, "to", newScreen);
1255
+ setCurrentScreen(newScreen);
1256
+ console.log("\u{1F512} All navigation handled internally - no external calls");
1257
+ };
1258
+ const notifyExternal = (path, reason) => {
1259
+ console.log(`\u{1F4E2} Notifying external: ${reason} - ${path}`);
1159
1260
  onNavigate?.(path);
1160
1261
  };
1161
1262
  const renderCurrentForm = () => {
1263
+ console.log("\u{1F3A8} renderCurrentForm for screen:", currentScreen);
1162
1264
  const commonProps = {
1163
1265
  config: finalConfig,
1164
1266
  onNavigate: handleNavigate,
1267
+ // Navegación interna
1165
1268
  onError,
1166
1269
  redirectUrl
1167
1270
  };
1168
1271
  switch (currentScreen) {
1169
1272
  case "forgotPassword":
1273
+ console.log("\u{1F4CB} Rendering ForgotPasswordForm");
1170
1274
  return /* @__PURE__ */ jsx6(ForgotPasswordForm_default, { ...commonProps });
1171
1275
  case "checkCode":
1172
- return /* @__PURE__ */ jsx6(CheckCodeForm_default, { ...commonProps });
1276
+ console.log("\u{1F522} Rendering CheckCodeForm");
1277
+ return /* @__PURE__ */ jsx6(CheckCodeForm_default, { ...commonProps, searchParams });
1173
1278
  case "resetPassword":
1174
- return /* @__PURE__ */ jsx6(ResetPasswordForm_default, { ...commonProps, searchParams });
1279
+ console.log("\u{1F510} Rendering ResetPasswordForm");
1280
+ return /* @__PURE__ */ jsx6(
1281
+ ResetPasswordForm_default,
1282
+ {
1283
+ ...commonProps,
1284
+ searchParams,
1285
+ onResetSuccess: () => {
1286
+ notifyExternal(redirectUrl, "Password reset successful");
1287
+ }
1288
+ }
1289
+ );
1175
1290
  default:
1176
- return /* @__PURE__ */ jsx6(LoginForm_default, { ...commonProps, onLoginSuccess });
1291
+ console.log("\u{1F511} Rendering LoginForm");
1292
+ return /* @__PURE__ */ jsx6(
1293
+ LoginForm_default,
1294
+ {
1295
+ ...commonProps,
1296
+ onLoginSuccess: (result) => {
1297
+ if (onLoginSuccess) {
1298
+ onLoginSuccess(result);
1299
+ }
1300
+ notifyExternal(redirectUrl, "Login successful");
1301
+ }
1302
+ }
1303
+ );
1177
1304
  }
1178
1305
  };
1179
1306
  return /* @__PURE__ */ jsxs5(Fragment5, { children: [
@@ -1229,7 +1356,7 @@ var CrudifyLogin = ({
1229
1356
  var CrudifyLogin_default = CrudifyLogin;
1230
1357
 
1231
1358
  // src/hooks/useUserProfile.ts
1232
- import { useState as useState7, useEffect as useEffect7, useCallback, useRef as useRef2 } from "react";
1359
+ import { useState as useState7, useEffect as useEffect6, useCallback, useRef as useRef2 } from "react";
1233
1360
  import crudify2 from "@nocios/crudify-browser";
1234
1361
 
1235
1362
  // src/utils/jwtUtils.ts
@@ -1349,12 +1476,12 @@ var useUserProfile = (options = {}) => {
1349
1476
  }
1350
1477
  }
1351
1478
  }, [retryOnError, maxRetries]);
1352
- useEffect7(() => {
1479
+ useEffect6(() => {
1353
1480
  if (autoFetch) {
1354
1481
  refreshProfile();
1355
1482
  }
1356
1483
  }, [autoFetch, refreshProfile]);
1357
- useEffect7(() => {
1484
+ useEffect6(() => {
1358
1485
  mountedRef.current = true;
1359
1486
  return () => {
1360
1487
  mountedRef.current = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocios/crudify-ui",
3
- "version": "1.0.55",
3
+ "version": "1.0.57",
4
4
  "description": "Biblioteca de componentes UI para Crudify",
5
5
  "author": "Nocios",
6
6
  "license": "MIT",