@asaleh37/ui-base 25.8.10-3 → 25.8.10-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/dist/index.d.ts +4 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/layout/Layout.tsx +44 -11
- package/src/main.tsx +1 -0
- package/src/redux/features/common/AppInfoSlice.ts +7 -0
package/package.json
CHANGED
package/src/layout/Layout.tsx
CHANGED
|
@@ -9,15 +9,16 @@ import { BrowserRouter } from "react-router-dom";
|
|
|
9
9
|
import MobileDrawer from "./MobileDrawer";
|
|
10
10
|
import { ToastContainer } from "react-toastify";
|
|
11
11
|
import { useEffect, useState } from "react";
|
|
12
|
-
import useLoadingMask from "../hooks/useLoadingMask";
|
|
13
12
|
import { useIsMobile } from "../hooks/UseMobile";
|
|
14
|
-
import useSession from "../hooks/UseSession";
|
|
15
13
|
import useAxios from "../hooks/useAxios";
|
|
16
14
|
import { DRAWER_WIDTH } from "../redux/features/common/AppLayoutSlice";
|
|
17
15
|
import { UserSessionProps } from "../redux/features/common/UserSessionSlice";
|
|
18
16
|
import LoadingMask from "../components/common/LoadingMask";
|
|
19
17
|
import Login from "../components/common/Login";
|
|
20
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
AppInfo,
|
|
20
|
+
LicenseCheckObject,
|
|
21
|
+
} from "../redux/features/common/AppInfoSlice";
|
|
21
22
|
|
|
22
23
|
const Main = styled("main", {
|
|
23
24
|
shouldForwardProp: (prop) => prop !== "open",
|
|
@@ -59,11 +60,39 @@ const Main = styled("main", {
|
|
|
59
60
|
|
|
60
61
|
export default function Layout() {
|
|
61
62
|
const SideBarState = useSelector((state: any) => state.SideBar);
|
|
63
|
+
const [licenseCheckObj, setLicenseCheckObject] = useState<LicenseCheckObject>(
|
|
64
|
+
{ isLicensed: true, lastLicenseCheckMessage: "", lastLicenseCheckTime: "" }
|
|
65
|
+
);
|
|
62
66
|
const isMobile = useIsMobile();
|
|
67
|
+
const { handleGetRequest } = useAxios();
|
|
63
68
|
const UserSession: UserSessionProps = useSelector(
|
|
64
69
|
(state: any) => state.UserSession
|
|
65
70
|
);
|
|
71
|
+
const appInfo: AppInfo = useSelector((state: any) => state.AppInfo.value);
|
|
66
72
|
const AppLayout = useSelector((state: any) => state.AppLayout);
|
|
73
|
+
const checkSystemLicense = async () => {
|
|
74
|
+
if (appInfo?.checkLicense?.endpoint) {
|
|
75
|
+
await handleGetRequest({
|
|
76
|
+
endPointURI: appInfo.checkLicense?.endpoint,
|
|
77
|
+
successCallBkFn: (response) => {
|
|
78
|
+
setLicenseCheckObject(response.data);
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (appInfo?.checkLicense?.endpoint) {
|
|
86
|
+
const interval = appInfo?.checkLicense?.interval || 60000;
|
|
87
|
+
const intervalId = setInterval(() => {
|
|
88
|
+
checkSystemLicense();
|
|
89
|
+
}, interval);
|
|
90
|
+
return () => {
|
|
91
|
+
clearInterval(intervalId);
|
|
92
|
+
console.log("Interval cleared");
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}, []);
|
|
67
96
|
|
|
68
97
|
return (
|
|
69
98
|
<BrowserRouter>
|
|
@@ -74,14 +103,18 @@ export default function Layout() {
|
|
|
74
103
|
/>
|
|
75
104
|
<LoadingMask />
|
|
76
105
|
{UserSession.value.isAuthenticated === true ? (
|
|
77
|
-
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
106
|
+
licenseCheckObj?.isLicensed ? (
|
|
107
|
+
<Main open={SideBarState.isOpened}>
|
|
108
|
+
<CssBaseline />
|
|
109
|
+
<TopBar />
|
|
110
|
+
{!isMobile ? <SideBar /> : null}
|
|
111
|
+
{isMobile ? <MobileDrawer /> : null}
|
|
112
|
+
<DrawerHeader />
|
|
113
|
+
<MainContent />
|
|
114
|
+
</Main>
|
|
115
|
+
) : (
|
|
116
|
+
<>Your licsense has been expired</>
|
|
117
|
+
)
|
|
85
118
|
) : (
|
|
86
119
|
<Login />
|
|
87
120
|
)}
|
package/src/main.tsx
CHANGED
|
@@ -3,6 +3,12 @@ import { SystemRoute } from "../../../routes/types";
|
|
|
3
3
|
import { ExtendedTreeItemProps } from "../../../navigationItems";
|
|
4
4
|
import { StoreMetaData } from "./CommonStoreSlice";
|
|
5
5
|
|
|
6
|
+
export type LicenseCheckObject = {
|
|
7
|
+
isLicensed: boolean;
|
|
8
|
+
lastLicenseCheckMessage: string;
|
|
9
|
+
lastLicenseCheckTime: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
6
12
|
export type AppInfo = {
|
|
7
13
|
documentTitle: string | null;
|
|
8
14
|
apiBaseUrl: string | null;
|
|
@@ -24,6 +30,7 @@ export type AppInfo = {
|
|
|
24
30
|
light: { primaryColor: string; secondaryColor: string };
|
|
25
31
|
dark: { primaryColor: string; secondaryColor: string };
|
|
26
32
|
};
|
|
33
|
+
checkLicense?: { endpoint: string; interval: number };
|
|
27
34
|
};
|
|
28
35
|
|
|
29
36
|
export type AppInfoProp = {
|