@intra-mart/smartlime 1.4.3-dev.20240612 → 1.4.4
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/lib/packages/Tenant/index.js +12 -12
- package/package.json +1 -1
|
@@ -14,7 +14,7 @@ const useGetTenantId = (tenantId) => {
|
|
|
14
14
|
const createInitFetchModuleState = (useModuleInfo) => {
|
|
15
15
|
return useModuleInfo ? 'notFetched' : 'notRequired';
|
|
16
16
|
};
|
|
17
|
-
const
|
|
17
|
+
const createStorageKey = (baseUrl, moduleKey) => {
|
|
18
18
|
return `${baseUrl}_${moduleKey}`;
|
|
19
19
|
};
|
|
20
20
|
const saveModuleInfoStorage = async (storageKey, ModuleInfo) => {
|
|
@@ -44,7 +44,7 @@ const useFetchModuleStateRef = (renderTarget, useModuleInfo) => {
|
|
|
44
44
|
const getter = useCallback(() => ref.current, []);
|
|
45
45
|
return [ref, setter, getter];
|
|
46
46
|
};
|
|
47
|
-
const useModuleInfoRef = (
|
|
47
|
+
const useModuleInfoRef = (baseUrl, fetchModuleStateSetter, useModuleInfo) => {
|
|
48
48
|
const ref = useRef();
|
|
49
49
|
const setter = useCallback((state, silent) => {
|
|
50
50
|
if (!useModuleInfo)
|
|
@@ -53,28 +53,28 @@ const useModuleInfoRef = (getBaseUrl, fetchModuleStateSetter, useModuleInfo) =>
|
|
|
53
53
|
return;
|
|
54
54
|
ref.current = state;
|
|
55
55
|
fetchModuleStateSetter('fetched', silent);
|
|
56
|
-
}, []);
|
|
56
|
+
}, [fetchModuleStateSetter, useModuleInfo]);
|
|
57
57
|
const getter = useCallback(() => ref.current, []);
|
|
58
58
|
const destroy = useCallback(async () => {
|
|
59
59
|
for (let i = 0; i < MODULE_IDS.length; i++) {
|
|
60
60
|
const key = MODULE_IDS[i];
|
|
61
61
|
if (key) {
|
|
62
|
-
const storageKey =
|
|
62
|
+
const storageKey = createStorageKey(baseUrl, key);
|
|
63
63
|
await deleteModuleInfoStorage(storageKey);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
ref.current = undefined;
|
|
67
67
|
fetchModuleStateSetter('notFetched');
|
|
68
|
-
}, []);
|
|
68
|
+
}, [fetchModuleStateSetter, baseUrl]);
|
|
69
69
|
return [ref, setter, getter, destroy];
|
|
70
70
|
};
|
|
71
|
-
const
|
|
71
|
+
const createCheckHybridSSOUrl = (baseUrl) => {
|
|
72
72
|
return join(baseUrl, '/im_hybrid_sso/logout');
|
|
73
73
|
};
|
|
74
|
-
const useFetchModuleInfo = (
|
|
75
|
-
const hybridSSOUrl = useCheckHybridSSOUrl(getBaseUrl());
|
|
74
|
+
const useFetchModuleInfo = (baseUrl, setModuleInfo) => {
|
|
76
75
|
return useCallback(async () => {
|
|
77
|
-
const
|
|
76
|
+
const hybridSSOUrl = createCheckHybridSSOUrl(baseUrl);
|
|
77
|
+
const storageKey = createStorageKey(baseUrl, HYBRID_SSO_KEY);
|
|
78
78
|
const storageState = await getModuleInfoStorage(storageKey);
|
|
79
79
|
if (storageState) {
|
|
80
80
|
setModuleInfo({
|
|
@@ -92,7 +92,7 @@ const useFetchModuleInfo = (getBaseUrl, setModuleInfo) => {
|
|
|
92
92
|
saveModuleInfoStorage(storageKey, state);
|
|
93
93
|
setModuleInfo({ [HYBRID_SSO_KEY]: state });
|
|
94
94
|
}
|
|
95
|
-
}, [setModuleInfo]);
|
|
95
|
+
}, [setModuleInfo, baseUrl]);
|
|
96
96
|
};
|
|
97
97
|
export const IMTenant = ({ children, baseUrl, tenantId, tenantContext, useModuleInfo, }) => {
|
|
98
98
|
const Context = tenantContext || DefaultContext;
|
|
@@ -101,8 +101,8 @@ export const IMTenant = ({ children, baseUrl, tenantId, tenantContext, useModule
|
|
|
101
101
|
const getBaseUrl = useGetBaseUrl(baseUrl);
|
|
102
102
|
const getTenantId = useGetTenantId(tenantId);
|
|
103
103
|
const [, setFetchModuleState, getFetchModuleState] = useFetchModuleStateRef(modulesStateRenderTarget, useModuleInfo);
|
|
104
|
-
const [, setModuleInfo, getModuleInfo, destroyModuleInfo] = useModuleInfoRef(
|
|
105
|
-
const fetchModuleInfo = useFetchModuleInfo(
|
|
104
|
+
const [, setModuleInfo, getModuleInfo, destroyModuleInfo] = useModuleInfoRef(baseUrl, setFetchModuleState, useModuleInfo);
|
|
105
|
+
const fetchModuleInfo = useFetchModuleInfo(baseUrl, setModuleInfo);
|
|
106
106
|
saveModuleInfoStorage;
|
|
107
107
|
contextRef.current = {
|
|
108
108
|
getBaseUrl,
|