@nocios/crudify-ui 1.0.62 → 1.0.64
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 +39 -19
- package/dist/index.mjs +47 -27
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -722,7 +722,7 @@ var ResetPasswordForm = ({ onNavigate, onError, searchParams, onResetSuccess, cr
|
|
|
722
722
|
crudifyKeys: crudify3 ? Object.keys(crudify3) : null
|
|
723
723
|
});
|
|
724
724
|
if (crudify3 && pendingValidation) {
|
|
725
|
-
console.log("\u{1F680} Crudify ready! Executing pending validation:", pendingValidation);
|
|
725
|
+
console.log("\u{1F680} Crudify verified ready! Executing pending validation:", pendingValidation);
|
|
726
726
|
console.log("\u{1F50D} Crudify object details:", {
|
|
727
727
|
hasTransaction: typeof crudify3.transaction === "function",
|
|
728
728
|
hasLogin: typeof crudify3.login === "function",
|
|
@@ -1118,6 +1118,7 @@ var getCookie = (name) => {
|
|
|
1118
1118
|
|
|
1119
1119
|
// src/components/CrudifyLogin/hooks/useCrudifyLogin.ts
|
|
1120
1120
|
var useCrudifyLogin = (config, _options = {}) => {
|
|
1121
|
+
const [isInitialized, setIsInitialized] = (0, import_react7.useState)(false);
|
|
1121
1122
|
const finalConfig = (0, import_react7.useMemo)(() => {
|
|
1122
1123
|
const publicApiKey = config.publicApiKey || getCookie("publicApiKey") || null;
|
|
1123
1124
|
const rawEnv = config.env || getCookie("environment") || "prod";
|
|
@@ -1146,44 +1147,63 @@ var useCrudifyLogin = (config, _options = {}) => {
|
|
|
1146
1147
|
});
|
|
1147
1148
|
if (!finalConfig.publicApiKey) {
|
|
1148
1149
|
console.log("\u274C No publicApiKey, skipping crudify initialization");
|
|
1150
|
+
setIsInitialized(false);
|
|
1149
1151
|
return;
|
|
1150
1152
|
}
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1153
|
+
const initializeCrudify = async () => {
|
|
1154
|
+
try {
|
|
1155
|
+
console.log("\u2699\uFE0F Configuring crudify with env:", finalConfig.env);
|
|
1156
|
+
import_crudify_browser.default.config(finalConfig.env);
|
|
1157
|
+
console.log("\u{1F680} Initializing crudify with publicApiKey:", finalConfig.publicApiKey.substring(0, 10) + "...");
|
|
1158
|
+
import_crudify_browser.default.init(finalConfig.publicApiKey, "none");
|
|
1159
|
+
console.log("\u{1F9EA} Testing crudify initialization...");
|
|
1160
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
1161
|
+
if (typeof import_crudify_browser.default.transaction === "function" && typeof import_crudify_browser.default.login === "function") {
|
|
1162
|
+
console.log("\u2705 Crudify initialization verified and ready");
|
|
1163
|
+
setIsInitialized(true);
|
|
1164
|
+
} else {
|
|
1165
|
+
console.log("\u274C Crudify methods not properly initialized");
|
|
1166
|
+
setIsInitialized(false);
|
|
1167
|
+
}
|
|
1168
|
+
console.log("\u{1F50D} Crudify state after init:", {
|
|
1169
|
+
hasTransaction: typeof import_crudify_browser.default.transaction === "function",
|
|
1170
|
+
hasLogin: typeof import_crudify_browser.default.login === "function",
|
|
1171
|
+
isInitialized: true,
|
|
1172
|
+
crudifyObject: import_crudify_browser.default
|
|
1173
|
+
});
|
|
1174
|
+
} catch (error) {
|
|
1175
|
+
console.error("\u274C Error initializing crudify:", error);
|
|
1176
|
+
setIsInitialized(false);
|
|
1177
|
+
}
|
|
1178
|
+
};
|
|
1179
|
+
initializeCrudify();
|
|
1165
1180
|
}, [finalConfig.publicApiKey, finalConfig.env]);
|
|
1166
1181
|
const crudifyMethods = (0, import_react7.useMemo)(() => {
|
|
1167
1182
|
console.log("\u{1F504} crudifyMethods useMemo triggered:", {
|
|
1168
1183
|
publicApiKey: !!finalConfig.publicApiKey,
|
|
1184
|
+
isInitialized,
|
|
1169
1185
|
crudifyLogin: typeof import_crudify_browser.default.login,
|
|
1170
1186
|
crudifyTransaction: typeof import_crudify_browser.default.transaction
|
|
1171
1187
|
});
|
|
1172
|
-
if (!finalConfig.publicApiKey) {
|
|
1173
|
-
console.log("\u274C
|
|
1188
|
+
if (!finalConfig.publicApiKey || !isInitialized) {
|
|
1189
|
+
console.log("\u274C Crudify not ready:", {
|
|
1190
|
+
publicApiKey: !!finalConfig.publicApiKey,
|
|
1191
|
+
isInitialized
|
|
1192
|
+
});
|
|
1174
1193
|
return null;
|
|
1175
1194
|
}
|
|
1176
1195
|
const methods = {
|
|
1177
1196
|
login: import_crudify_browser.default.login,
|
|
1178
1197
|
transaction: import_crudify_browser.default.transaction
|
|
1179
1198
|
};
|
|
1180
|
-
console.log("\u2705 Returning crudifyMethods:", {
|
|
1199
|
+
console.log("\u2705 Returning ready crudifyMethods:", {
|
|
1181
1200
|
hasLogin: typeof methods.login === "function",
|
|
1182
1201
|
hasTransaction: typeof methods.transaction === "function",
|
|
1202
|
+
isInitialized,
|
|
1183
1203
|
methods
|
|
1184
1204
|
});
|
|
1185
1205
|
return methods;
|
|
1186
|
-
}, [finalConfig.publicApiKey]);
|
|
1206
|
+
}, [finalConfig.publicApiKey, isInitialized]);
|
|
1187
1207
|
return { crudify: crudifyMethods };
|
|
1188
1208
|
};
|
|
1189
1209
|
|
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 React2, { useState as
|
|
6
|
+
import React2, { useState as useState7, 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
|
|
@@ -678,7 +678,7 @@ var ResetPasswordForm = ({ onNavigate, onError, searchParams, onResetSuccess, cr
|
|
|
678
678
|
crudifyKeys: crudify3 ? Object.keys(crudify3) : null
|
|
679
679
|
});
|
|
680
680
|
if (crudify3 && pendingValidation) {
|
|
681
|
-
console.log("\u{1F680} Crudify ready! Executing pending validation:", pendingValidation);
|
|
681
|
+
console.log("\u{1F680} Crudify verified ready! Executing pending validation:", pendingValidation);
|
|
682
682
|
console.log("\u{1F50D} Crudify object details:", {
|
|
683
683
|
hasTransaction: typeof crudify3.transaction === "function",
|
|
684
684
|
hasLogin: typeof crudify3.login === "function",
|
|
@@ -1063,7 +1063,7 @@ var CheckCodeForm = ({ onNavigate, onError, searchParams, crudify: crudify3 }) =
|
|
|
1063
1063
|
var CheckCodeForm_default = CheckCodeForm;
|
|
1064
1064
|
|
|
1065
1065
|
// src/components/CrudifyLogin/hooks/useCrudifyLogin.ts
|
|
1066
|
-
import { useMemo as useMemo2, useEffect as useEffect5 } from "react";
|
|
1066
|
+
import { useMemo as useMemo2, useEffect as useEffect5, useState as useState6 } from "react";
|
|
1067
1067
|
import crudify from "@nocios/crudify-browser";
|
|
1068
1068
|
|
|
1069
1069
|
// src/components/CrudifyLogin/utils/cookies.ts
|
|
@@ -1074,6 +1074,7 @@ var getCookie = (name) => {
|
|
|
1074
1074
|
|
|
1075
1075
|
// src/components/CrudifyLogin/hooks/useCrudifyLogin.ts
|
|
1076
1076
|
var useCrudifyLogin = (config, _options = {}) => {
|
|
1077
|
+
const [isInitialized, setIsInitialized] = useState6(false);
|
|
1077
1078
|
const finalConfig = useMemo2(() => {
|
|
1078
1079
|
const publicApiKey = config.publicApiKey || getCookie("publicApiKey") || null;
|
|
1079
1080
|
const rawEnv = config.env || getCookie("environment") || "prod";
|
|
@@ -1102,44 +1103,63 @@ var useCrudifyLogin = (config, _options = {}) => {
|
|
|
1102
1103
|
});
|
|
1103
1104
|
if (!finalConfig.publicApiKey) {
|
|
1104
1105
|
console.log("\u274C No publicApiKey, skipping crudify initialization");
|
|
1106
|
+
setIsInitialized(false);
|
|
1105
1107
|
return;
|
|
1106
1108
|
}
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1109
|
+
const initializeCrudify = async () => {
|
|
1110
|
+
try {
|
|
1111
|
+
console.log("\u2699\uFE0F Configuring crudify with env:", finalConfig.env);
|
|
1112
|
+
crudify.config(finalConfig.env);
|
|
1113
|
+
console.log("\u{1F680} Initializing crudify with publicApiKey:", finalConfig.publicApiKey.substring(0, 10) + "...");
|
|
1114
|
+
crudify.init(finalConfig.publicApiKey, "none");
|
|
1115
|
+
console.log("\u{1F9EA} Testing crudify initialization...");
|
|
1116
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
1117
|
+
if (typeof crudify.transaction === "function" && typeof crudify.login === "function") {
|
|
1118
|
+
console.log("\u2705 Crudify initialization verified and ready");
|
|
1119
|
+
setIsInitialized(true);
|
|
1120
|
+
} else {
|
|
1121
|
+
console.log("\u274C Crudify methods not properly initialized");
|
|
1122
|
+
setIsInitialized(false);
|
|
1123
|
+
}
|
|
1124
|
+
console.log("\u{1F50D} Crudify state after init:", {
|
|
1125
|
+
hasTransaction: typeof crudify.transaction === "function",
|
|
1126
|
+
hasLogin: typeof crudify.login === "function",
|
|
1127
|
+
isInitialized: true,
|
|
1128
|
+
crudifyObject: crudify
|
|
1129
|
+
});
|
|
1130
|
+
} catch (error) {
|
|
1131
|
+
console.error("\u274C Error initializing crudify:", error);
|
|
1132
|
+
setIsInitialized(false);
|
|
1133
|
+
}
|
|
1134
|
+
};
|
|
1135
|
+
initializeCrudify();
|
|
1121
1136
|
}, [finalConfig.publicApiKey, finalConfig.env]);
|
|
1122
1137
|
const crudifyMethods = useMemo2(() => {
|
|
1123
1138
|
console.log("\u{1F504} crudifyMethods useMemo triggered:", {
|
|
1124
1139
|
publicApiKey: !!finalConfig.publicApiKey,
|
|
1140
|
+
isInitialized,
|
|
1125
1141
|
crudifyLogin: typeof crudify.login,
|
|
1126
1142
|
crudifyTransaction: typeof crudify.transaction
|
|
1127
1143
|
});
|
|
1128
|
-
if (!finalConfig.publicApiKey) {
|
|
1129
|
-
console.log("\u274C
|
|
1144
|
+
if (!finalConfig.publicApiKey || !isInitialized) {
|
|
1145
|
+
console.log("\u274C Crudify not ready:", {
|
|
1146
|
+
publicApiKey: !!finalConfig.publicApiKey,
|
|
1147
|
+
isInitialized
|
|
1148
|
+
});
|
|
1130
1149
|
return null;
|
|
1131
1150
|
}
|
|
1132
1151
|
const methods = {
|
|
1133
1152
|
login: crudify.login,
|
|
1134
1153
|
transaction: crudify.transaction
|
|
1135
1154
|
};
|
|
1136
|
-
console.log("\u2705 Returning crudifyMethods:", {
|
|
1155
|
+
console.log("\u2705 Returning ready crudifyMethods:", {
|
|
1137
1156
|
hasLogin: typeof methods.login === "function",
|
|
1138
1157
|
hasTransaction: typeof methods.transaction === "function",
|
|
1158
|
+
isInitialized,
|
|
1139
1159
|
methods
|
|
1140
1160
|
});
|
|
1141
1161
|
return methods;
|
|
1142
|
-
}, [finalConfig.publicApiKey]);
|
|
1162
|
+
}, [finalConfig.publicApiKey, isInitialized]);
|
|
1143
1163
|
return { crudify: crudifyMethods };
|
|
1144
1164
|
};
|
|
1145
1165
|
|
|
@@ -1155,8 +1175,8 @@ var CrudifyLoginInternal = ({
|
|
|
1155
1175
|
autoReadFromCookies = true
|
|
1156
1176
|
}) => {
|
|
1157
1177
|
const { t } = useTranslation();
|
|
1158
|
-
const [currentScreen, setCurrentScreen] =
|
|
1159
|
-
const [searchParams, setSearchParams] =
|
|
1178
|
+
const [currentScreen, setCurrentScreen] = useState7(initialScreen);
|
|
1179
|
+
const [searchParams, setSearchParams] = useState7();
|
|
1160
1180
|
console.log("\u{1F504} CrudifyLoginInternal RENDER:", { currentScreen, initialScreen });
|
|
1161
1181
|
React2.useEffect(() => {
|
|
1162
1182
|
const urlParams = new URLSearchParams(window.location.search);
|
|
@@ -1344,7 +1364,7 @@ var CrudifyLogin = ({
|
|
|
1344
1364
|
var CrudifyLogin_default = CrudifyLogin;
|
|
1345
1365
|
|
|
1346
1366
|
// src/hooks/useUserProfile.ts
|
|
1347
|
-
import { useState as
|
|
1367
|
+
import { useState as useState8, useEffect as useEffect6, useCallback, useRef as useRef2 } from "react";
|
|
1348
1368
|
import crudify2 from "@nocios/crudify-browser";
|
|
1349
1369
|
|
|
1350
1370
|
// src/utils/jwtUtils.ts
|
|
@@ -1390,9 +1410,9 @@ var isTokenExpired = (token) => {
|
|
|
1390
1410
|
// src/hooks/useUserProfile.ts
|
|
1391
1411
|
var useUserProfile = (options = {}) => {
|
|
1392
1412
|
const { autoFetch = true, retryOnError = false, maxRetries = 3 } = options;
|
|
1393
|
-
const [userProfile, setUserProfile] =
|
|
1394
|
-
const [loading, setLoading] =
|
|
1395
|
-
const [error, setError] =
|
|
1413
|
+
const [userProfile, setUserProfile] = useState8(null);
|
|
1414
|
+
const [loading, setLoading] = useState8(false);
|
|
1415
|
+
const [error, setError] = useState8(null);
|
|
1396
1416
|
const abortControllerRef = useRef2(null);
|
|
1397
1417
|
const mountedRef = useRef2(true);
|
|
1398
1418
|
const requestIdRef = useRef2(0);
|