@asaleh37/ui-base 25.8.10-6 → 25.8.10-7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asaleh37/ui-base",
3
- "version": "25.8.10-6",
3
+ "version": "25.8.10-7",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "Ahmed Saleh Mohamed",
@@ -4,10 +4,39 @@ import {
4
4
  LicenseCheckObject,
5
5
  } from "../../redux/features/common/AppInfoSlice";
6
6
  import { useSelector } from "react-redux";
7
+ import { useEffect, useState } from "react";
8
+ import { useAxios } from "../../hooks";
7
9
 
8
- const NoLicenseComponent: React.FC<LicenseCheckObject> = (props) => {
10
+ const NoLicenseComponent: React.FC = () => {
11
+ const [licenseCheckObj, setLicenseCheckObject] = useState<LicenseCheckObject>(
12
+ { isLicensed: true, lastLicenseCheckMessage: "", lastLicenseCheckTime: "" }
13
+ );
14
+ const { handleGetRequest } = useAxios();
9
15
  const appInfo: AppInfo = useSelector((state: any) => state.AppInfo.value);
10
- return (
16
+ const checkSystemLicense = async () => {
17
+ if (appInfo?.checkLicense?.endpoint) {
18
+ await handleGetRequest({
19
+ endPointURI: appInfo.checkLicense?.endpoint,
20
+ successCallBkFn: (response) => {
21
+ setLicenseCheckObject(response.data);
22
+ },
23
+ });
24
+ }
25
+ };
26
+
27
+ useEffect(() => {
28
+ if (appInfo?.checkLicense?.endpoint) {
29
+ const interval = appInfo?.checkLicense?.interval || 60000;
30
+ const intervalId = setInterval(() => {
31
+ checkSystemLicense();
32
+ }, interval);
33
+ return () => {
34
+ clearInterval(intervalId);
35
+ console.log("Interval cleared");
36
+ };
37
+ }
38
+ }, [appInfo]);
39
+ return !licenseCheckObj.isLicensed ? (
11
40
  <Box
12
41
  sx={{
13
42
  flex: 1,
@@ -17,6 +46,11 @@ const NoLicenseComponent: React.FC<LicenseCheckObject> = (props) => {
17
46
  flexDirection: "column",
18
47
  alignItems: "center",
19
48
  justifyContent: "center",
49
+ position: "fixed",
50
+ top: 0,
51
+ background: "rgba(235, 235, 235, 0.8)",
52
+ left: 0,
53
+ zIndex: 9999,
20
54
  }}
21
55
  >
22
56
  <img src={appInfo.appLogo} />
@@ -30,12 +64,15 @@ const NoLicenseComponent: React.FC<LicenseCheckObject> = (props) => {
30
64
  Please reach out to your vendor for assistance.
31
65
  </Typography>
32
66
  <Typography>
33
- License Check @{props?.lastLicenseCheckTime || "--------"}
67
+ License Check @{licenseCheckObj?.lastLicenseCheckTime || "--------"}
34
68
  </Typography>
35
69
  <Typography>
36
- License Check Result : {props?.lastLicenseCheckMessage || "--------"}
70
+ License Check Result :{" "}
71
+ {licenseCheckObj?.lastLicenseCheckMessage || "--------"}
37
72
  </Typography>
38
73
  </Box>
74
+ ) : (
75
+ <></>
39
76
  );
40
77
  };
41
78
 
@@ -8,17 +8,11 @@ import MainContent from "./MainContent";
8
8
  import { BrowserRouter } from "react-router-dom";
9
9
  import MobileDrawer from "./MobileDrawer";
10
10
  import { ToastContainer } from "react-toastify";
11
- import { useEffect, useState } from "react";
12
11
  import { useIsMobile } from "../hooks/UseMobile";
13
- import useAxios from "../hooks/useAxios";
14
12
  import { DRAWER_WIDTH } from "../redux/features/common/AppLayoutSlice";
15
13
  import { UserSessionProps } from "../redux/features/common/UserSessionSlice";
16
14
  import LoadingMask from "../components/common/LoadingMask";
17
15
  import Login from "../components/common/Login";
18
- import {
19
- AppInfo,
20
- LicenseCheckObject,
21
- } from "../redux/features/common/AppInfoSlice";
22
16
  import NoLicenseComponent from "../components/common/NoLicenseComponent";
23
17
 
24
18
  const Main = styled("main", {
@@ -61,40 +55,12 @@ const Main = styled("main", {
61
55
 
62
56
  export default function Layout() {
63
57
  const SideBarState = useSelector((state: any) => state.SideBar);
64
- const [licenseCheckObj, setLicenseCheckObject] = useState<LicenseCheckObject>(
65
- { isLicensed: true, lastLicenseCheckMessage: "", lastLicenseCheckTime: "" }
66
- );
58
+
67
59
  const isMobile = useIsMobile();
68
- const { handleGetRequest } = useAxios();
69
60
  const UserSession: UserSessionProps = useSelector(
70
61
  (state: any) => state.UserSession
71
62
  );
72
- const appInfo: AppInfo = useSelector((state: any) => state.AppInfo.value);
73
63
  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]);
97
-
98
64
  return (
99
65
  <BrowserRouter>
100
66
  <ToastContainer
@@ -104,18 +70,16 @@ export default function Layout() {
104
70
  />
105
71
  <LoadingMask />
106
72
  {UserSession.value.isAuthenticated === true ? (
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
- )
73
+ // licenseCheckObj?.isLicensed ? (
74
+ <Main open={SideBarState.isOpened}>
75
+ <CssBaseline />
76
+ <TopBar />
77
+ {!isMobile ? <SideBar /> : null}
78
+ {isMobile ? <MobileDrawer /> : null}
79
+ <DrawerHeader />
80
+ <MainContent />
81
+ <NoLicenseComponent />
82
+ </Main>
119
83
  ) : (
120
84
  <Login />
121
85
  )}