@logickernel/bridge 0.9.0 → 0.9.1
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/README.md +29 -31
- package/dist/next/components.cjs +80 -6
- package/dist/next/components.cjs.map +1 -1
- package/dist/next/components.js +80 -6
- package/dist/next/components.js.map +1 -1
- package/package.json +1 -1
package/dist/next/components.js
CHANGED
|
@@ -1188,18 +1188,37 @@ function useNavigation({
|
|
|
1188
1188
|
const [loading, setLoading] = useState(false);
|
|
1189
1189
|
const [error, setError] = useState(null);
|
|
1190
1190
|
useEffect(() => {
|
|
1191
|
+
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
1192
|
+
console.log("[useNavigation] Hook called:", {
|
|
1193
|
+
enabled,
|
|
1194
|
+
organizationId,
|
|
1195
|
+
apiBaseUrl,
|
|
1196
|
+
willFetch: enabled && !!organizationId
|
|
1197
|
+
});
|
|
1198
|
+
}
|
|
1191
1199
|
if (!enabled || !organizationId) {
|
|
1200
|
+
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
1201
|
+
console.log("[useNavigation] Skipping fetch:", {
|
|
1202
|
+
reason: !enabled ? "disabled" : "no organizationId",
|
|
1203
|
+
enabled,
|
|
1204
|
+
organizationId
|
|
1205
|
+
});
|
|
1206
|
+
}
|
|
1192
1207
|
setItems([]);
|
|
1193
1208
|
setOrganizations([]);
|
|
1194
1209
|
setUser(null);
|
|
1195
1210
|
return;
|
|
1196
1211
|
}
|
|
1197
1212
|
const fetchNavigation = async () => {
|
|
1213
|
+
const url = `${apiBaseUrl}/navigation/${organizationId}`;
|
|
1214
|
+
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
1215
|
+
console.log("[useNavigation] Fetching navigation:", url);
|
|
1216
|
+
}
|
|
1198
1217
|
setLoading(true);
|
|
1199
1218
|
setError(null);
|
|
1200
1219
|
try {
|
|
1201
1220
|
const response = await fetch(
|
|
1202
|
-
|
|
1221
|
+
url,
|
|
1203
1222
|
{
|
|
1204
1223
|
credentials: "include"
|
|
1205
1224
|
// Include cookies for auth
|
|
@@ -1215,11 +1234,25 @@ function useNavigation({
|
|
|
1215
1234
|
throw new Error(`Failed to fetch navigation: ${response.statusText}`);
|
|
1216
1235
|
}
|
|
1217
1236
|
const data = await response.json();
|
|
1237
|
+
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
1238
|
+
console.log("[useNavigation] Navigation data received:", {
|
|
1239
|
+
itemsCount: data.items?.length || 0,
|
|
1240
|
+
organizationsCount: data.organizations?.length || 0,
|
|
1241
|
+
hasUser: !!data.user
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1218
1244
|
setItems(data.items || []);
|
|
1219
1245
|
setOrganizations(data.organizations || []);
|
|
1220
1246
|
setUser(data.user || null);
|
|
1221
1247
|
} catch (err) {
|
|
1222
1248
|
const error2 = err instanceof Error ? err : new Error("Unknown error");
|
|
1249
|
+
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
1250
|
+
console.error("[useNavigation] Fetch error:", {
|
|
1251
|
+
error: error2.message,
|
|
1252
|
+
url,
|
|
1253
|
+
organizationId
|
|
1254
|
+
});
|
|
1255
|
+
}
|
|
1223
1256
|
setError(error2);
|
|
1224
1257
|
setItems([]);
|
|
1225
1258
|
setOrganizations([]);
|
|
@@ -1239,19 +1272,60 @@ function AppSidebar({
|
|
|
1239
1272
|
...props
|
|
1240
1273
|
}) {
|
|
1241
1274
|
const currentPathname = usePathname();
|
|
1242
|
-
const pathSegments = currentPathname.split("/");
|
|
1243
|
-
|
|
1244
|
-
|
|
1275
|
+
const pathSegments = currentPathname.split("/").filter(Boolean);
|
|
1276
|
+
let pathOrgId = null;
|
|
1277
|
+
if (pathSegments.length >= 2 && pathSegments[0] === "app") {
|
|
1278
|
+
const potentialOrgId = pathSegments[1];
|
|
1279
|
+
if (potentialOrgId && potentialOrgId !== "user") {
|
|
1280
|
+
pathOrgId = potentialOrgId;
|
|
1281
|
+
}
|
|
1282
|
+
} else if (pathSegments.length >= 1) {
|
|
1283
|
+
const potentialOrgId = pathSegments[0];
|
|
1284
|
+
const skipSegments = ["user", "api", "auth", "dashboard", "settings", "app"];
|
|
1285
|
+
if (potentialOrgId && !skipSegments.includes(potentialOrgId)) {
|
|
1286
|
+
if (potentialOrgId.includes("-") || potentialOrgId.length >= 8) {
|
|
1287
|
+
pathOrgId = potentialOrgId;
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
const detectedOrgId = organizationId || pathOrgId || void 0;
|
|
1292
|
+
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
1293
|
+
console.log("[AppSidebar] Debug:", {
|
|
1294
|
+
currentPathname,
|
|
1295
|
+
pathSegments,
|
|
1296
|
+
pathOrgId,
|
|
1297
|
+
organizationId,
|
|
1298
|
+
detectedOrgId,
|
|
1299
|
+
apiBaseUrl
|
|
1300
|
+
});
|
|
1301
|
+
}
|
|
1245
1302
|
const {
|
|
1246
1303
|
items: apiNavigationItems,
|
|
1247
1304
|
organizations: apiOrganizations,
|
|
1248
1305
|
user: navigationUser,
|
|
1249
|
-
loading: navigationLoading
|
|
1306
|
+
loading: navigationLoading,
|
|
1307
|
+
error: navigationError
|
|
1250
1308
|
} = useNavigation({
|
|
1251
|
-
organizationId:
|
|
1309
|
+
organizationId: detectedOrgId,
|
|
1252
1310
|
apiBaseUrl,
|
|
1253
1311
|
enabled: true
|
|
1254
1312
|
});
|
|
1313
|
+
React2.useEffect(() => {
|
|
1314
|
+
if (process.env.NODE_ENV === "development") {
|
|
1315
|
+
console.log("[AppSidebar] Navigation state:", {
|
|
1316
|
+
currentPathname,
|
|
1317
|
+
pathOrgId,
|
|
1318
|
+
organizationId,
|
|
1319
|
+
detectedOrgId,
|
|
1320
|
+
apiBaseUrl,
|
|
1321
|
+
itemsCount: apiNavigationItems.length,
|
|
1322
|
+
organizationsCount: apiOrganizations.length,
|
|
1323
|
+
loading: navigationLoading,
|
|
1324
|
+
error: navigationError?.message,
|
|
1325
|
+
navigationUrl: detectedOrgId ? `${apiBaseUrl}/navigation/${detectedOrgId}` : "N/A"
|
|
1326
|
+
});
|
|
1327
|
+
}
|
|
1328
|
+
}, [currentPathname, pathOrgId, organizationId, detectedOrgId, apiBaseUrl, apiNavigationItems.length, apiOrganizations.length, navigationLoading, navigationError]);
|
|
1255
1329
|
const user = navigationUser || userProp;
|
|
1256
1330
|
const currentOrgId = organizationId || (pathOrgId && apiOrganizations.some((org) => org.id === pathOrgId) ? pathOrgId : void 0);
|
|
1257
1331
|
let navigationItems = apiNavigationItems;
|