@asaleh37/ui-base 25.8.10-3 → 25.8.10-6
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 +6 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/components/common/NoLicenseComponent.tsx +42 -0
- package/src/layout/Layout.tsx +45 -11
- package/src/main.tsx +1 -1
- package/src/redux/features/common/AppInfoSlice.ts +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asaleh37/ui-base",
|
|
3
|
-
"version": "25.8.10-
|
|
3
|
+
"version": "25.8.10-6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "Ahmed Saleh Mohamed",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"stylis-plugin-rtl": "^2.1.1",
|
|
114
114
|
"zod": "^3.24.2"
|
|
115
115
|
},
|
|
116
|
-
"dependencies": {
|
|
116
|
+
"dependencies": {
|
|
117
117
|
"@rollup/plugin-json": "^6.1.0",
|
|
118
118
|
"rollup-plugin-terser": "^7.0.2"
|
|
119
119
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Box, Typography } from "@mui/material";
|
|
2
|
+
import {
|
|
3
|
+
AppInfo,
|
|
4
|
+
LicenseCheckObject,
|
|
5
|
+
} from "../../redux/features/common/AppInfoSlice";
|
|
6
|
+
import { useSelector } from "react-redux";
|
|
7
|
+
|
|
8
|
+
const NoLicenseComponent: React.FC<LicenseCheckObject> = (props) => {
|
|
9
|
+
const appInfo: AppInfo = useSelector((state: any) => state.AppInfo.value);
|
|
10
|
+
return (
|
|
11
|
+
<Box
|
|
12
|
+
sx={{
|
|
13
|
+
flex: 1,
|
|
14
|
+
width: "100%",
|
|
15
|
+
height: "100%",
|
|
16
|
+
display: "flex",
|
|
17
|
+
flexDirection: "column",
|
|
18
|
+
alignItems: "center",
|
|
19
|
+
justifyContent: "center",
|
|
20
|
+
}}
|
|
21
|
+
>
|
|
22
|
+
<img src={appInfo.appLogo} />
|
|
23
|
+
<Typography variant="h5">
|
|
24
|
+
{appInfo.appName} - {appInfo.appVersion}
|
|
25
|
+
</Typography>
|
|
26
|
+
<Typography variant="h6" color="error">
|
|
27
|
+
Your license is missing or has expired.
|
|
28
|
+
</Typography>
|
|
29
|
+
<Typography variant="h6" color="error">
|
|
30
|
+
Please reach out to your vendor for assistance.
|
|
31
|
+
</Typography>
|
|
32
|
+
<Typography>
|
|
33
|
+
License Check @{props?.lastLicenseCheckTime || "--------"}
|
|
34
|
+
</Typography>
|
|
35
|
+
<Typography>
|
|
36
|
+
License Check Result : {props?.lastLicenseCheckMessage || "--------"}
|
|
37
|
+
</Typography>
|
|
38
|
+
</Box>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default NoLicenseComponent;
|
package/src/layout/Layout.tsx
CHANGED
|
@@ -9,15 +9,17 @@ 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";
|
|
22
|
+
import NoLicenseComponent from "../components/common/NoLicenseComponent";
|
|
21
23
|
|
|
22
24
|
const Main = styled("main", {
|
|
23
25
|
shouldForwardProp: (prop) => prop !== "open",
|
|
@@ -59,11 +61,39 @@ const Main = styled("main", {
|
|
|
59
61
|
|
|
60
62
|
export default function Layout() {
|
|
61
63
|
const SideBarState = useSelector((state: any) => state.SideBar);
|
|
64
|
+
const [licenseCheckObj, setLicenseCheckObject] = useState<LicenseCheckObject>(
|
|
65
|
+
{ isLicensed: true, lastLicenseCheckMessage: "", lastLicenseCheckTime: "" }
|
|
66
|
+
);
|
|
62
67
|
const isMobile = useIsMobile();
|
|
68
|
+
const { handleGetRequest } = useAxios();
|
|
63
69
|
const UserSession: UserSessionProps = useSelector(
|
|
64
70
|
(state: any) => state.UserSession
|
|
65
71
|
);
|
|
72
|
+
const appInfo: AppInfo = useSelector((state: any) => state.AppInfo.value);
|
|
66
73
|
const AppLayout = useSelector((state: any) => state.AppLayout);
|
|
74
|
+
const checkSystemLicense = async () => {
|
|
75
|
+
if (appInfo?.checkLicense?.endpoint) {
|
|
76
|
+
await handleGetRequest({
|
|
77
|
+
endPointURI: appInfo.checkLicense?.endpoint,
|
|
78
|
+
successCallBkFn: (response) => {
|
|
79
|
+
setLicenseCheckObject(response.data);
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (appInfo?.checkLicense?.endpoint) {
|
|
87
|
+
const interval = appInfo?.checkLicense?.interval || 60000;
|
|
88
|
+
const intervalId = setInterval(() => {
|
|
89
|
+
checkSystemLicense();
|
|
90
|
+
}, interval);
|
|
91
|
+
return () => {
|
|
92
|
+
clearInterval(intervalId);
|
|
93
|
+
console.log("Interval cleared");
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}, [appInfo]);
|
|
67
97
|
|
|
68
98
|
return (
|
|
69
99
|
<BrowserRouter>
|
|
@@ -74,14 +104,18 @@ export default function Layout() {
|
|
|
74
104
|
/>
|
|
75
105
|
<LoadingMask />
|
|
76
106
|
{UserSession.value.isAuthenticated === true ? (
|
|
77
|
-
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
107
|
+
licenseCheckObj?.isLicensed ? (
|
|
108
|
+
<Main open={SideBarState.isOpened}>
|
|
109
|
+
<CssBaseline />
|
|
110
|
+
<TopBar />
|
|
111
|
+
{!isMobile ? <SideBar /> : null}
|
|
112
|
+
{isMobile ? <MobileDrawer /> : null}
|
|
113
|
+
<DrawerHeader />
|
|
114
|
+
<MainContent />
|
|
115
|
+
</Main>
|
|
116
|
+
) : (
|
|
117
|
+
<NoLicenseComponent {...licenseCheckObj} />
|
|
118
|
+
)
|
|
85
119
|
) : (
|
|
86
120
|
<Login />
|
|
87
121
|
)}
|
package/src/main.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRoot } from "react-dom/client";
|
|
2
2
|
import { BaseApp } from "./components";
|
|
3
3
|
|
|
4
|
-
|
|
5
4
|
createRoot(document.getElementById("root")!).render(
|
|
6
5
|
<BaseApp
|
|
7
6
|
apiBaseUrl="http://localhost:8080/api-base"
|
|
7
|
+
enableUINotifications={false}
|
|
8
8
|
appLogo={"/logo.png"}
|
|
9
9
|
appName="UI Base Library"
|
|
10
10
|
appVersion="0.0"
|
|
@@ -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 = {
|