@asaleh37/ui-base 1.2.3 → 1.2.5
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 +20 -13
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -3
- package/src/components/App.tsx +1 -1
- package/src/components/BaseApp.tsx +2 -19
- package/src/components/administration/admin/OrgMemberRoleForm.tsx +83 -0
- package/src/components/administration/admin/OrganizationApplicationModuleGrid.tsx +131 -0
- package/src/components/administration/admin/OrganizationGrid.tsx +165 -0
- package/src/components/administration/admin/OrganizationMemberGrid.tsx +176 -0
- package/src/components/administration/admin/OrganizationMemberRoleGrid.tsx +87 -0
- package/src/components/{admin → administration/admin}/OrganizationRankGrid.tsx +49 -19
- package/src/components/administration/admin/OrganizationUnitGrid.tsx +139 -0
- package/src/components/administration/admin/OrganizationUnitTypeGrid.tsx +121 -0
- package/src/components/administration/admin/PersonGrid.tsx +195 -0
- package/src/components/{admin → administration/admin}/RoleAuthoritiesForm.tsx +30 -11
- package/src/components/administration/admin/SystemApplicationAuthorityGrid.tsx +142 -0
- package/src/components/administration/admin/SystemApplicationGrid.tsx +161 -0
- package/src/components/administration/admin/SystemApplicationModuleGrid.tsx +109 -0
- package/src/components/administration/admin/SystemApplicationRoleAuthorityGrid.tsx +67 -0
- package/src/components/administration/admin/SystemApplicationRoleGrid.tsx +130 -0
- package/src/components/administration/dev/BluePrintGrid.tsx +129 -0
- package/src/components/administration/dev/DashboardGrid.tsx +173 -0
- package/src/components/administration/dev/DashboardWidgetGrid.tsx +164 -0
- package/src/components/administration/dev/DataQueryGrid.tsx +206 -0
- package/src/components/administration/dev/DataQueryParameterGrid.tsx +191 -0
- package/src/components/administration/dev/DataQueryParametersForm.tsx +84 -0
- package/src/components/administration/dev/DatasourceConnectionGrid.tsx +150 -0
- package/src/components/administration/dev/EntityParameterGrid.tsx +279 -0
- package/src/components/administration/dev/LookupGrid.tsx +131 -0
- package/src/components/administration/dev/MailAttachmentGrid.tsx +155 -0
- package/src/components/administration/dev/MailBodyGrid.tsx +215 -0
- package/src/components/{admin → administration/dev}/MailNotificationQueueGrid.tsx +114 -26
- package/src/components/administration/dev/MailRecipientGrid.tsx +169 -0
- package/src/components/administration/dev/MailSenderConfigGrid.tsx +478 -0
- package/src/components/administration/dev/MailTemplateGrid.tsx +388 -0
- package/src/components/administration/dev/ReportGrid.tsx +504 -0
- package/src/components/administration/dev/ReportParameterGrid.tsx +186 -0
- package/src/components/administration/dev/ReportParametersForm.tsx +84 -0
- package/src/components/administration/dev/WidgetGrid.tsx +431 -0
- package/src/components/administration/dev/WorkflowDocumentActionGrid.tsx +264 -0
- package/src/components/administration/dev/WorkflowDocumentActionHistoryGrid.tsx +172 -0
- package/src/components/administration/dev/WorkflowDocumentActionMailGrid.tsx +161 -0
- package/src/components/administration/dev/WorkflowDocumentGrid.tsx +377 -0
- package/src/components/{admin → administration/dev}/WorkflowDocumentMailLogGrid.tsx +87 -10
- package/src/components/administration/dev/WorkflowDocumentStatusGrid.tsx +243 -0
- package/src/components/common/ChangeOrgForm.tsx +81 -0
- package/src/components/common/Home.tsx +28 -22
- package/src/components/common/LoadingMask.tsx +9 -4
- package/src/components/common/Login.tsx +9 -13
- package/src/components/templates/DataEntryTemplates/DataEntryTypes.ts +30 -6
- package/src/components/templates/DataEntryTemplates/DataEntryUtil.ts +46 -5
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormElementField.tsx +64 -5
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormElementGroup.tsx +11 -3
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/CheckBox.tsx +2 -2
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/ComboBox.tsx +1 -2
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/HtmlEditor.tsx +144 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/SystemLookupCombobox.tsx +55 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/TemplateTextField.tsx +9 -1
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/TemplateForm.tsx +45 -5
- package/src/components/templates/DataEntryTemplates/TemplateDataGrid/DataGridColumnsUtil.tsx +8 -7
- package/src/components/templates/DataEntryTemplates/TemplateDataGrid/TemplateGrid.tsx +38 -10
- package/src/components/templates/DataEntryTemplates/TemplateDataGrid/TemplateGridRecordAction.tsx +4 -1
- package/src/components/templates/DataEntryTemplates/TemplateDataGrid/TemplateGridTopBar.tsx +3 -4
- package/src/components/templates/TransferList.tsx +16 -6
- package/src/components/templates/index.ts +0 -2
- package/src/components/templates/report/ExcelReportViewer.tsx +65 -0
- package/src/components/templates/report/ReportViewer.tsx +382 -0
- package/src/components/templates/visuals/DashboardRouteView.tsx +9 -0
- package/src/components/templates/visuals/DashboardViewer.tsx +148 -0
- package/src/components/templates/visuals/WidgetViewer.tsx +198 -0
- package/src/components/templates/visuals/charts/TemplateBarChart.tsx +9 -2
- package/src/components/templates/visuals/charts/TemplateDataCard.tsx +6 -31
- package/src/components/templates/visuals/charts/TemplateGauge.tsx +8 -3
- package/src/components/templates/visuals/charts/TemplateLineChart.tsx +8 -2
- package/src/components/templates/visuals/charts/TemplateLineProgress.tsx +5 -3
- package/src/components/templates/visuals/charts/TemplatePieChart.tsx +1 -2
- package/src/components/templates/workflow/WorkflowDocumentPanel.tsx +581 -0
- package/src/components/templates/workflow/WorkflowDocumentTimeLine.tsx +134 -0
- package/src/hooks/UseSession.tsx +3 -7
- package/src/hooks/UseWindow.tsx +2 -1
- package/src/hooks/useAxios.tsx +9 -27
- package/src/hooks/useLookupGridColumn.tsx +35 -0
- package/src/layout/Layout.tsx +2 -46
- package/src/layout/MainContent.tsx +60 -7
- package/src/layout/MobileDrawer.tsx +5 -5
- package/src/layout/NavigationTree.tsx +0 -1
- package/src/layout/RouteWrapper.tsx +36 -0
- package/src/layout/SideBar.tsx +15 -10
- package/src/layout/TopBar.tsx +139 -71
- package/src/locales/arabic/adminLocalsAr.json +81 -344
- package/src/locales/arabic/common.json +11 -1
- package/src/locales/arabic/devLocalsAr.json +280 -0
- package/src/locales/arabic/index.ts +2 -0
- package/src/locales/english/adminLocalsEn.json +86 -346
- package/src/locales/english/common.json +11 -1
- package/src/locales/english/devLocalsEn.json +281 -0
- package/src/locales/english/index.ts +3 -0
- package/src/main.tsx +5 -6
- package/src/navigationItems/Administration/adminNavigationItems.tsx +65 -99
- package/src/navigationItems/Administration/index.tsx +10 -65
- package/src/redux/features/administration/AdministrationStoresMetaData.ts +45 -12
- package/src/redux/features/common/AppLayoutSlice.ts +0 -8
- package/src/redux/features/common/CommonStoreSlice.ts +4 -0
- package/src/redux/features/common/SideBarSlice.ts +29 -0
- package/src/redux/features/common/UserSessionSlice.ts +15 -23
- package/src/redux/store.ts +1 -1
- package/src/routes/administration/adminRoutes.tsx +41 -222
- package/src/routes/administration/devRoutes.tsx +90 -0
- package/src/routes/administration/index.ts +5 -1
- package/src/routes/index.ts +1 -0
- package/src/styles/index.css +3 -3
- package/src/util/AppUtils.ts +5 -0
- package/vite.config.ts +14 -0
- package/src/components/admin/AttachmentGrid.tsx +0 -116
- package/src/components/admin/AuthorityGrid.tsx +0 -88
- package/src/components/admin/BluePrintGrid.tsx +0 -55
- package/src/components/admin/BluePrintPageGrid.tsx +0 -85
- package/src/components/admin/BluePrintPointGrid.tsx +0 -85
- package/src/components/admin/DashboardGrid.tsx +0 -95
- package/src/components/admin/DashboardWidgetGrid.tsx +0 -75
- package/src/components/admin/DataQueryGrid.tsx +0 -75
- package/src/components/admin/DataQueryParameterGrid.tsx +0 -98
- package/src/components/admin/DatasourceConnectionGrid.tsx +0 -98
- package/src/components/admin/EmployeeGrid.tsx +0 -105
- package/src/components/admin/EntityParameterGrid.tsx +0 -125
- package/src/components/admin/ExcelUploaderDetailGrid.tsx +0 -78
- package/src/components/admin/ExcelUploaderHeaderGrid.tsx +0 -78
- package/src/components/admin/LookupGrid.tsx +0 -95
- package/src/components/admin/MailAttachmentGrid.tsx +0 -65
- package/src/components/admin/MailBodyGrid.tsx +0 -105
- package/src/components/admin/MailRecipientGrid.tsx +0 -75
- package/src/components/admin/MailTemplateGrid.tsx +0 -145
- package/src/components/admin/NewTableGrid.tsx +0 -65
- package/src/components/admin/NotificationGrid.tsx +0 -115
- package/src/components/admin/NotificationQueueGrid.tsx +0 -125
- package/src/components/admin/OrganizationApplicationGrid.tsx +0 -81
- package/src/components/admin/OrganizationGrid.tsx +0 -65
- package/src/components/admin/OrganizationUnitGrid.tsx +0 -85
- package/src/components/admin/OrganizationUserGrid.tsx +0 -75
- package/src/components/admin/OrganizationUserRoleGrid.tsx +0 -98
- package/src/components/admin/ReportGrid.tsx +0 -155
- package/src/components/admin/ReportParameterGrid.tsx +0 -95
- package/src/components/admin/RoleAuthorityGrid.tsx +0 -65
- package/src/components/admin/RoleGrid.tsx +0 -132
- package/src/components/admin/UserAccountGrid.tsx +0 -65
- package/src/components/admin/UserRequestGrid.tsx +0 -145
- package/src/components/admin/WidgetGrid.tsx +0 -175
- package/src/components/admin/WorkflowDocumentActionGrid.tsx +0 -111
- package/src/components/admin/WorkflowDocumentActionHistoryGrid.tsx +0 -111
- package/src/components/admin/WorkflowDocumentActionMailGrid.tsx +0 -71
- package/src/components/admin/WorkflowDocumentGrid.tsx +0 -185
- package/src/components/admin/WorkflowDocumentStatusGrid.tsx +0 -121
- package/src/components/templates/visuals/TemplateDashboard.tsx +0 -126
- package/src/redux/features/CounterSlice.tsx +0 -13
package/src/hooks/UseSession.tsx
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { useSelector } from "react-redux";
|
|
2
|
-
import { RootState } from "../redux/store";
|
|
3
|
-
|
|
4
2
|
|
|
5
3
|
const useSession = () => {
|
|
6
|
-
const UserSession = useSelector((state:
|
|
4
|
+
const UserSession = useSelector((state: any) => state.UserSession);
|
|
5
|
+
const UserInfo = UserSession.value;
|
|
7
6
|
const isUserAuthorized = (authorityCode: string): boolean => {
|
|
8
7
|
if (UserSession?.value?.authorities) {
|
|
9
|
-
// if (UserSession.value.authorities.includes("DEVELOPMENT_ADMIN")) {
|
|
10
|
-
// return true;
|
|
11
|
-
// }
|
|
12
8
|
for (let grantedAuthority of UserSession.value.authorities) {
|
|
13
9
|
if (
|
|
14
10
|
grantedAuthority?.authority === "DEVELOPMENT_ADMIN" ||
|
|
@@ -20,7 +16,7 @@ const useSession = () => {
|
|
|
20
16
|
}
|
|
21
17
|
return false;
|
|
22
18
|
};
|
|
23
|
-
return { UserSession, isUserAuthorized };
|
|
19
|
+
return { UserSession, isUserAuthorized, UserInfo };
|
|
24
20
|
};
|
|
25
21
|
|
|
26
22
|
export default useSession;
|
package/src/hooks/UseWindow.tsx
CHANGED
|
@@ -9,13 +9,14 @@ import {
|
|
|
9
9
|
Typography,
|
|
10
10
|
} from "@mui/material";
|
|
11
11
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
12
|
+
import { IconProp } from "@fortawesome/fontawesome-svg-core";
|
|
12
13
|
|
|
13
14
|
export interface TemplateWindowProp {
|
|
14
15
|
height?: any;
|
|
15
16
|
width?: any;
|
|
16
17
|
minWidth?: any;
|
|
17
18
|
minHeight?: any;
|
|
18
|
-
windowIcon?:
|
|
19
|
+
windowIcon?: IconProp;
|
|
19
20
|
windowTitle?: string;
|
|
20
21
|
onCloseCallBack?: any;
|
|
21
22
|
}
|
package/src/hooks/useAxios.tsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { toast } from "react-toastify";
|
|
2
2
|
import axios from "axios";
|
|
3
3
|
import { useSelector } from "react-redux";
|
|
4
|
-
import { RootState } from "../redux/store";
|
|
5
4
|
import useLoadingMask from "./useLoadingMask";
|
|
6
5
|
|
|
7
6
|
export interface APIRequest {
|
|
@@ -17,7 +16,7 @@ export interface APIRequest {
|
|
|
17
16
|
const useAxios = () => {
|
|
18
17
|
const mask = useLoadingMask();
|
|
19
18
|
const apiBaseUrl = useSelector(
|
|
20
|
-
(state:
|
|
19
|
+
(state: any) => state.AppInfo.value.apiBaseUrl
|
|
21
20
|
);
|
|
22
21
|
const axiosInstance = axios.create({
|
|
23
22
|
baseURL: apiBaseUrl,
|
|
@@ -62,7 +61,14 @@ const useAxios = () => {
|
|
|
62
61
|
: false
|
|
63
62
|
: false
|
|
64
63
|
) {
|
|
65
|
-
|
|
64
|
+
if (error.response.data instanceof Blob) {
|
|
65
|
+
const blob = error.response.data;
|
|
66
|
+
blob.text().then((text) => {
|
|
67
|
+
toast.error(text);
|
|
68
|
+
});
|
|
69
|
+
} else {
|
|
70
|
+
toast.error(error.response.data);
|
|
71
|
+
}
|
|
66
72
|
} else {
|
|
67
73
|
toast.error(
|
|
68
74
|
"failed to communicate with the server ... try again later"
|
|
@@ -153,30 +159,6 @@ const useAxios = () => {
|
|
|
153
159
|
}
|
|
154
160
|
return "ERROR";
|
|
155
161
|
}
|
|
156
|
-
// axiosInstance
|
|
157
|
-
// .request({
|
|
158
|
-
// url: props.endPointURI,
|
|
159
|
-
// method: "POST",
|
|
160
|
-
// data: props.data,
|
|
161
|
-
// responseType: "blob",
|
|
162
|
-
// })
|
|
163
|
-
// .then((response) => {
|
|
164
|
-
// const url = window.URL.createObjectURL(
|
|
165
|
-
// new Blob([response.data], { type: "application/pdf" })
|
|
166
|
-
// );
|
|
167
|
-
// const link = document.createElement("a");
|
|
168
|
-
// link.href = url;
|
|
169
|
-
// link.setAttribute("download", "example.pdf"); // specify download filename
|
|
170
|
-
// document.body.appendChild(link);
|
|
171
|
-
// link.click();
|
|
172
|
-
// link.remove();
|
|
173
|
-
// })
|
|
174
|
-
// .catch((error) => {
|
|
175
|
-
// console.error("Download error:", error);
|
|
176
|
-
// })
|
|
177
|
-
// .finally(() => {
|
|
178
|
-
|
|
179
|
-
// });
|
|
180
162
|
};
|
|
181
163
|
const handlePostRequest = async (
|
|
182
164
|
props: APIRequest = { endPointURI: "", parameters: {}, data: {} }
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useSelector } from "react-redux";
|
|
2
|
+
import { TemplateGridColDef } from "../components";
|
|
3
|
+
import useAxios from "./useAxios";
|
|
4
|
+
|
|
5
|
+
const useLookupGridColumn = () => {
|
|
6
|
+
const { handleGetRequest } = useAxios();
|
|
7
|
+
const AppLayout = useSelector((state: any) => state.AppLayout);
|
|
8
|
+
const getLookupOptions = async (lookupType: string) => {
|
|
9
|
+
let options = [];
|
|
10
|
+
await handleGetRequest({
|
|
11
|
+
endPointURI: "api/v1/dev/system/lookup",
|
|
12
|
+
showMask: true,
|
|
13
|
+
parameters: { lookupType },
|
|
14
|
+
successCallBkFn: (response: any) => {
|
|
15
|
+
options = response.data;
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
return options;
|
|
19
|
+
};
|
|
20
|
+
const generateLookupGridColumn = async (props: TemplateGridColDef) => {
|
|
21
|
+
let options = await getLookupOptions(props.lookupType);
|
|
22
|
+
return {
|
|
23
|
+
...props,
|
|
24
|
+
options,
|
|
25
|
+
displayField:
|
|
26
|
+
AppLayout.appDirection === "ltr"
|
|
27
|
+
? "lookupEnDisplay"
|
|
28
|
+
: "lookupArDisplay",
|
|
29
|
+
valueField: "lookupValue",
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
return { generateLookupGridColumn, getLookupOptions };
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default useLookupGridColumn;
|
package/src/layout/Layout.tsx
CHANGED
|
@@ -25,52 +25,8 @@ const Main = styled("main", {
|
|
|
25
25
|
open?: boolean;
|
|
26
26
|
}>(({ theme: any, open }) => {
|
|
27
27
|
const AppLayout = useSelector((state: any) => state.AppLayout);
|
|
28
|
-
const dispatch = useDispatch();
|
|
29
|
-
const { show, hide } = useLoadingMask();
|
|
30
|
-
const commonStores = useSelector((state: any) => state.commonStores);
|
|
31
|
-
const [isAutoLoadLoaded, setAutoLoadLoaded] = useState<boolean>(false);
|
|
32
28
|
const theme = useTheme();
|
|
33
29
|
const isMobile = useIsMobile();
|
|
34
|
-
const { isUserAuthorized } = useSession();
|
|
35
|
-
|
|
36
|
-
// loadCommonStores
|
|
37
|
-
const { handleGetRequest } = useAxios();
|
|
38
|
-
const loadCommonStores = async () => {
|
|
39
|
-
debugger;
|
|
40
|
-
if (!isAutoLoadLoaded) {
|
|
41
|
-
setAutoLoadLoaded(true);
|
|
42
|
-
show("Loading ... please wait");
|
|
43
|
-
const stores = commonStores.stores;
|
|
44
|
-
const storeKeys = commonStores.storeKeys;
|
|
45
|
-
for (let storeKey of storeKeys) {
|
|
46
|
-
if (
|
|
47
|
-
(stores[storeKey]?.authority === undefined ||
|
|
48
|
-
stores[storeKey]?.authority === null ||
|
|
49
|
-
isUserAuthorized(stores[storeKey]?.authority)) &&
|
|
50
|
-
stores[storeKey]?.url != "" &&
|
|
51
|
-
stores[storeKey].autoLoad === true
|
|
52
|
-
) {
|
|
53
|
-
await handleGetRequest({
|
|
54
|
-
endPointURI: stores[storeKey].url,
|
|
55
|
-
showMask: false,
|
|
56
|
-
successCallBkFn: (response) => {
|
|
57
|
-
dispatch(setStoreData({ storeKey, data: response.data }));
|
|
58
|
-
},
|
|
59
|
-
failureCallBkFn: () => {
|
|
60
|
-
dispatch(setStoreData({ storeKey, data: [] }));
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
hide();
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
useEffect(() => {
|
|
70
|
-
if (commonStores.storeKeys) {
|
|
71
|
-
loadCommonStores();
|
|
72
|
-
}
|
|
73
|
-
}, [commonStores.storeKeys]);
|
|
74
30
|
|
|
75
31
|
return {
|
|
76
32
|
display: "flex",
|
|
@@ -102,7 +58,7 @@ const Main = styled("main", {
|
|
|
102
58
|
});
|
|
103
59
|
|
|
104
60
|
export default function Layout() {
|
|
105
|
-
const
|
|
61
|
+
const SideBarState = useSelector((state: any) => state.SideBar);
|
|
106
62
|
const isMobile = useIsMobile();
|
|
107
63
|
const UserSession: UserSessionProps = useSelector(
|
|
108
64
|
(state: any) => state.UserSession
|
|
@@ -112,7 +68,7 @@ export default function Layout() {
|
|
|
112
68
|
<ToastContainer draggable={true} position="bottom-center" />
|
|
113
69
|
<LoadingMask />
|
|
114
70
|
{UserSession.value.isAuthenticated === true ? (
|
|
115
|
-
<Main open={
|
|
71
|
+
<Main open={SideBarState.isOpened}>
|
|
116
72
|
<CssBaseline />
|
|
117
73
|
<TopBar />
|
|
118
74
|
{!isMobile ? <SideBar /> : null}
|
|
@@ -1,22 +1,64 @@
|
|
|
1
1
|
import { Box } from "@mui/material";
|
|
2
|
-
import { useSelector } from "react-redux";
|
|
2
|
+
import { useDispatch, useSelector } from "react-redux";
|
|
3
3
|
import { CacheProvider } from "@emotion/react";
|
|
4
4
|
import { Route, Routes } from "react-router-dom";
|
|
5
|
-
import { RootState } from "../redux/store";
|
|
6
5
|
import { cacheLtr, cacheRtl } from "../components/common/LayoutHandlers";
|
|
7
6
|
import { SYSTEM_ROUTES } from "../routes";
|
|
8
7
|
import { SystemRoute } from "../routes/types";
|
|
8
|
+
import RouteWrapper from "./RouteWrapper";
|
|
9
|
+
import { useAxios, useLoadingMask, useSession } from "../hooks";
|
|
10
|
+
import { useEffect, useState } from "react";
|
|
11
|
+
import { setStoreData } from "../redux/features/common/CommonStoreSlice";
|
|
9
12
|
|
|
10
13
|
const MainContent: React.FC = () => {
|
|
11
|
-
const AppLayoutState = useSelector((state:
|
|
12
|
-
const AppInfo = useSelector((state:
|
|
14
|
+
const AppLayoutState = useSelector((state: any) => state.AppLayout);
|
|
15
|
+
const AppInfo = useSelector((state: any) => state.AppInfo.value);
|
|
13
16
|
const businessRoutes = useSelector(
|
|
14
|
-
(state:
|
|
17
|
+
(state: any) => state.AppInfo.value.businessRoutes
|
|
15
18
|
);
|
|
19
|
+
const dispatch = useDispatch();
|
|
20
|
+
const { show, hide } = useLoadingMask();
|
|
21
|
+
const commonStores = useSelector((state: any) => state.commonStores);
|
|
22
|
+
const [isAutoLoadLoaded, setAutoLoadLoaded] = useState<boolean>(false);
|
|
23
|
+
const { isUserAuthorized } = useSession();
|
|
24
|
+
const { handleGetRequest } = useAxios();
|
|
25
|
+
const loadCommonStores = async () => {
|
|
26
|
+
show("Loading ... please wait");
|
|
27
|
+
const stores = commonStores.stores;
|
|
28
|
+
const storeKeys = commonStores.storeKeys;
|
|
29
|
+
for (let storeKey of storeKeys) {
|
|
30
|
+
if (
|
|
31
|
+
(stores[storeKey]?.authority === undefined ||
|
|
32
|
+
stores[storeKey]?.authority === null ||
|
|
33
|
+
isUserAuthorized(stores[storeKey]?.authority)) &&
|
|
34
|
+
stores[storeKey]?.url != "" &&
|
|
35
|
+
stores[storeKey].autoLoad === true
|
|
36
|
+
) {
|
|
37
|
+
await handleGetRequest({
|
|
38
|
+
endPointURI: stores[storeKey].url,
|
|
39
|
+
showMask: false,
|
|
40
|
+
successCallBkFn: (response) => {
|
|
41
|
+
dispatch(setStoreData({ storeKey, data: response.data }));
|
|
42
|
+
},
|
|
43
|
+
failureCallBkFn: () => {
|
|
44
|
+
dispatch(setStoreData({ storeKey, data: [] }));
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
hide();
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (commonStores?.storeKeys) {
|
|
54
|
+
loadCommonStores();
|
|
55
|
+
}
|
|
56
|
+
}, [commonStores.storeKeys]);
|
|
16
57
|
return (
|
|
17
58
|
<CacheProvider
|
|
18
59
|
value={AppLayoutState.appDirection === "ltr" ? cacheLtr : cacheRtl}
|
|
19
60
|
>
|
|
61
|
+
{/* {isAutoLoadLoaded ? ( */}
|
|
20
62
|
<Box
|
|
21
63
|
sx={{
|
|
22
64
|
display: "flex",
|
|
@@ -35,7 +77,11 @@ const MainContent: React.FC = () => {
|
|
|
35
77
|
<Route
|
|
36
78
|
key={"adm" + index}
|
|
37
79
|
path={route.path}
|
|
38
|
-
|
|
80
|
+
element={
|
|
81
|
+
<RouteWrapper authority={route.authority}>
|
|
82
|
+
<route.component />
|
|
83
|
+
</RouteWrapper>
|
|
84
|
+
}
|
|
39
85
|
/>
|
|
40
86
|
);
|
|
41
87
|
})
|
|
@@ -45,12 +91,19 @@ const MainContent: React.FC = () => {
|
|
|
45
91
|
<Route
|
|
46
92
|
key={"bs" + index}
|
|
47
93
|
path={route.path}
|
|
48
|
-
|
|
94
|
+
element={
|
|
95
|
+
<RouteWrapper authority={route.authority}>
|
|
96
|
+
<route.component />
|
|
97
|
+
</RouteWrapper>
|
|
98
|
+
}
|
|
49
99
|
/>
|
|
50
100
|
);
|
|
51
101
|
})}
|
|
52
102
|
</Routes>
|
|
53
103
|
</Box>
|
|
104
|
+
{/* ) : (
|
|
105
|
+
<></>
|
|
106
|
+
)} */}
|
|
54
107
|
</CacheProvider>
|
|
55
108
|
);
|
|
56
109
|
};
|
|
@@ -3,9 +3,9 @@ import { grey } from "@mui/material/colors";
|
|
|
3
3
|
import SwipeableDrawer from "@mui/material/SwipeableDrawer";
|
|
4
4
|
import { useDispatch, useSelector } from "react-redux";
|
|
5
5
|
import { Box, Typography } from "@mui/material";
|
|
6
|
-
import { RootState } from "../redux/store";
|
|
7
6
|
import { AppLayoutActions } from "../redux/features/common/AppLayoutSlice";
|
|
8
7
|
import NavigationTree from "./NavigationTree";
|
|
8
|
+
import { setSideBarState } from "../redux/features/common/SideBarSlice";
|
|
9
9
|
|
|
10
10
|
const drawerBleeding = 56;
|
|
11
11
|
|
|
@@ -33,11 +33,11 @@ const Puller = styled("div")(({ theme }) => ({
|
|
|
33
33
|
|
|
34
34
|
export default function MobileDrawer(props: Props) {
|
|
35
35
|
const { window } = props;
|
|
36
|
-
const
|
|
37
|
-
const AppInfo = useSelector((state:
|
|
36
|
+
const SideBarState = useSelector((state: any) => state.SideBar);
|
|
37
|
+
const AppInfo = useSelector((state: any) => state.AppInfo.value);
|
|
38
38
|
const dispatch = useDispatch();
|
|
39
39
|
const toggleDrawer = (newState: boolean) => {
|
|
40
|
-
dispatch(
|
|
40
|
+
dispatch(setSideBarState(newState));
|
|
41
41
|
};
|
|
42
42
|
// This is used only for the example
|
|
43
43
|
const container =
|
|
@@ -47,7 +47,7 @@ export default function MobileDrawer(props: Props) {
|
|
|
47
47
|
<SwipeableDrawer
|
|
48
48
|
container={container}
|
|
49
49
|
anchor="bottom"
|
|
50
|
-
open={
|
|
50
|
+
open={SideBarState.isOpened}
|
|
51
51
|
onClose={() => {
|
|
52
52
|
toggleDrawer(false);
|
|
53
53
|
}}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Box } from "@mui/material";
|
|
2
|
+
import { useSession } from "../hooks";
|
|
3
|
+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
4
|
+
|
|
5
|
+
type RouteWrapperProps = {
|
|
6
|
+
authority?: string;
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
};
|
|
9
|
+
const RouteWrapper: React.FC<RouteWrapperProps> = (props) => {
|
|
10
|
+
const { isUserAuthorized } = useSession();
|
|
11
|
+
if (props?.authority && !isUserAuthorized(props.authority)) {
|
|
12
|
+
return (
|
|
13
|
+
<Box
|
|
14
|
+
sx={{
|
|
15
|
+
flex: 1,
|
|
16
|
+
display: "flex",
|
|
17
|
+
flexDirection: "column",
|
|
18
|
+
alignItems: "center",
|
|
19
|
+
justifyContent: "center",
|
|
20
|
+
color: "red",
|
|
21
|
+
}}
|
|
22
|
+
>
|
|
23
|
+
<h2>
|
|
24
|
+
<FontAwesomeIcon
|
|
25
|
+
style={{ marginRight: 10, marginLeft: 10 }}
|
|
26
|
+
icon="cancel"
|
|
27
|
+
/>
|
|
28
|
+
You aren't authorized to access this page
|
|
29
|
+
</h2>
|
|
30
|
+
</Box>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
return <>{props.children}</>;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default RouteWrapper;
|
package/src/layout/SideBar.tsx
CHANGED
|
@@ -5,20 +5,21 @@ import Drawer from "@mui/material/Drawer";
|
|
|
5
5
|
import { useDispatch, useSelector } from "react-redux";
|
|
6
6
|
import { DrawerHeader } from "./DrawerHeader";
|
|
7
7
|
import { Box, Typography, useTheme } from "@mui/material";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
AppLayoutActions,
|
|
11
|
-
DRAWER_WIDTH,
|
|
12
|
-
} from "../redux/features/common/AppLayoutSlice";
|
|
8
|
+
import { DRAWER_WIDTH } from "../redux/features/common/AppLayoutSlice";
|
|
13
9
|
import NavigationTree from "./NavigationTree";
|
|
10
|
+
import { useSession } from "../hooks";
|
|
11
|
+
import { toggleSideBarState } from "../redux/features/common/SideBarSlice";
|
|
14
12
|
|
|
15
13
|
const SideBar: React.FC = () => {
|
|
16
|
-
const AppInfo = useSelector((state:
|
|
14
|
+
const AppInfo = useSelector((state: any) => state.AppInfo.value);
|
|
15
|
+
const { UserSession } = useSession();
|
|
16
|
+
const currentOrganization = UserSession.value.currentOrganization;
|
|
17
17
|
const theme = useTheme();
|
|
18
|
-
const AppLayout = useSelector((state:
|
|
18
|
+
const AppLayout = useSelector((state: any) => state.AppLayout);
|
|
19
|
+
const SideBarState = useSelector((state: any) => state.SideBar);
|
|
19
20
|
const dispatch = useDispatch();
|
|
20
21
|
const toggleSideBar = () => {
|
|
21
|
-
dispatch(
|
|
22
|
+
dispatch(toggleSideBarState());
|
|
22
23
|
};
|
|
23
24
|
return (
|
|
24
25
|
<Drawer
|
|
@@ -32,7 +33,7 @@ const SideBar: React.FC = () => {
|
|
|
32
33
|
}}
|
|
33
34
|
variant="persistent"
|
|
34
35
|
anchor={AppLayout.appDirection === "ltr" ? "left" : "right"}
|
|
35
|
-
open={
|
|
36
|
+
open={SideBarState.isOpened}
|
|
36
37
|
>
|
|
37
38
|
<DrawerHeader>
|
|
38
39
|
<Box sx={{ width: "100%" }}>
|
|
@@ -56,7 +57,11 @@ const SideBar: React.FC = () => {
|
|
|
56
57
|
}}
|
|
57
58
|
>
|
|
58
59
|
<Typography sx={{ fontSize: 12 }} color="textDisabled">
|
|
59
|
-
{AppInfo.appName}
|
|
60
|
+
{`${AppInfo.appName} - ${
|
|
61
|
+
AppLayout.appDirection === "ltr"
|
|
62
|
+
? currentOrganization?.organizationEnName
|
|
63
|
+
: currentOrganization?.organizationArName
|
|
64
|
+
}`}
|
|
60
65
|
</Typography>
|
|
61
66
|
<Typography sx={{ fontSize: 12 }} color="textDisabled">
|
|
62
67
|
V.{AppInfo.appVersion}
|