@asaleh37/ui-base 25.8.10 → 25.8.15

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",
3
+ "version": "25.8.15",
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
  }
@@ -126,6 +126,13 @@ const Login: React.FC = () => {
126
126
  useEffect(() => {
127
127
  checkUserSession();
128
128
  }, [appInfo]);
129
+
130
+ useEffect(() => {
131
+ if (userSession.isAuthenticated === null) {
132
+ console.log("checking usersession on reload", userSession);
133
+ checkUserSession();
134
+ }
135
+ }, [userSession.isAuthenticated]);
129
136
  return (
130
137
  <ThemeProvider theme={loginTheme}>
131
138
  <Paper
@@ -0,0 +1,79 @@
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
+ import { useEffect, useState } from "react";
8
+ import { useAxios } from "../../hooks";
9
+
10
+ const NoLicenseComponent: React.FC = () => {
11
+ const [licenseCheckObj, setLicenseCheckObject] = useState<LicenseCheckObject>(
12
+ { isLicensed: true, lastLicenseCheckMessage: "", lastLicenseCheckTime: "" }
13
+ );
14
+ const { handleGetRequest } = useAxios();
15
+ const appInfo: AppInfo = useSelector((state: any) => state.AppInfo.value);
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 ? (
40
+ <Box
41
+ sx={{
42
+ flex: 1,
43
+ width: "100%",
44
+ height: "100%",
45
+ display: "flex",
46
+ flexDirection: "column",
47
+ alignItems: "center",
48
+ justifyContent: "center",
49
+ position: "fixed",
50
+ top: 0,
51
+ background: "rgba(235, 235, 235, 0.8)",
52
+ left: 0,
53
+ zIndex: 9999,
54
+ }}
55
+ >
56
+ <img src={appInfo.appLogo} style={{ height: 200, width: 200 }} />
57
+ <Typography variant="h5">
58
+ {appInfo.appName} - {appInfo.appVersion}
59
+ </Typography>
60
+ <Typography variant="h6" color="error">
61
+ Your license is missing or has expired.
62
+ </Typography>
63
+ <Typography variant="h6" color="error">
64
+ Please reach out to your vendor for assistance.
65
+ </Typography>
66
+ <Typography>
67
+ License Check @{licenseCheckObj?.lastLicenseCheckTime || "--------"}
68
+ </Typography>
69
+ <Typography>
70
+ License Check Result :{" "}
71
+ {licenseCheckObj?.lastLicenseCheckMessage || "--------"}
72
+ </Typography>
73
+ </Box>
74
+ ) : (
75
+ <></>
76
+ );
77
+ };
78
+
79
+ export default NoLicenseComponent;
@@ -57,6 +57,19 @@ const useAxios = () => {
57
57
  toast.error("your session is now expired, you need to login again", {
58
58
  autoClose: false,
59
59
  });
60
+ } else if (
61
+ error
62
+ ? error.response
63
+ ? error.response.status
64
+ ? error.response.status === 402
65
+ : false
66
+ : false
67
+ : false
68
+ ) {
69
+ dispatch(UserSessionActions.setUnAuthenticated());
70
+ toast.error(
71
+ "Your license is missing or has expired,Please reach out to your vendor for assistance."
72
+ );
60
73
  } else if (
61
74
  error
62
75
  ? error.response
@@ -8,16 +8,12 @@ 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
- import useLoadingMask from "../hooks/useLoadingMask";
13
11
  import { useIsMobile } from "../hooks/UseMobile";
14
- import useSession from "../hooks/UseSession";
15
- import useAxios from "../hooks/useAxios";
16
12
  import { DRAWER_WIDTH } from "../redux/features/common/AppLayoutSlice";
17
13
  import { UserSessionProps } from "../redux/features/common/UserSessionSlice";
18
14
  import LoadingMask from "../components/common/LoadingMask";
19
15
  import Login from "../components/common/Login";
20
- import { setStoreData } from "../redux/features/common/CommonStoreSlice";
16
+ import NoLicenseComponent from "../components/common/NoLicenseComponent";
21
17
 
22
18
  const Main = styled("main", {
23
19
  shouldForwardProp: (prop) => prop !== "open",
@@ -59,12 +55,12 @@ const Main = styled("main", {
59
55
 
60
56
  export default function Layout() {
61
57
  const SideBarState = useSelector((state: any) => state.SideBar);
58
+
62
59
  const isMobile = useIsMobile();
63
60
  const UserSession: UserSessionProps = useSelector(
64
61
  (state: any) => state.UserSession
65
62
  );
66
63
  const AppLayout = useSelector((state: any) => state.AppLayout);
67
-
68
64
  return (
69
65
  <BrowserRouter>
70
66
  <ToastContainer
@@ -74,6 +70,7 @@ export default function Layout() {
74
70
  />
75
71
  <LoadingMask />
76
72
  {UserSession.value.isAuthenticated === true ? (
73
+ // licenseCheckObj?.isLicensed ? (
77
74
  <Main open={SideBarState.isOpened}>
78
75
  <CssBaseline />
79
76
  <TopBar />
@@ -81,6 +78,7 @@ export default function Layout() {
81
78
  {isMobile ? <MobileDrawer /> : null}
82
79
  <DrawerHeader />
83
80
  <MainContent />
81
+ <NoLicenseComponent />
84
82
  </Main>
85
83
  ) : (
86
84
  <Login />
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"
@@ -17,7 +17,7 @@ export const adminNavigationItems: TreeViewBaseItem<ExtendedTreeItemProps>[] = [
17
17
  actionPayload: { path: "admin/persons" },
18
18
  },
19
19
  {
20
- id: "system_admin.devtools.roles",
20
+ id: "system_admin.devtools.rolesx",
21
21
  label: "ROLES",
22
22
  icon: "tag",
23
23
  action: "NAVIGATION",
@@ -200,7 +200,7 @@ export const adminNavigationItems: TreeViewBaseItem<ExtendedTreeItemProps>[] = [
200
200
  {
201
201
  id: "system_admin.followup",
202
202
  label: "SYSTEM_MONITORING",
203
- authority: "SYSTEM_ADMIN",
203
+ authority: "DEVELOPMENT_ADMIN",
204
204
  icon: "tv",
205
205
  children: [
206
206
  {
@@ -130,19 +130,19 @@ export const ADMINISTRATION_STORES: CommonStores = {
130
130
  SystemApplicationModules: {
131
131
  autoLoad: true,
132
132
  data: [],
133
- authority: "DEVELOPMENT_ADMIN",
133
+ authority: "SYSTEM_ADMIN",
134
134
  url: "api/v1/admin/systemapplicationmodule/application/all",
135
135
  },
136
136
  SystemApplicationAuthorities: {
137
137
  autoLoad: true,
138
138
  data: [],
139
- authority: "DEVELOPMENT_ADMIN",
139
+ authority: "SYSTEM_ADMIN",
140
140
  url: "api/v1/admin/systemapplicationauthority/all",
141
141
  },
142
142
  SystemApplicationRoles: {
143
143
  autoLoad: true,
144
144
  data: [],
145
- authority: "DEVELOPMENT_ADMIN",
145
+ authority: "SYSTEM_ADMIN",
146
146
  url: "api/v1/admin/systemapplicationrole/all",
147
147
  },
148
148
  };
@@ -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 = {
package/tsconfig.json CHANGED
@@ -131,5 +131,5 @@
131
131
  "noEmit": true,
132
132
  "jsx": "react-jsx"
133
133
  },
134
- "include": ["src"]
134
+ "include": ["src"]
135
135
  }