@asaleh37/ui-base 1.2.0 → 1.2.2
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/.env +4 -0
- package/.env.development +1 -0
- package/.env.production +1 -0
- package/dist/index.d.ts +18 -37
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +1 -1
- package/index.html +13 -0
- package/package.json +1 -1
- package/public/__logo.png +0 -0
- package/public/logo.png +0 -0
- package/public/vite.svg +1 -0
- package/rollup.config-1748377725725.cjs +16 -16
- package/src/assets/logo.png +0 -0
- package/src/components/App.tsx +39 -9
- package/src/components/BaseApp.tsx +37 -25
- package/src/components/admin/AttachmentGrid.tsx +1 -1
- package/src/components/admin/AuthorityGrid.tsx +1 -1
- package/src/components/admin/BluePrintGrid.tsx +1 -1
- package/src/components/admin/BluePrintPageGrid.tsx +1 -1
- package/src/components/admin/BluePrintPointGrid.tsx +1 -1
- package/src/components/admin/DashboardGrid.tsx +1 -1
- package/src/components/admin/DashboardWidgetGrid.tsx +1 -1
- package/src/components/admin/DataQueryGrid.tsx +1 -1
- package/src/components/admin/DataQueryParameterGrid.tsx +1 -1
- package/src/components/admin/DatasourceConnectionGrid.tsx +1 -1
- package/src/components/admin/EmployeeGrid.tsx +1 -1
- package/src/components/admin/EntityParameterGrid.tsx +1 -1
- package/src/components/admin/ExcelUploaderDetailGrid.tsx +1 -1
- package/src/components/admin/ExcelUploaderHeaderGrid.tsx +1 -1
- package/src/components/admin/LookupGrid.tsx +1 -1
- package/src/components/admin/MailAttachmentGrid.tsx +1 -1
- package/src/components/admin/MailBodyGrid.tsx +1 -1
- package/src/components/admin/MailNotificationQueueGrid.tsx +1 -1
- package/src/components/admin/MailRecipientGrid.tsx +1 -1
- package/src/components/admin/MailTemplateGrid.tsx +1 -1
- package/src/components/admin/NewTableGrid.tsx +1 -1
- package/src/components/admin/NotificationGrid.tsx +1 -1
- package/src/components/admin/NotificationQueueGrid.tsx +1 -1
- package/src/components/admin/OrganizationApplicationGrid.tsx +1 -1
- package/src/components/admin/OrganizationGrid.tsx +1 -1
- package/src/components/admin/OrganizationRankGrid.tsx +1 -1
- package/src/components/admin/OrganizationUnitGrid.tsx +1 -1
- package/src/components/admin/OrganizationUserGrid.tsx +1 -1
- package/src/components/admin/OrganizationUserRoleGrid.tsx +1 -1
- package/src/components/admin/ReportGrid.tsx +1 -1
- package/src/components/admin/ReportParameterGrid.tsx +1 -1
- package/src/components/admin/RoleAuthoritiesForm.tsx +65 -0
- package/src/components/admin/RoleAuthorityGrid.tsx +1 -1
- package/src/components/admin/RoleGrid.tsx +68 -14
- package/src/components/admin/UserAccountGrid.tsx +1 -1
- package/src/components/admin/UserRequestGrid.tsx +1 -1
- package/src/components/admin/WidgetGrid.tsx +1 -1
- package/src/components/admin/WorkflowDocumentActionGrid.tsx +1 -1
- package/src/components/admin/WorkflowDocumentActionHistoryGrid.tsx +1 -1
- package/src/components/admin/WorkflowDocumentActionMailGrid.tsx +1 -1
- package/src/components/admin/WorkflowDocumentGrid.tsx +1 -1
- package/src/components/admin/WorkflowDocumentMailLogGrid.tsx +1 -1
- package/src/components/admin/WorkflowDocumentStatusGrid.tsx +1 -1
- package/src/components/common/Home.tsx +3 -0
- package/src/components/common/Login.tsx +10 -3
- package/src/components/templates/DataEntryTemplates/DataEntryTypes.ts +1 -1
- package/src/components/templates/TransferList.tsx +4 -7
- package/src/hooks/index.ts +1 -0
- package/src/{components/templates/DataEntryTemplates → hooks}/useApiActions.ts +4 -5
- package/src/layout/Layout.tsx +36 -29
- package/src/main.tsx +25 -0
- package/src/redux/features/CounterSlice.tsx +13 -0
- package/src/redux/features/common/AppInfoSlice.ts +1 -1
- package/src/redux/features/common/CommonStoreSlice.ts +19 -5
- package/src/redux/store.ts +25 -24
- package/src/util/constants.ts +5 -1
- package/vite.config.ts +10 -0
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
2
|
import TemplateGrid from "../templates/DataEntryTemplates/TemplateDataGrid/TemplateGrid";
|
|
3
|
-
import useApiActions from "
|
|
3
|
+
import useApiActions from "../../hooks/useApiActions";
|
|
4
4
|
import { FormElementProps } from "../templates/DataEntryTemplates/DataEntryTypes";
|
|
5
|
+
import { useAxios, useWindow } from "../../hooks";
|
|
6
|
+
import RoleAuthoritiesForm from "./RoleAuthoritiesForm";
|
|
5
7
|
|
|
6
8
|
const RoleGrid: React.FC = () => {
|
|
7
9
|
const [data, setData] = useState([]);
|
|
@@ -12,7 +14,37 @@ const RoleGrid: React.FC = () => {
|
|
|
12
14
|
findById: "api/v1/admin/role",
|
|
13
15
|
setData: setData,
|
|
14
16
|
});
|
|
15
|
-
|
|
17
|
+
const [selectedRole, setSelectedRole] = useState<any>(null);
|
|
18
|
+
const { handleGetRequest } = useAxios();
|
|
19
|
+
const [selectedRoleAuthorities, setSelectedRoleAuthorities] = useState<any>(
|
|
20
|
+
[]
|
|
21
|
+
);
|
|
22
|
+
const [
|
|
23
|
+
selectedRoleAvailableAuthorities,
|
|
24
|
+
setSelectedRoleAvailableAuthorities,
|
|
25
|
+
] = useState<any>([]);
|
|
26
|
+
const {
|
|
27
|
+
Window: RoleAuthoritiesWindow,
|
|
28
|
+
setWindowState: setRoleAuthorirtiesWindowOpen,
|
|
29
|
+
} = useWindow({
|
|
30
|
+
width: "50%",
|
|
31
|
+
windowIcon: "key",
|
|
32
|
+
windowTitle: "Role Authorities",
|
|
33
|
+
});
|
|
34
|
+
const loadRoleAuthorities = async (data: any) => {
|
|
35
|
+
await handleGetRequest({
|
|
36
|
+
endPointURI: "api/v1/admin/role/authorities",
|
|
37
|
+
showMask: true,
|
|
38
|
+
parameters: {
|
|
39
|
+
roleId: data.id,
|
|
40
|
+
},
|
|
41
|
+
successCallBkFn: (response: any) => {
|
|
42
|
+
setRoleAuthorirtiesWindowOpen(true);
|
|
43
|
+
setSelectedRoleAuthorities(response.data.selectedAuthorities);
|
|
44
|
+
setSelectedRoleAvailableAuthorities(response.data.availableAuthorities);
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
};
|
|
16
48
|
const formElements: Array<FormElementProps> = [
|
|
17
49
|
{
|
|
18
50
|
type: "field",
|
|
@@ -60,18 +92,40 @@ const RoleGrid: React.FC = () => {
|
|
|
60
92
|
];
|
|
61
93
|
|
|
62
94
|
return (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
95
|
+
<>
|
|
96
|
+
<RoleAuthoritiesWindow>
|
|
97
|
+
<RoleAuthoritiesForm
|
|
98
|
+
roleId={selectedRole?.id}
|
|
99
|
+
availableAuthorities={selectedRoleAvailableAuthorities}
|
|
100
|
+
currentRoleAuthorities={selectedRoleAuthorities}
|
|
101
|
+
closeModalFn={() => {
|
|
102
|
+
setRoleAuthorirtiesWindowOpen(false);
|
|
103
|
+
}}
|
|
104
|
+
/>
|
|
105
|
+
</RoleAuthoritiesWindow>
|
|
106
|
+
<TemplateGrid
|
|
107
|
+
rowActions={[
|
|
108
|
+
{
|
|
109
|
+
icon: "key",
|
|
110
|
+
label: "authorities",
|
|
111
|
+
actionFn: async (data) => {
|
|
112
|
+
setSelectedRole(data);
|
|
113
|
+
loadRoleAuthorities(data);
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
]}
|
|
117
|
+
apiActions={apiActions}
|
|
118
|
+
data={data}
|
|
119
|
+
setData={setData}
|
|
120
|
+
editMode={{ editMode: "row", reloadAfterSave: true }}
|
|
121
|
+
formElements={formElements}
|
|
122
|
+
keyColumnName={"id"}
|
|
123
|
+
gridTitle="ROLE_PLURAL"
|
|
124
|
+
girdIcon="table-cells"
|
|
125
|
+
editAction={{ isEnabled: true, authority: "ROLE_EDIT" }}
|
|
126
|
+
deleteAction={{ isEnabled: true, authority: "ROLE_DELETE" }}
|
|
127
|
+
/>
|
|
128
|
+
</>
|
|
75
129
|
);
|
|
76
130
|
};
|
|
77
131
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
2
|
import TemplateGrid from "../templates/DataEntryTemplates/TemplateDataGrid/TemplateGrid";
|
|
3
|
-
import useApiActions from "
|
|
3
|
+
import useApiActions from "../../hooks/useApiActions";
|
|
4
4
|
import { FormElementProps } from "../templates/DataEntryTemplates/DataEntryTypes";
|
|
5
5
|
|
|
6
6
|
const UserAccountGrid: React.FC = () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
2
|
import TemplateGrid from "../templates/DataEntryTemplates/TemplateDataGrid/TemplateGrid";
|
|
3
|
-
import useApiActions from "
|
|
3
|
+
import useApiActions from "../../hooks/useApiActions";
|
|
4
4
|
import { FormElementProps } from "../templates/DataEntryTemplates/DataEntryTypes";
|
|
5
5
|
|
|
6
6
|
const UserRequestGrid: React.FC = () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
2
|
import TemplateGrid from "../templates/DataEntryTemplates/TemplateDataGrid/TemplateGrid";
|
|
3
|
-
import useApiActions from "
|
|
3
|
+
import useApiActions from "../../hooks/useApiActions";
|
|
4
4
|
import { FormElementProps } from "../templates/DataEntryTemplates/DataEntryTypes";
|
|
5
5
|
|
|
6
6
|
const WidgetGrid: React.FC = () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
2
|
import TemplateGrid from "../templates/DataEntryTemplates/TemplateDataGrid/TemplateGrid";
|
|
3
|
-
import useApiActions from "
|
|
3
|
+
import useApiActions from "../../hooks/useApiActions";
|
|
4
4
|
import { FormElementProps } from "../templates/DataEntryTemplates/DataEntryTypes";
|
|
5
5
|
|
|
6
6
|
const WorkflowDocumentActionGrid: React.FC = () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
2
|
import TemplateGrid from "../templates/DataEntryTemplates/TemplateDataGrid/TemplateGrid";
|
|
3
|
-
import useApiActions from "
|
|
3
|
+
import useApiActions from "../../hooks/useApiActions";
|
|
4
4
|
import { FormElementProps } from "../templates/DataEntryTemplates/DataEntryTypes";
|
|
5
5
|
|
|
6
6
|
const WorkflowDocumentActionHistoryGrid: React.FC = () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
2
|
import TemplateGrid from "../templates/DataEntryTemplates/TemplateDataGrid/TemplateGrid";
|
|
3
|
-
import useApiActions from "
|
|
3
|
+
import useApiActions from "../../hooks/useApiActions";
|
|
4
4
|
import { FormElementProps } from "../templates/DataEntryTemplates/DataEntryTypes";
|
|
5
5
|
|
|
6
6
|
const WorkflowDocumentActionMailGrid: React.FC = () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
2
|
import TemplateGrid from "../templates/DataEntryTemplates/TemplateDataGrid/TemplateGrid";
|
|
3
|
-
import useApiActions from "
|
|
3
|
+
import useApiActions from "../../hooks/useApiActions";
|
|
4
4
|
import { FormElementProps } from "../templates/DataEntryTemplates/DataEntryTypes";
|
|
5
5
|
|
|
6
6
|
const WorkflowDocumentGrid: React.FC = () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
2
|
import TemplateGrid from "../templates/DataEntryTemplates/TemplateDataGrid/TemplateGrid";
|
|
3
|
-
import useApiActions from "
|
|
3
|
+
import useApiActions from "../../hooks/useApiActions";
|
|
4
4
|
import { FormElementProps } from "../templates/DataEntryTemplates/DataEntryTypes";
|
|
5
5
|
|
|
6
6
|
const WorkflowDocumentMailLogGrid: React.FC = () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
2
|
import TemplateGrid from "../templates/DataEntryTemplates/TemplateDataGrid/TemplateGrid";
|
|
3
|
-
import useApiActions from "
|
|
3
|
+
import useApiActions from "../../hooks/useApiActions";
|
|
4
4
|
import { FormElementProps } from "../templates/DataEntryTemplates/DataEntryTypes";
|
|
5
5
|
|
|
6
6
|
const WorkflowDocumentStatusGrid: React.FC = () => {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
2
2
|
import { Box } from "@mui/material";
|
|
3
|
+
import { useSelector } from "react-redux";
|
|
3
4
|
|
|
4
5
|
const Home: React.FC = () => {
|
|
6
|
+
const counter = useSelector((state) => state.counter.value);
|
|
5
7
|
return (
|
|
6
8
|
<Box
|
|
7
9
|
sx={{
|
|
@@ -24,6 +26,7 @@ const Home: React.FC = () => {
|
|
|
24
26
|
/>
|
|
25
27
|
] to navigate to your authorized system modules
|
|
26
28
|
</div>
|
|
29
|
+
<div>counter [{counter}]</div>
|
|
27
30
|
</Box>
|
|
28
31
|
);
|
|
29
32
|
};
|
|
@@ -14,6 +14,7 @@ import axios from "axios";
|
|
|
14
14
|
import { toast } from "react-toastify";
|
|
15
15
|
import { RootState } from "../../redux/store";
|
|
16
16
|
import { UserSessionActions } from "../../redux/features/common/UserSessionSlice";
|
|
17
|
+
import { DARK_THEME_INITIAL_MAIN_COLOR, DARK_THEME_INITIAL_SECANDARY_COLOR } from "../../util";
|
|
17
18
|
|
|
18
19
|
const Login: React.FC = () => {
|
|
19
20
|
const appInfo = useSelector((state: RootState) => state.AppInfo.value);
|
|
@@ -73,7 +74,10 @@ const Login: React.FC = () => {
|
|
|
73
74
|
/* Custom Scrollbar */
|
|
74
75
|
* {
|
|
75
76
|
scrollbar-width: thin;
|
|
76
|
-
scrollbar-color: ${
|
|
77
|
+
scrollbar-color: ${
|
|
78
|
+
appInfo.appTheme?.dark?.primaryColor ||
|
|
79
|
+
DARK_THEME_INITIAL_MAIN_COLOR
|
|
80
|
+
} #121212;
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
/* Webkit Browsers */
|
|
@@ -87,10 +91,13 @@ const Login: React.FC = () => {
|
|
|
87
91
|
palette: {
|
|
88
92
|
mode: "dark",
|
|
89
93
|
primary: {
|
|
90
|
-
main:
|
|
94
|
+
main:
|
|
95
|
+
appInfo.appTheme?.dark?.primaryColor || DARK_THEME_INITIAL_MAIN_COLOR,
|
|
91
96
|
},
|
|
92
97
|
secondary: {
|
|
93
|
-
main:
|
|
98
|
+
main:
|
|
99
|
+
appInfo.appTheme?.dark?.secondaryColor ||
|
|
100
|
+
DARK_THEME_INITIAL_SECANDARY_COLOR,
|
|
94
101
|
},
|
|
95
102
|
},
|
|
96
103
|
});
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "@mui/x-data-grid-premium";
|
|
9
9
|
import { UseFormReturn } from "react-hook-form";
|
|
10
10
|
import { SxProps } from "@mui/material";
|
|
11
|
-
import { ApiActions } from "
|
|
11
|
+
import { ApiActions } from "../../../hooks/useApiActions";
|
|
12
12
|
export type MakeOptional<T, K extends keyof T> = Omit<T, K> &
|
|
13
13
|
Partial<Pick<T, K>>;
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@ import ListItemIcon from "@mui/material/ListItemIcon";
|
|
|
8
8
|
import Checkbox from "@mui/material/Checkbox";
|
|
9
9
|
import Button from "@mui/material/Button";
|
|
10
10
|
import Divider from "@mui/material/Divider";
|
|
11
|
-
import { Box, Grid2 } from "@mui/material";
|
|
11
|
+
import { Box, Grid2, ListItemButton } from "@mui/material";
|
|
12
12
|
import TemplateTextField from "./DataEntryTemplates/TemplateDataForm/FormFields/TemplateTextField";
|
|
13
13
|
|
|
14
14
|
function not(a, b) {
|
|
@@ -172,27 +172,24 @@ const TransferList: React.FC<TransferListProps> = ({
|
|
|
172
172
|
const labelId = `transfer-list-all-item-${value[valueField]}-label`;
|
|
173
173
|
|
|
174
174
|
return (
|
|
175
|
-
<
|
|
175
|
+
<ListItemButton
|
|
176
176
|
key={value[valueField]}
|
|
177
177
|
role="listitem"
|
|
178
|
-
component="button"
|
|
179
178
|
onClick={handleToggle(value)}
|
|
179
|
+
sx={{ cursor: "pointer" }}
|
|
180
180
|
>
|
|
181
181
|
<ListItemIcon>
|
|
182
182
|
<Checkbox
|
|
183
183
|
checked={checked.indexOf(value) !== -1}
|
|
184
184
|
tabIndex={-1}
|
|
185
185
|
disableRipple
|
|
186
|
-
inputProps={{
|
|
187
|
-
"aria-labelledby": labelId,
|
|
188
|
-
}}
|
|
189
186
|
/>
|
|
190
187
|
</ListItemIcon>
|
|
191
188
|
<ListItemText
|
|
192
189
|
id={value[valueField]}
|
|
193
190
|
primary={value[displayField]}
|
|
194
191
|
/>
|
|
195
|
-
</
|
|
192
|
+
</ListItemButton>
|
|
196
193
|
);
|
|
197
194
|
})}
|
|
198
195
|
</List>
|
package/src/hooks/index.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { useDispatch, useSelector } from "react-redux";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { setStoreData } from "../../../redux/features/common/CommonStoreSlice";
|
|
2
|
+
import useSession from "./UseSession";
|
|
3
|
+
import useAxios from "./useAxios";
|
|
4
|
+
import { setStoreData } from "../redux/features/common/CommonStoreSlice";
|
|
6
5
|
|
|
7
6
|
export type ApiActionsProps = {
|
|
8
7
|
findAll?: string;
|
|
@@ -25,7 +24,7 @@ export type ApiActions = {
|
|
|
25
24
|
const useApiActions: (apiActionsProps: ApiActionsProps) => ApiActions = (
|
|
26
25
|
apiActionsProps: ApiActionsProps
|
|
27
26
|
) => {
|
|
28
|
-
const CommonStores = useSelector((state:
|
|
27
|
+
const CommonStores = useSelector((state: any) => state.commonStores.stores);
|
|
29
28
|
const dispatch = useDispatch();
|
|
30
29
|
const session = useSession();
|
|
31
30
|
const { handleGetRequest, handlePostRequest, handleDeleteRequest } =
|
package/src/layout/Layout.tsx
CHANGED
|
@@ -8,8 +8,7 @@ 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 } from "react";
|
|
12
|
-
import { RootState } from "../redux/store";
|
|
11
|
+
import { useEffect, useState } from "react";
|
|
13
12
|
import useLoadingMask from "../hooks/useLoadingMask";
|
|
14
13
|
import { useIsMobile } from "../hooks/UseMobile";
|
|
15
14
|
import useSession from "../hooks/UseSession";
|
|
@@ -25,10 +24,11 @@ const Main = styled("main", {
|
|
|
25
24
|
})<{
|
|
26
25
|
open?: boolean;
|
|
27
26
|
}>(({ theme: any, open }) => {
|
|
28
|
-
const AppLayout = useSelector((state:
|
|
27
|
+
const AppLayout = useSelector((state: any) => state.AppLayout);
|
|
29
28
|
const dispatch = useDispatch();
|
|
30
29
|
const { show, hide } = useLoadingMask();
|
|
31
|
-
const
|
|
30
|
+
const commonStores = useSelector((state: any) => state.commonStores);
|
|
31
|
+
const [isAutoLoadLoaded, setAutoLoadLoaded] = useState<boolean>(false);
|
|
32
32
|
const theme = useTheme();
|
|
33
33
|
const isMobile = useIsMobile();
|
|
34
34
|
const { isUserAuthorized } = useSession();
|
|
@@ -36,34 +36,41 @@ const Main = styled("main", {
|
|
|
36
36
|
// loadCommonStores
|
|
37
37
|
const { handleGetRequest } = useAxios();
|
|
38
38
|
const loadCommonStores = async () => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
+
}
|
|
59
64
|
}
|
|
65
|
+
hide();
|
|
60
66
|
}
|
|
61
|
-
hide();
|
|
62
67
|
};
|
|
63
68
|
|
|
64
69
|
useEffect(() => {
|
|
65
|
-
|
|
66
|
-
|
|
70
|
+
if (commonStores.storeKeys) {
|
|
71
|
+
loadCommonStores();
|
|
72
|
+
}
|
|
73
|
+
}, [commonStores.storeKeys]);
|
|
67
74
|
|
|
68
75
|
return {
|
|
69
76
|
display: "flex",
|
|
@@ -95,10 +102,10 @@ const Main = styled("main", {
|
|
|
95
102
|
});
|
|
96
103
|
|
|
97
104
|
export default function Layout() {
|
|
98
|
-
const AppLayoutState = useSelector((state:
|
|
105
|
+
const AppLayoutState = useSelector((state: any) => state.AppLayout);
|
|
99
106
|
const isMobile = useIsMobile();
|
|
100
107
|
const UserSession: UserSessionProps = useSelector(
|
|
101
|
-
(state:
|
|
108
|
+
(state: any) => state.UserSession
|
|
102
109
|
);
|
|
103
110
|
return (
|
|
104
111
|
<BrowserRouter>
|
package/src/main.tsx
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { StrictMode } from "react";
|
|
2
|
+
import { createRoot } from "react-dom/client";
|
|
3
|
+
import { BaseApp } from "./components";
|
|
4
|
+
import logo from "./assets/logo.png";
|
|
5
|
+
import CounterReducer from "./redux/features/CounterSlice";
|
|
6
|
+
|
|
7
|
+
createRoot(document.getElementById("root")!).render(
|
|
8
|
+
<BaseApp
|
|
9
|
+
apiBaseUrl="http://localhost:8080/as-api"
|
|
10
|
+
appLogo={logo}
|
|
11
|
+
appName="UI Base Library"
|
|
12
|
+
appVersion="0.0"
|
|
13
|
+
businessCommonStoresMetaData={{}}
|
|
14
|
+
businessNavigationItems={[]}
|
|
15
|
+
businessReduxReducers={
|
|
16
|
+
{
|
|
17
|
+
counter: CounterReducer
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
businessRoutes={[]}
|
|
21
|
+
documentTitle="UI Base"
|
|
22
|
+
enableAdministrationModule={true}
|
|
23
|
+
muiPremiumKey="c2bd611fa642666253500ab9c8e4f78fTz0xMTE4MjEsRT0xNzc2OTg4Nzk5MDAwLFM9cHJlbWl1bSxMTT1zdWJzY3JpcHRpb24sUFY9aW5pdGlhbCxLVj0y"
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createSlice } from "@reduxjs/toolkit";
|
|
2
|
+
|
|
3
|
+
const CounterSlice = createSlice({
|
|
4
|
+
name: "counter",
|
|
5
|
+
initialState: { value: 0 },
|
|
6
|
+
reducers: {
|
|
7
|
+
increment: (state) => {
|
|
8
|
+
state.value = state.value + 1;
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export default CounterSlice.reducer;
|
|
@@ -15,7 +15,7 @@ export type AppInfo = {
|
|
|
15
15
|
businessCommonStoresMetaData: { [key: string]: StoreMetaData };
|
|
16
16
|
muiPremiumKey: string;
|
|
17
17
|
enableAdministrationModule: boolean;
|
|
18
|
-
appTheme
|
|
18
|
+
appTheme?: {
|
|
19
19
|
light: { primaryColor: string; secondaryColor: string };
|
|
20
20
|
dark: { primaryColor: string; secondaryColor: string };
|
|
21
21
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
|
2
2
|
|
|
3
3
|
export interface CommonStoresInterface {
|
|
4
|
-
[key: string]: StoreMetaData;
|
|
4
|
+
stores: { [key: string]: StoreMetaData };
|
|
5
|
+
storeKeys: Array<String>;
|
|
6
|
+
isAutoLoadLoaded: boolean;
|
|
5
7
|
}
|
|
6
8
|
|
|
7
9
|
interface setStoreDataProps {
|
|
@@ -16,17 +18,29 @@ export interface StoreMetaData {
|
|
|
16
18
|
authority?: string;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
export const commonStoresInitialState: CommonStoresInterface = {
|
|
21
|
+
export const commonStoresInitialState: CommonStoresInterface = {
|
|
22
|
+
stores: {},
|
|
23
|
+
storeKeys: [],
|
|
24
|
+
isAutoLoadLoaded: false,
|
|
25
|
+
};
|
|
20
26
|
|
|
21
27
|
const commonStoreSlice = createSlice({
|
|
22
28
|
name: "loadingMask",
|
|
23
29
|
initialState: commonStoresInitialState,
|
|
24
30
|
reducers: {
|
|
25
|
-
|
|
26
|
-
state
|
|
31
|
+
setStoresMetaData: (state, action) => {
|
|
32
|
+
state.stores = action.payload;
|
|
33
|
+
state.storeKeys = Object.keys(action.payload);
|
|
34
|
+
},
|
|
35
|
+
setStoreData: (state, action: PayloadAction<setStoreDataProps>) => {
|
|
36
|
+
state.stores[action.payload.storeKey].data = action.payload.data;
|
|
37
|
+
},
|
|
38
|
+
setAutoLoadLoaded: () => {
|
|
39
|
+
state.isAutoLoadLoaded = true;
|
|
27
40
|
},
|
|
28
41
|
},
|
|
29
42
|
});
|
|
30
43
|
|
|
31
|
-
export const { setStoreData } =
|
|
44
|
+
export const { setStoreData, setStoresMetaData, setAutoLoadLoaded } =
|
|
45
|
+
commonStoreSlice.actions;
|
|
32
46
|
export default commonStoreSlice.reducer;
|
package/src/redux/store.ts
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import { configureStore, Reducer } from "@reduxjs/toolkit";
|
|
2
|
-
import AppLayoutReducer from "./features/common/AppLayoutSlice";
|
|
3
|
-
import UserSessionReducer from "./features/common/UserSessionSlice";
|
|
4
|
-
import LoadingMaskReducer from "./features/common/LoadingMaskSlice";
|
|
5
|
-
import CommonStoreReducer from "./features/common/CommonStoreSlice";
|
|
6
|
-
import AppInfoReducer from "./features/common/AppInfoSlice";
|
|
1
|
+
// import { configureStore, Reducer } from "@reduxjs/toolkit";
|
|
2
|
+
// import AppLayoutReducer from "./features/common/AppLayoutSlice";
|
|
3
|
+
// import UserSessionReducer from "./features/common/UserSessionSlice";
|
|
4
|
+
// import LoadingMaskReducer from "./features/common/LoadingMaskSlice";
|
|
5
|
+
// import CommonStoreReducer from "./features/common/CommonStoreSlice";
|
|
6
|
+
// import AppInfoReducer from "./features/common/AppInfoSlice";
|
|
7
7
|
|
|
8
|
-
const reducers = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
8
|
+
// const reducers = {
|
|
9
|
+
// AppLayout: AppLayoutReducer,
|
|
10
|
+
// UserSession: UserSessionReducer,
|
|
11
|
+
// loadingMask: LoadingMaskReducer,
|
|
12
|
+
// commonStores: CommonStoreReducer,
|
|
13
|
+
// AppInfo: AppInfoReducer,
|
|
14
|
+
// };
|
|
15
15
|
|
|
16
|
-
export function addReducer(key: string, reducer: Reducer<any>) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
16
|
+
// export function addReducer(key: string, reducer: Reducer<any>) {
|
|
17
|
+
// debugger;
|
|
18
|
+
// // if (!reducers[key]) {
|
|
19
|
+
// reducers[key] = reducer;
|
|
20
|
+
// // }
|
|
21
|
+
// }
|
|
21
22
|
|
|
22
|
-
export const store = configureStore({
|
|
23
|
-
|
|
24
|
-
});
|
|
23
|
+
// export const store = configureStore({
|
|
24
|
+
// reducer: reducers,
|
|
25
|
+
// });
|
|
25
26
|
|
|
26
|
-
// Infer the `RootState` and `AppDispatch` types from the store itself
|
|
27
|
-
export type RootState = ReturnType<typeof store.getState>;
|
|
28
|
-
export type AppDispatch = typeof store.dispatch;
|
|
27
|
+
// // Infer the `RootState` and `AppDispatch` types from the store itself
|
|
28
|
+
// export type RootState = ReturnType<typeof store.getState>;
|
|
29
|
+
// export type AppDispatch = typeof store.dispatch;
|
package/src/util/constants.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
export const DATE_FORMAT = "YYYY-MM-DD";
|
|
2
|
-
export const DATE_TIME_FORMAT = "YYYY-MM-DD HH:mm:ss";
|
|
2
|
+
export const DATE_TIME_FORMAT = "YYYY-MM-DD HH:mm:ss";
|
|
3
|
+
export const LIGHT_THEME_INITIAL_MAIN_COLOR = "#37505C";
|
|
4
|
+
export const LIGHT_THEME_INITIAL_SECANDARY_COLOR = "#ff6d00";
|
|
5
|
+
export const DARK_THEME_INITIAL_MAIN_COLOR = "#ea690e";
|
|
6
|
+
export const DARK_THEME_INITIAL_SECANDARY_COLOR = "#74776B";
|