@erpsquad/common 1.8.146 → 1.8.148
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/constants/index.esm.js +12271 -10
- package/dist/constants/index.esm.js.map +1 -1
- package/dist/constants/index.js +1 -1
- package/dist/constants/index.js.map +1 -1
- package/dist/hooks/index.esm.js +38 -32
- package/dist/hooks/index.esm.js.map +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.esm.js +1 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{migration-utils--ZDLIXHX.esm.js → migration-utils-hV41wEaX.esm.js} +3 -3
- package/dist/migration-utils-hV41wEaX.esm.js.map +1 -0
- package/dist/migration-utils-t8N4H56x.js +6 -0
- package/dist/migration-utils-t8N4H56x.js.map +1 -0
- package/dist/utils/index.esm.js +1 -2
- package/dist/utils/index.esm.js.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/migration-utils--ZDLIXHX.esm.js.map +0 -1
- package/dist/migration-utils-e8WoiOOR.js +0 -6
- package/dist/migration-utils-e8WoiOOR.js.map +0 -1
- package/dist/resource-lang-DGLkQTMh.js +0 -2
- package/dist/resource-lang-DGLkQTMh.js.map +0 -1
- package/dist/resource-lang-aiXJhRQt.esm.js +0 -12269
- package/dist/resource-lang-aiXJhRQt.esm.js.map +0 -1
package/dist/hooks/index.esm.js
CHANGED
|
@@ -4,7 +4,7 @@ import _ from "lodash";
|
|
|
4
4
|
import { getCountries } from "libphonenumber-js";
|
|
5
5
|
import { u, c, d, a, b } from "../useLocationFilter-D57qqjeN.esm.js";
|
|
6
6
|
import { useMemo, useState, useEffect, useCallback } from "react";
|
|
7
|
-
import { useTranslation } from "react-i18next";
|
|
7
|
+
import { getI18n, useTranslation } from "react-i18next";
|
|
8
8
|
import { useTranslation as useTranslation2 } from "react-i18next";
|
|
9
9
|
import { l as loadModuleTranslations } from "../translations-BLI-qNqf.esm.js";
|
|
10
10
|
import { m as modules } from "../modules-CjfmbQNF.esm.js";
|
|
@@ -403,46 +403,52 @@ let globalInitialLoad = true;
|
|
|
403
403
|
const useAppTranslations = () => {
|
|
404
404
|
const [isLoading, setIsLoading] = useState(globalInitialLoad);
|
|
405
405
|
const location = window.location;
|
|
406
|
+
const i18nInstance = getI18n();
|
|
407
|
+
const { user, loading } = useAuth();
|
|
408
|
+
console.log("🚀 ~ useAppTranslations ~ location.pathname:: >>", location.pathname);
|
|
406
409
|
const { t } = useTranslation();
|
|
407
410
|
useEffect(() => {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
(
|
|
412
|
-
|
|
413
|
-
|
|
411
|
+
if ((user == null ? void 0 : user.id) && !loading) {
|
|
412
|
+
const erpModules = modules(t);
|
|
413
|
+
const currentPath = location.pathname.toLowerCase();
|
|
414
|
+
console.log("🚀 ~ useAppTranslations ~ currentPath:: >>", currentPath);
|
|
415
|
+
const matchedModule = erpModules.find(
|
|
416
|
+
(mod) => {
|
|
417
|
+
var _a;
|
|
418
|
+
return mod.link.toLowerCase() === currentPath || ((_a = mod.connectedRoutes) == null ? void 0 : _a.some((route) => currentPath.startsWith(route.toLowerCase())));
|
|
419
|
+
}
|
|
420
|
+
);
|
|
421
|
+
let modulesToLoad = [];
|
|
422
|
+
if (matchedModule == null ? void 0 : matchedModule.translationModule) {
|
|
423
|
+
modulesToLoad = [...matchedModule.translationModule, "common"];
|
|
424
|
+
} else if (!matchedModule && currentPath === "/dashboard") {
|
|
425
|
+
modulesToLoad = ["common"];
|
|
414
426
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
427
|
+
if (modulesToLoad.length > 0) {
|
|
428
|
+
const moduleKey = [...modulesToLoad].sort().join(",");
|
|
429
|
+
if (globalLastLoadedModules === moduleKey || globalIsLoading) {
|
|
430
|
+
if (globalInitialLoad) {
|
|
431
|
+
setIsLoading(false);
|
|
432
|
+
globalInitialLoad = false;
|
|
433
|
+
}
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
globalIsLoading = true;
|
|
437
|
+
globalLastLoadedModules = moduleKey;
|
|
438
|
+
setIsLoading(true);
|
|
439
|
+
loadModuleTranslations(modulesToLoad, i18nInstance).finally(() => {
|
|
440
|
+
globalIsLoading = false;
|
|
441
|
+
setIsLoading(false);
|
|
442
|
+
globalInitialLoad = false;
|
|
443
|
+
});
|
|
444
|
+
} else {
|
|
425
445
|
if (globalInitialLoad) {
|
|
426
446
|
setIsLoading(false);
|
|
427
447
|
globalInitialLoad = false;
|
|
428
448
|
}
|
|
429
|
-
return;
|
|
430
|
-
}
|
|
431
|
-
globalIsLoading = true;
|
|
432
|
-
globalLastLoadedModules = moduleKey;
|
|
433
|
-
setIsLoading(true);
|
|
434
|
-
loadModuleTranslations(modulesToLoad).finally(() => {
|
|
435
|
-
globalIsLoading = false;
|
|
436
|
-
setIsLoading(false);
|
|
437
|
-
globalInitialLoad = false;
|
|
438
|
-
});
|
|
439
|
-
} else {
|
|
440
|
-
if (globalInitialLoad) {
|
|
441
|
-
setIsLoading(false);
|
|
442
|
-
globalInitialLoad = false;
|
|
443
449
|
}
|
|
444
450
|
}
|
|
445
|
-
}, [location.pathname, t]);
|
|
451
|
+
}, [location.pathname, t, user, loading, i18nInstance]);
|
|
446
452
|
return { isLoading };
|
|
447
453
|
};
|
|
448
454
|
const useNameSkuUniquenessCheck = ({
|