@nocios/crudify-ui 1.0.71 → 1.0.73
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.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +110 -53
- package/dist/index.mjs +110 -53
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -187,8 +187,8 @@ declare const ERROR_CODES: {
|
|
|
187
187
|
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
188
188
|
readonly TIMEOUT_ERROR: "TIMEOUT_ERROR";
|
|
189
189
|
};
|
|
190
|
-
type ErrorCode = typeof ERROR_CODES[keyof typeof ERROR_CODES];
|
|
191
|
-
type ErrorSeverity =
|
|
190
|
+
type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
|
|
191
|
+
type ErrorSeverity = "info" | "warning" | "error" | "critical";
|
|
192
192
|
declare const ERROR_SEVERITY_MAP: Record<ErrorCode, ErrorSeverity>;
|
|
193
193
|
interface ParsedError {
|
|
194
194
|
code: ErrorCode;
|
package/dist/index.d.ts
CHANGED
|
@@ -187,8 +187,8 @@ declare const ERROR_CODES: {
|
|
|
187
187
|
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
188
188
|
readonly TIMEOUT_ERROR: "TIMEOUT_ERROR";
|
|
189
189
|
};
|
|
190
|
-
type ErrorCode = typeof ERROR_CODES[keyof typeof ERROR_CODES];
|
|
191
|
-
type ErrorSeverity =
|
|
190
|
+
type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
|
|
191
|
+
type ErrorSeverity = "info" | "warning" | "error" | "critical";
|
|
192
192
|
declare const ERROR_SEVERITY_MAP: Record<ErrorCode, ErrorSeverity>;
|
|
193
193
|
interface ParsedError {
|
|
194
194
|
code: ErrorCode;
|
package/dist/index.js
CHANGED
|
@@ -238,15 +238,27 @@ var initialState = {
|
|
|
238
238
|
config: {}
|
|
239
239
|
};
|
|
240
240
|
function loginStateReducer(state, action) {
|
|
241
|
+
console.log("\u{1F504} LoginStateReducer - Action dispatched:", {
|
|
242
|
+
type: action.type,
|
|
243
|
+
currentScreen: state.currentScreen,
|
|
244
|
+
payload: action.payload
|
|
245
|
+
});
|
|
241
246
|
switch (action.type) {
|
|
242
247
|
case "SET_SCREEN":
|
|
243
|
-
|
|
248
|
+
const newState = {
|
|
244
249
|
...state,
|
|
245
250
|
currentScreen: action.payload.screen,
|
|
246
251
|
searchParams: action.payload.params || state.searchParams,
|
|
247
252
|
// Clear form errors when changing screens
|
|
248
253
|
errors: { global: [] }
|
|
249
254
|
};
|
|
255
|
+
console.log("\u{1F504} LoginStateReducer - SET_SCREEN result:", {
|
|
256
|
+
oldScreen: state.currentScreen,
|
|
257
|
+
newScreen: newState.currentScreen,
|
|
258
|
+
oldParams: state.searchParams,
|
|
259
|
+
newParams: newState.searchParams
|
|
260
|
+
});
|
|
261
|
+
return newState;
|
|
250
262
|
case "SET_SEARCH_PARAMS":
|
|
251
263
|
return {
|
|
252
264
|
...state,
|
|
@@ -333,6 +345,11 @@ var LoginStateProvider = ({
|
|
|
333
345
|
config: providedConfig,
|
|
334
346
|
autoReadFromCookies = true
|
|
335
347
|
}) => {
|
|
348
|
+
console.log("\u{1F3D7}\uFE0F LoginStateProvider - Component initialized with:", {
|
|
349
|
+
initialScreen,
|
|
350
|
+
providedConfig,
|
|
351
|
+
autoReadFromCookies
|
|
352
|
+
});
|
|
336
353
|
const [state, dispatch] = (0, import_react4.useReducer)(loginStateReducer, {
|
|
337
354
|
...initialState,
|
|
338
355
|
currentScreen: initialScreen
|
|
@@ -393,6 +410,11 @@ var LoginStateProvider = ({
|
|
|
393
410
|
}
|
|
394
411
|
}, [initialScreen]);
|
|
395
412
|
const setScreen = (screen2, params) => {
|
|
413
|
+
console.log("\u{1F504} LoginStateProvider - setScreen called:", {
|
|
414
|
+
currentScreen: state.currentScreen,
|
|
415
|
+
targetScreen: screen2,
|
|
416
|
+
params
|
|
417
|
+
});
|
|
396
418
|
dispatch({ type: "SET_SCREEN", payload: { screen: screen2, params } });
|
|
397
419
|
};
|
|
398
420
|
const updateFormData = (data) => {
|
|
@@ -686,11 +708,13 @@ function parseApiError(response) {
|
|
|
686
708
|
details: { originalError: error }
|
|
687
709
|
});
|
|
688
710
|
}
|
|
689
|
-
return errors.length > 0 ? errors : [
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
711
|
+
return errors.length > 0 ? errors : [
|
|
712
|
+
{
|
|
713
|
+
code: ERROR_CODES.INTERNAL_SERVER_ERROR,
|
|
714
|
+
message: "Unknown error occurred",
|
|
715
|
+
severity: "error"
|
|
716
|
+
}
|
|
717
|
+
];
|
|
694
718
|
}
|
|
695
719
|
function parseTransactionError(response) {
|
|
696
720
|
try {
|
|
@@ -718,12 +742,14 @@ function parseTransactionError(response) {
|
|
|
718
742
|
}
|
|
719
743
|
return parseApiError(response);
|
|
720
744
|
} catch (error) {
|
|
721
|
-
return [
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
745
|
+
return [
|
|
746
|
+
{
|
|
747
|
+
code: ERROR_CODES.INTERNAL_SERVER_ERROR,
|
|
748
|
+
message: "Failed to parse transaction error",
|
|
749
|
+
severity: "error",
|
|
750
|
+
details: { originalError: error }
|
|
751
|
+
}
|
|
752
|
+
];
|
|
727
753
|
}
|
|
728
754
|
}
|
|
729
755
|
function isValidErrorCode(code) {
|
|
@@ -795,12 +821,14 @@ function handleCrudifyError(error) {
|
|
|
795
821
|
}
|
|
796
822
|
return parseApiError(error);
|
|
797
823
|
}
|
|
798
|
-
return [
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
824
|
+
return [
|
|
825
|
+
{
|
|
826
|
+
code: ERROR_CODES.INTERNAL_SERVER_ERROR,
|
|
827
|
+
message: "An unknown error occurred",
|
|
828
|
+
severity: "error",
|
|
829
|
+
details: { originalError: error }
|
|
830
|
+
}
|
|
831
|
+
];
|
|
804
832
|
}
|
|
805
833
|
|
|
806
834
|
// src/components/CrudifyLogin/Forms/LoginForm.tsx
|
|
@@ -1087,7 +1115,14 @@ var ForgotPasswordForm = ({ onScreenChange, onError }) => {
|
|
|
1087
1115
|
onScreenChange?.("login");
|
|
1088
1116
|
};
|
|
1089
1117
|
const handleGoToCheckCode = () => {
|
|
1118
|
+
console.log("\u{1F4E7} ForgotPasswordForm - handleGoToCheckCode called:", {
|
|
1119
|
+
emailSent,
|
|
1120
|
+
codeAlreadyExists,
|
|
1121
|
+
email,
|
|
1122
|
+
onScreenChange: !!onScreenChange
|
|
1123
|
+
});
|
|
1090
1124
|
if (emailSent || codeAlreadyExists) {
|
|
1125
|
+
console.log("\u{1F4E7} ForgotPasswordForm - Navigating to checkCode with email:", email);
|
|
1091
1126
|
onScreenChange?.("checkCode", { email });
|
|
1092
1127
|
return;
|
|
1093
1128
|
}
|
|
@@ -1099,6 +1134,7 @@ var ForgotPasswordForm = ({ onScreenChange, onError }) => {
|
|
|
1099
1134
|
setHelperTextEmail(t("forgotPassword.invalidEmail"));
|
|
1100
1135
|
return;
|
|
1101
1136
|
}
|
|
1137
|
+
console.log("\u{1F4E7} ForgotPasswordForm - Navigating to checkCode with validated email:", email);
|
|
1102
1138
|
onScreenChange?.("checkCode", { email });
|
|
1103
1139
|
};
|
|
1104
1140
|
if (emailSent || codeAlreadyExists) {
|
|
@@ -1194,14 +1230,21 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
|
|
|
1194
1230
|
}
|
|
1195
1231
|
return parsedError.message || t("error.unknown");
|
|
1196
1232
|
};
|
|
1233
|
+
const getParam = (key) => {
|
|
1234
|
+
if (!searchParams) return null;
|
|
1235
|
+
if (searchParams instanceof URLSearchParams) {
|
|
1236
|
+
return searchParams.get(key);
|
|
1237
|
+
}
|
|
1238
|
+
return searchParams[key] || null;
|
|
1239
|
+
};
|
|
1197
1240
|
(0, import_react7.useEffect)(() => {
|
|
1198
1241
|
if (!searchParams) {
|
|
1199
1242
|
return;
|
|
1200
1243
|
}
|
|
1201
1244
|
if (searchParams) {
|
|
1202
|
-
const fromCodeVerificationParam =
|
|
1203
|
-
const emailParam =
|
|
1204
|
-
const codeParam =
|
|
1245
|
+
const fromCodeVerificationParam = getParam("fromCodeVerification");
|
|
1246
|
+
const emailParam = getParam("email");
|
|
1247
|
+
const codeParam = getParam("code");
|
|
1205
1248
|
if (fromCodeVerificationParam === "true" && emailParam && codeParam) {
|
|
1206
1249
|
setEmail(emailParam);
|
|
1207
1250
|
setCode(codeParam);
|
|
@@ -1210,7 +1253,7 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
|
|
|
1210
1253
|
setValidatingCode(false);
|
|
1211
1254
|
return;
|
|
1212
1255
|
}
|
|
1213
|
-
const linkParam =
|
|
1256
|
+
const linkParam = getParam("link");
|
|
1214
1257
|
if (linkParam) {
|
|
1215
1258
|
try {
|
|
1216
1259
|
const decodedLink = decodeURIComponent(linkParam);
|
|
@@ -1427,6 +1470,11 @@ var import_react8 = require("react");
|
|
|
1427
1470
|
var import_material4 = require("@mui/material");
|
|
1428
1471
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1429
1472
|
var CheckCodeForm = ({ onScreenChange, onError, searchParams }) => {
|
|
1473
|
+
console.log("\u{1F522} CheckCodeForm - Component initialized with props:", {
|
|
1474
|
+
onScreenChange: !!onScreenChange,
|
|
1475
|
+
onError: !!onError,
|
|
1476
|
+
searchParams
|
|
1477
|
+
});
|
|
1430
1478
|
const { crudify: crudify3 } = useCrudify();
|
|
1431
1479
|
const [code, setCode] = (0, import_react8.useState)("");
|
|
1432
1480
|
const [loading, setLoading] = (0, import_react8.useState)(false);
|
|
@@ -1434,6 +1482,13 @@ var CheckCodeForm = ({ onScreenChange, onError, searchParams }) => {
|
|
|
1434
1482
|
const [helperTextCode, setHelperTextCode] = (0, import_react8.useState)(null);
|
|
1435
1483
|
const [email, setEmail] = (0, import_react8.useState)("");
|
|
1436
1484
|
const { t } = useTranslation();
|
|
1485
|
+
const getParam = (key) => {
|
|
1486
|
+
if (!searchParams) return null;
|
|
1487
|
+
if (searchParams instanceof URLSearchParams) {
|
|
1488
|
+
return searchParams.get(key);
|
|
1489
|
+
}
|
|
1490
|
+
return searchParams[key] || null;
|
|
1491
|
+
};
|
|
1437
1492
|
const translateError = (parsedError) => {
|
|
1438
1493
|
const possibleKeys = [
|
|
1439
1494
|
`errors.auth.${parsedError.code}`,
|
|
@@ -1451,10 +1506,17 @@ var CheckCodeForm = ({ onScreenChange, onError, searchParams }) => {
|
|
|
1451
1506
|
return parsedError.message || t("error.unknown");
|
|
1452
1507
|
};
|
|
1453
1508
|
(0, import_react8.useEffect)(() => {
|
|
1454
|
-
|
|
1509
|
+
console.log("\u{1F522} CheckCodeForm - useEffect triggered:", {
|
|
1510
|
+
searchParams,
|
|
1511
|
+
onScreenChange: !!onScreenChange
|
|
1512
|
+
});
|
|
1513
|
+
const emailParam = getParam("email");
|
|
1514
|
+
console.log("\u{1F522} CheckCodeForm - emailParam extracted:", emailParam);
|
|
1455
1515
|
if (emailParam) {
|
|
1516
|
+
console.log("\u{1F522} CheckCodeForm - Setting email:", emailParam);
|
|
1456
1517
|
setEmail(emailParam);
|
|
1457
1518
|
} else {
|
|
1519
|
+
console.log("\u{1F522} CheckCodeForm - No email found, redirecting to forgotPassword");
|
|
1458
1520
|
onScreenChange?.("forgotPassword");
|
|
1459
1521
|
}
|
|
1460
1522
|
}, [searchParams, onScreenChange]);
|
|
@@ -1498,6 +1560,7 @@ var CheckCodeForm = ({ onScreenChange, onError, searchParams }) => {
|
|
|
1498
1560
|
}
|
|
1499
1561
|
};
|
|
1500
1562
|
const handleBack = () => {
|
|
1563
|
+
console.log("\u{1F522} CheckCodeForm - handleBack called");
|
|
1501
1564
|
onScreenChange?.("forgotPassword");
|
|
1502
1565
|
};
|
|
1503
1566
|
const handleCodeChange = (event) => {
|
|
@@ -1565,10 +1628,7 @@ var CheckCodeForm_default = CheckCodeForm;
|
|
|
1565
1628
|
// src/components/CrudifyLogin/components/CrudifyInitializer.tsx
|
|
1566
1629
|
var import_material5 = require("@mui/material");
|
|
1567
1630
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1568
|
-
var CrudifyInitializer = ({
|
|
1569
|
-
children,
|
|
1570
|
-
fallback
|
|
1571
|
-
}) => {
|
|
1631
|
+
var CrudifyInitializer = ({ children, fallback }) => {
|
|
1572
1632
|
const { isLoading, error, isInitialized } = useCrudify();
|
|
1573
1633
|
const { t } = useTranslation();
|
|
1574
1634
|
if (isLoading) {
|
|
@@ -1593,7 +1653,8 @@ var CrudifyInitializer = ({
|
|
|
1593
1653
|
if (error) {
|
|
1594
1654
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material5.Alert, { severity: "error", sx: { mt: 2 }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material5.Typography, { variant: "body2", children: [
|
|
1595
1655
|
t("login.initializationError") !== "login.initializationError" ? t("login.initializationError") : "Initialization error",
|
|
1596
|
-
":
|
|
1656
|
+
":",
|
|
1657
|
+
" ",
|
|
1597
1658
|
error
|
|
1598
1659
|
] }) });
|
|
1599
1660
|
}
|
|
@@ -1641,10 +1702,22 @@ var CrudifyLoginInternal = ({
|
|
|
1641
1702
|
const { t } = useTranslation();
|
|
1642
1703
|
const { state, setScreen } = useLoginState();
|
|
1643
1704
|
const handleScreenChange = (screen2, params) => {
|
|
1705
|
+
console.log("\u{1F504} CrudifyLoginInternal - handleScreenChange called:", {
|
|
1706
|
+
currentScreen: state.currentScreen,
|
|
1707
|
+
newScreen: screen2,
|
|
1708
|
+
params,
|
|
1709
|
+
stateSearchParams: state.searchParams
|
|
1710
|
+
});
|
|
1644
1711
|
setScreen(screen2, params);
|
|
1645
1712
|
onScreenChange?.(screen2, params);
|
|
1713
|
+
console.log("\u2705 CrudifyLoginInternal - screen change completed");
|
|
1646
1714
|
};
|
|
1647
1715
|
const renderCurrentForm = () => {
|
|
1716
|
+
console.log("\u{1F3A8} CrudifyLoginInternal - renderCurrentForm called:", {
|
|
1717
|
+
currentScreen: state.currentScreen,
|
|
1718
|
+
searchParams: state.searchParams,
|
|
1719
|
+
config: state.config
|
|
1720
|
+
});
|
|
1648
1721
|
const commonProps = {
|
|
1649
1722
|
onScreenChange: handleScreenChange,
|
|
1650
1723
|
onExternalNavigate,
|
|
@@ -1653,27 +1726,27 @@ var CrudifyLoginInternal = ({
|
|
|
1653
1726
|
};
|
|
1654
1727
|
switch (state.currentScreen) {
|
|
1655
1728
|
case "forgotPassword":
|
|
1729
|
+
console.log("\u{1F4E7} Rendering ForgotPasswordForm");
|
|
1656
1730
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ForgotPasswordForm_default, { ...commonProps });
|
|
1657
1731
|
case "checkCode":
|
|
1658
|
-
|
|
1732
|
+
console.log("\u{1F522} Rendering CheckCodeForm with params:", state.searchParams);
|
|
1733
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CheckCodeForm_default, { ...commonProps, searchParams: state.searchParams });
|
|
1659
1734
|
case "resetPassword":
|
|
1735
|
+
console.log("\u{1F510} Rendering ResetPasswordForm with params:", state.searchParams);
|
|
1660
1736
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1661
1737
|
ResetPasswordForm_default,
|
|
1662
1738
|
{
|
|
1663
1739
|
...commonProps,
|
|
1740
|
+
searchParams: state.searchParams,
|
|
1664
1741
|
onResetSuccess: () => {
|
|
1742
|
+
console.log("\u2705 ResetPasswordForm - onResetSuccess called");
|
|
1665
1743
|
handleScreenChange("login");
|
|
1666
1744
|
}
|
|
1667
1745
|
}
|
|
1668
1746
|
);
|
|
1669
1747
|
default:
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
{
|
|
1673
|
-
...commonProps,
|
|
1674
|
-
onLoginSuccess
|
|
1675
|
-
}
|
|
1676
|
-
);
|
|
1748
|
+
console.log("\u{1F3E0} Rendering LoginForm (default)");
|
|
1749
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(LoginForm_default, { ...commonProps, onLoginSuccess });
|
|
1677
1750
|
}
|
|
1678
1751
|
};
|
|
1679
1752
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(CrudifyInitializer, { children: [
|
|
@@ -1719,23 +1792,7 @@ var CrudifyLogin = ({
|
|
|
1719
1792
|
...props
|
|
1720
1793
|
}) => {
|
|
1721
1794
|
const { config: finalConfig } = useCrudifyLogin(config);
|
|
1722
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1723
|
-
I18nProvider,
|
|
1724
|
-
{
|
|
1725
|
-
translations,
|
|
1726
|
-
translationsUrl,
|
|
1727
|
-
language,
|
|
1728
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CrudifyProvider, { config: finalConfig, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1729
|
-
LoginStateProvider,
|
|
1730
|
-
{
|
|
1731
|
-
config,
|
|
1732
|
-
initialScreen,
|
|
1733
|
-
autoReadFromCookies,
|
|
1734
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CrudifyLoginInternal, { config, ...props })
|
|
1735
|
-
}
|
|
1736
|
-
) })
|
|
1737
|
-
}
|
|
1738
|
-
);
|
|
1795
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(I18nProvider, { translations, translationsUrl, language, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CrudifyProvider, { config: finalConfig, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(LoginStateProvider, { config, initialScreen, autoReadFromCookies, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CrudifyLoginInternal, { config, ...props }) }) }) });
|
|
1739
1796
|
};
|
|
1740
1797
|
var CrudifyLogin_default = CrudifyLogin;
|
|
1741
1798
|
|
package/dist/index.mjs
CHANGED
|
@@ -187,15 +187,27 @@ var initialState = {
|
|
|
187
187
|
config: {}
|
|
188
188
|
};
|
|
189
189
|
function loginStateReducer(state, action) {
|
|
190
|
+
console.log("\u{1F504} LoginStateReducer - Action dispatched:", {
|
|
191
|
+
type: action.type,
|
|
192
|
+
currentScreen: state.currentScreen,
|
|
193
|
+
payload: action.payload
|
|
194
|
+
});
|
|
190
195
|
switch (action.type) {
|
|
191
196
|
case "SET_SCREEN":
|
|
192
|
-
|
|
197
|
+
const newState = {
|
|
193
198
|
...state,
|
|
194
199
|
currentScreen: action.payload.screen,
|
|
195
200
|
searchParams: action.payload.params || state.searchParams,
|
|
196
201
|
// Clear form errors when changing screens
|
|
197
202
|
errors: { global: [] }
|
|
198
203
|
};
|
|
204
|
+
console.log("\u{1F504} LoginStateReducer - SET_SCREEN result:", {
|
|
205
|
+
oldScreen: state.currentScreen,
|
|
206
|
+
newScreen: newState.currentScreen,
|
|
207
|
+
oldParams: state.searchParams,
|
|
208
|
+
newParams: newState.searchParams
|
|
209
|
+
});
|
|
210
|
+
return newState;
|
|
199
211
|
case "SET_SEARCH_PARAMS":
|
|
200
212
|
return {
|
|
201
213
|
...state,
|
|
@@ -282,6 +294,11 @@ var LoginStateProvider = ({
|
|
|
282
294
|
config: providedConfig,
|
|
283
295
|
autoReadFromCookies = true
|
|
284
296
|
}) => {
|
|
297
|
+
console.log("\u{1F3D7}\uFE0F LoginStateProvider - Component initialized with:", {
|
|
298
|
+
initialScreen,
|
|
299
|
+
providedConfig,
|
|
300
|
+
autoReadFromCookies
|
|
301
|
+
});
|
|
285
302
|
const [state, dispatch] = useReducer(loginStateReducer, {
|
|
286
303
|
...initialState,
|
|
287
304
|
currentScreen: initialScreen
|
|
@@ -342,6 +359,11 @@ var LoginStateProvider = ({
|
|
|
342
359
|
}
|
|
343
360
|
}, [initialScreen]);
|
|
344
361
|
const setScreen = (screen2, params) => {
|
|
362
|
+
console.log("\u{1F504} LoginStateProvider - setScreen called:", {
|
|
363
|
+
currentScreen: state.currentScreen,
|
|
364
|
+
targetScreen: screen2,
|
|
365
|
+
params
|
|
366
|
+
});
|
|
345
367
|
dispatch({ type: "SET_SCREEN", payload: { screen: screen2, params } });
|
|
346
368
|
};
|
|
347
369
|
const updateFormData = (data) => {
|
|
@@ -635,11 +657,13 @@ function parseApiError(response) {
|
|
|
635
657
|
details: { originalError: error }
|
|
636
658
|
});
|
|
637
659
|
}
|
|
638
|
-
return errors.length > 0 ? errors : [
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
660
|
+
return errors.length > 0 ? errors : [
|
|
661
|
+
{
|
|
662
|
+
code: ERROR_CODES.INTERNAL_SERVER_ERROR,
|
|
663
|
+
message: "Unknown error occurred",
|
|
664
|
+
severity: "error"
|
|
665
|
+
}
|
|
666
|
+
];
|
|
643
667
|
}
|
|
644
668
|
function parseTransactionError(response) {
|
|
645
669
|
try {
|
|
@@ -667,12 +691,14 @@ function parseTransactionError(response) {
|
|
|
667
691
|
}
|
|
668
692
|
return parseApiError(response);
|
|
669
693
|
} catch (error) {
|
|
670
|
-
return [
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
694
|
+
return [
|
|
695
|
+
{
|
|
696
|
+
code: ERROR_CODES.INTERNAL_SERVER_ERROR,
|
|
697
|
+
message: "Failed to parse transaction error",
|
|
698
|
+
severity: "error",
|
|
699
|
+
details: { originalError: error }
|
|
700
|
+
}
|
|
701
|
+
];
|
|
676
702
|
}
|
|
677
703
|
}
|
|
678
704
|
function isValidErrorCode(code) {
|
|
@@ -744,12 +770,14 @@ function handleCrudifyError(error) {
|
|
|
744
770
|
}
|
|
745
771
|
return parseApiError(error);
|
|
746
772
|
}
|
|
747
|
-
return [
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
773
|
+
return [
|
|
774
|
+
{
|
|
775
|
+
code: ERROR_CODES.INTERNAL_SERVER_ERROR,
|
|
776
|
+
message: "An unknown error occurred",
|
|
777
|
+
severity: "error",
|
|
778
|
+
details: { originalError: error }
|
|
779
|
+
}
|
|
780
|
+
];
|
|
753
781
|
}
|
|
754
782
|
|
|
755
783
|
// src/components/CrudifyLogin/Forms/LoginForm.tsx
|
|
@@ -1036,7 +1064,14 @@ var ForgotPasswordForm = ({ onScreenChange, onError }) => {
|
|
|
1036
1064
|
onScreenChange?.("login");
|
|
1037
1065
|
};
|
|
1038
1066
|
const handleGoToCheckCode = () => {
|
|
1067
|
+
console.log("\u{1F4E7} ForgotPasswordForm - handleGoToCheckCode called:", {
|
|
1068
|
+
emailSent,
|
|
1069
|
+
codeAlreadyExists,
|
|
1070
|
+
email,
|
|
1071
|
+
onScreenChange: !!onScreenChange
|
|
1072
|
+
});
|
|
1039
1073
|
if (emailSent || codeAlreadyExists) {
|
|
1074
|
+
console.log("\u{1F4E7} ForgotPasswordForm - Navigating to checkCode with email:", email);
|
|
1040
1075
|
onScreenChange?.("checkCode", { email });
|
|
1041
1076
|
return;
|
|
1042
1077
|
}
|
|
@@ -1048,6 +1083,7 @@ var ForgotPasswordForm = ({ onScreenChange, onError }) => {
|
|
|
1048
1083
|
setHelperTextEmail(t("forgotPassword.invalidEmail"));
|
|
1049
1084
|
return;
|
|
1050
1085
|
}
|
|
1086
|
+
console.log("\u{1F4E7} ForgotPasswordForm - Navigating to checkCode with validated email:", email);
|
|
1051
1087
|
onScreenChange?.("checkCode", { email });
|
|
1052
1088
|
};
|
|
1053
1089
|
if (emailSent || codeAlreadyExists) {
|
|
@@ -1143,14 +1179,21 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
|
|
|
1143
1179
|
}
|
|
1144
1180
|
return parsedError.message || t("error.unknown");
|
|
1145
1181
|
};
|
|
1182
|
+
const getParam = (key) => {
|
|
1183
|
+
if (!searchParams) return null;
|
|
1184
|
+
if (searchParams instanceof URLSearchParams) {
|
|
1185
|
+
return searchParams.get(key);
|
|
1186
|
+
}
|
|
1187
|
+
return searchParams[key] || null;
|
|
1188
|
+
};
|
|
1146
1189
|
useEffect5(() => {
|
|
1147
1190
|
if (!searchParams) {
|
|
1148
1191
|
return;
|
|
1149
1192
|
}
|
|
1150
1193
|
if (searchParams) {
|
|
1151
|
-
const fromCodeVerificationParam =
|
|
1152
|
-
const emailParam =
|
|
1153
|
-
const codeParam =
|
|
1194
|
+
const fromCodeVerificationParam = getParam("fromCodeVerification");
|
|
1195
|
+
const emailParam = getParam("email");
|
|
1196
|
+
const codeParam = getParam("code");
|
|
1154
1197
|
if (fromCodeVerificationParam === "true" && emailParam && codeParam) {
|
|
1155
1198
|
setEmail(emailParam);
|
|
1156
1199
|
setCode(codeParam);
|
|
@@ -1159,7 +1202,7 @@ var ResetPasswordForm = ({ onScreenChange, onError, searchParams, onResetSuccess
|
|
|
1159
1202
|
setValidatingCode(false);
|
|
1160
1203
|
return;
|
|
1161
1204
|
}
|
|
1162
|
-
const linkParam =
|
|
1205
|
+
const linkParam = getParam("link");
|
|
1163
1206
|
if (linkParam) {
|
|
1164
1207
|
try {
|
|
1165
1208
|
const decodedLink = decodeURIComponent(linkParam);
|
|
@@ -1376,6 +1419,11 @@ import { useState as useState5, useEffect as useEffect6 } from "react";
|
|
|
1376
1419
|
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";
|
|
1377
1420
|
import { Fragment as Fragment4, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1378
1421
|
var CheckCodeForm = ({ onScreenChange, onError, searchParams }) => {
|
|
1422
|
+
console.log("\u{1F522} CheckCodeForm - Component initialized with props:", {
|
|
1423
|
+
onScreenChange: !!onScreenChange,
|
|
1424
|
+
onError: !!onError,
|
|
1425
|
+
searchParams
|
|
1426
|
+
});
|
|
1379
1427
|
const { crudify: crudify3 } = useCrudify();
|
|
1380
1428
|
const [code, setCode] = useState5("");
|
|
1381
1429
|
const [loading, setLoading] = useState5(false);
|
|
@@ -1383,6 +1431,13 @@ var CheckCodeForm = ({ onScreenChange, onError, searchParams }) => {
|
|
|
1383
1431
|
const [helperTextCode, setHelperTextCode] = useState5(null);
|
|
1384
1432
|
const [email, setEmail] = useState5("");
|
|
1385
1433
|
const { t } = useTranslation();
|
|
1434
|
+
const getParam = (key) => {
|
|
1435
|
+
if (!searchParams) return null;
|
|
1436
|
+
if (searchParams instanceof URLSearchParams) {
|
|
1437
|
+
return searchParams.get(key);
|
|
1438
|
+
}
|
|
1439
|
+
return searchParams[key] || null;
|
|
1440
|
+
};
|
|
1386
1441
|
const translateError = (parsedError) => {
|
|
1387
1442
|
const possibleKeys = [
|
|
1388
1443
|
`errors.auth.${parsedError.code}`,
|
|
@@ -1400,10 +1455,17 @@ var CheckCodeForm = ({ onScreenChange, onError, searchParams }) => {
|
|
|
1400
1455
|
return parsedError.message || t("error.unknown");
|
|
1401
1456
|
};
|
|
1402
1457
|
useEffect6(() => {
|
|
1403
|
-
|
|
1458
|
+
console.log("\u{1F522} CheckCodeForm - useEffect triggered:", {
|
|
1459
|
+
searchParams,
|
|
1460
|
+
onScreenChange: !!onScreenChange
|
|
1461
|
+
});
|
|
1462
|
+
const emailParam = getParam("email");
|
|
1463
|
+
console.log("\u{1F522} CheckCodeForm - emailParam extracted:", emailParam);
|
|
1404
1464
|
if (emailParam) {
|
|
1465
|
+
console.log("\u{1F522} CheckCodeForm - Setting email:", emailParam);
|
|
1405
1466
|
setEmail(emailParam);
|
|
1406
1467
|
} else {
|
|
1468
|
+
console.log("\u{1F522} CheckCodeForm - No email found, redirecting to forgotPassword");
|
|
1407
1469
|
onScreenChange?.("forgotPassword");
|
|
1408
1470
|
}
|
|
1409
1471
|
}, [searchParams, onScreenChange]);
|
|
@@ -1447,6 +1509,7 @@ var CheckCodeForm = ({ onScreenChange, onError, searchParams }) => {
|
|
|
1447
1509
|
}
|
|
1448
1510
|
};
|
|
1449
1511
|
const handleBack = () => {
|
|
1512
|
+
console.log("\u{1F522} CheckCodeForm - handleBack called");
|
|
1450
1513
|
onScreenChange?.("forgotPassword");
|
|
1451
1514
|
};
|
|
1452
1515
|
const handleCodeChange = (event) => {
|
|
@@ -1514,10 +1577,7 @@ var CheckCodeForm_default = CheckCodeForm;
|
|
|
1514
1577
|
// src/components/CrudifyLogin/components/CrudifyInitializer.tsx
|
|
1515
1578
|
import { Box as Box5, CircularProgress as CircularProgress5, Alert as Alert5, Typography as Typography5 } from "@mui/material";
|
|
1516
1579
|
import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1517
|
-
var CrudifyInitializer = ({
|
|
1518
|
-
children,
|
|
1519
|
-
fallback
|
|
1520
|
-
}) => {
|
|
1580
|
+
var CrudifyInitializer = ({ children, fallback }) => {
|
|
1521
1581
|
const { isLoading, error, isInitialized } = useCrudify();
|
|
1522
1582
|
const { t } = useTranslation();
|
|
1523
1583
|
if (isLoading) {
|
|
@@ -1542,7 +1602,8 @@ var CrudifyInitializer = ({
|
|
|
1542
1602
|
if (error) {
|
|
1543
1603
|
return /* @__PURE__ */ jsx8(Alert5, { severity: "error", sx: { mt: 2 }, children: /* @__PURE__ */ jsxs5(Typography5, { variant: "body2", children: [
|
|
1544
1604
|
t("login.initializationError") !== "login.initializationError" ? t("login.initializationError") : "Initialization error",
|
|
1545
|
-
":
|
|
1605
|
+
":",
|
|
1606
|
+
" ",
|
|
1546
1607
|
error
|
|
1547
1608
|
] }) });
|
|
1548
1609
|
}
|
|
@@ -1590,10 +1651,22 @@ var CrudifyLoginInternal = ({
|
|
|
1590
1651
|
const { t } = useTranslation();
|
|
1591
1652
|
const { state, setScreen } = useLoginState();
|
|
1592
1653
|
const handleScreenChange = (screen2, params) => {
|
|
1654
|
+
console.log("\u{1F504} CrudifyLoginInternal - handleScreenChange called:", {
|
|
1655
|
+
currentScreen: state.currentScreen,
|
|
1656
|
+
newScreen: screen2,
|
|
1657
|
+
params,
|
|
1658
|
+
stateSearchParams: state.searchParams
|
|
1659
|
+
});
|
|
1593
1660
|
setScreen(screen2, params);
|
|
1594
1661
|
onScreenChange?.(screen2, params);
|
|
1662
|
+
console.log("\u2705 CrudifyLoginInternal - screen change completed");
|
|
1595
1663
|
};
|
|
1596
1664
|
const renderCurrentForm = () => {
|
|
1665
|
+
console.log("\u{1F3A8} CrudifyLoginInternal - renderCurrentForm called:", {
|
|
1666
|
+
currentScreen: state.currentScreen,
|
|
1667
|
+
searchParams: state.searchParams,
|
|
1668
|
+
config: state.config
|
|
1669
|
+
});
|
|
1597
1670
|
const commonProps = {
|
|
1598
1671
|
onScreenChange: handleScreenChange,
|
|
1599
1672
|
onExternalNavigate,
|
|
@@ -1602,27 +1675,27 @@ var CrudifyLoginInternal = ({
|
|
|
1602
1675
|
};
|
|
1603
1676
|
switch (state.currentScreen) {
|
|
1604
1677
|
case "forgotPassword":
|
|
1678
|
+
console.log("\u{1F4E7} Rendering ForgotPasswordForm");
|
|
1605
1679
|
return /* @__PURE__ */ jsx9(ForgotPasswordForm_default, { ...commonProps });
|
|
1606
1680
|
case "checkCode":
|
|
1607
|
-
|
|
1681
|
+
console.log("\u{1F522} Rendering CheckCodeForm with params:", state.searchParams);
|
|
1682
|
+
return /* @__PURE__ */ jsx9(CheckCodeForm_default, { ...commonProps, searchParams: state.searchParams });
|
|
1608
1683
|
case "resetPassword":
|
|
1684
|
+
console.log("\u{1F510} Rendering ResetPasswordForm with params:", state.searchParams);
|
|
1609
1685
|
return /* @__PURE__ */ jsx9(
|
|
1610
1686
|
ResetPasswordForm_default,
|
|
1611
1687
|
{
|
|
1612
1688
|
...commonProps,
|
|
1689
|
+
searchParams: state.searchParams,
|
|
1613
1690
|
onResetSuccess: () => {
|
|
1691
|
+
console.log("\u2705 ResetPasswordForm - onResetSuccess called");
|
|
1614
1692
|
handleScreenChange("login");
|
|
1615
1693
|
}
|
|
1616
1694
|
}
|
|
1617
1695
|
);
|
|
1618
1696
|
default:
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
{
|
|
1622
|
-
...commonProps,
|
|
1623
|
-
onLoginSuccess
|
|
1624
|
-
}
|
|
1625
|
-
);
|
|
1697
|
+
console.log("\u{1F3E0} Rendering LoginForm (default)");
|
|
1698
|
+
return /* @__PURE__ */ jsx9(LoginForm_default, { ...commonProps, onLoginSuccess });
|
|
1626
1699
|
}
|
|
1627
1700
|
};
|
|
1628
1701
|
return /* @__PURE__ */ jsxs6(CrudifyInitializer, { children: [
|
|
@@ -1668,23 +1741,7 @@ var CrudifyLogin = ({
|
|
|
1668
1741
|
...props
|
|
1669
1742
|
}) => {
|
|
1670
1743
|
const { config: finalConfig } = useCrudifyLogin(config);
|
|
1671
|
-
return /* @__PURE__ */ jsx9(
|
|
1672
|
-
I18nProvider,
|
|
1673
|
-
{
|
|
1674
|
-
translations,
|
|
1675
|
-
translationsUrl,
|
|
1676
|
-
language,
|
|
1677
|
-
children: /* @__PURE__ */ jsx9(CrudifyProvider, { config: finalConfig, children: /* @__PURE__ */ jsx9(
|
|
1678
|
-
LoginStateProvider,
|
|
1679
|
-
{
|
|
1680
|
-
config,
|
|
1681
|
-
initialScreen,
|
|
1682
|
-
autoReadFromCookies,
|
|
1683
|
-
children: /* @__PURE__ */ jsx9(CrudifyLoginInternal, { config, ...props })
|
|
1684
|
-
}
|
|
1685
|
-
) })
|
|
1686
|
-
}
|
|
1687
|
-
);
|
|
1744
|
+
return /* @__PURE__ */ jsx9(I18nProvider, { translations, translationsUrl, language, children: /* @__PURE__ */ jsx9(CrudifyProvider, { config: finalConfig, children: /* @__PURE__ */ jsx9(LoginStateProvider, { config, initialScreen, autoReadFromCookies, children: /* @__PURE__ */ jsx9(CrudifyLoginInternal, { config, ...props }) }) }) });
|
|
1688
1745
|
};
|
|
1689
1746
|
var CrudifyLogin_default = CrudifyLogin;
|
|
1690
1747
|
|