datastake-daf 0.6.710 → 0.6.712
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/components/index.js +347 -8
- package/dist/hooks/index.js +19 -4673
- package/dist/pages/index.js +0 -15
- package/dist/services/index.js +0 -15
- package/dist/utils/index.js +0 -4
- package/package.json +1 -1
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Accounts.jsx +109 -0
- package/src/@daf/core/components/Screens/Admin/AdminScreens/AccountsView.jsx +73 -0
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Dashboard.jsx +77 -0
- package/src/@daf/core/components/Screens/Admin/AdminScreens/README.md +216 -0
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Users.jsx +117 -0
- package/src/@daf/core/components/Screens/Admin/AdminScreens/index.js +11 -0
- package/src/@daf/core/components/Screens/Admin/adminRoutes.js +104 -0
- package/src/@daf/services/DashboardService.js +0 -15
- package/src/helpers/StringHelper.js +0 -6
- package/src/index.js +19 -1
- package/src/utils.js +1 -1
- package/build/favicon.ico +0 -0
- package/build/logo192.png +0 -0
- package/build/logo512.png +0 -0
- package/build/manifest.json +0 -25
- package/build/robots.txt +0 -3
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import AdminDashboardScreen from "./AdminScreens/Dashboard.jsx";
|
|
3
|
+
import AdminUsersScreen from "./AdminScreens/Users.jsx";
|
|
4
|
+
import AdminAccountsScreen from "./AdminScreens/Accounts.jsx";
|
|
5
|
+
import AdminAccountsViewScreen from "./AdminScreens/AccountsView.jsx";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Generate Admin Routes for any application
|
|
9
|
+
*
|
|
10
|
+
* This function returns a complete set of admin routes that can be used directly
|
|
11
|
+
* in your application's route configuration. Just provide the configuration and
|
|
12
|
+
* you get back ready-to-use routes.
|
|
13
|
+
*
|
|
14
|
+
* @param {Object} config - Application-specific configuration
|
|
15
|
+
* @param {string} config.appName - Application name (e.g., "wazi", "tazama")
|
|
16
|
+
* @param {Function} config.useAdminDashboardConfig - Hook that returns dashboard config
|
|
17
|
+
* @param {Function} config.useAdminUsersConfig - Hook that returns users config
|
|
18
|
+
* @param {Function} config.useAdminAccountsConfig - Hook that returns accounts config
|
|
19
|
+
* @param {Function} config.useAdminAccountsViewConfig - Hook that returns accounts view config
|
|
20
|
+
* @param {Function} config.userIsAdmin - Function to check if user is admin
|
|
21
|
+
*
|
|
22
|
+
* @returns {Array} Array of route objects ready to be used with React Router
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```javascript
|
|
26
|
+
* import { getAdminRoutes } from "datastake-daf/dist/admin";
|
|
27
|
+
*
|
|
28
|
+
* const routes = getAdminRoutes({
|
|
29
|
+
* appName: "wazi",
|
|
30
|
+
* useAdminDashboardConfig,
|
|
31
|
+
* useAdminUsersConfig,
|
|
32
|
+
* useAdminAccountsConfig,
|
|
33
|
+
* useAdminAccountsViewConfig,
|
|
34
|
+
* userIsAdmin: (user) => user?.role === 'admin'
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* export default routes;
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export function getAdminRoutes(config) {
|
|
41
|
+
const {
|
|
42
|
+
appName,
|
|
43
|
+
useAdminDashboardConfig,
|
|
44
|
+
useAdminUsersConfig,
|
|
45
|
+
useAdminAccountsConfig,
|
|
46
|
+
useAdminAccountsViewConfig,
|
|
47
|
+
userIsAdmin,
|
|
48
|
+
} = config;
|
|
49
|
+
|
|
50
|
+
const APP_PREFIX = `APP_${appName.toUpperCase()}`;
|
|
51
|
+
|
|
52
|
+
// Wrapper components that use the configuration hooks
|
|
53
|
+
function DashboardWrapper() {
|
|
54
|
+
const dashboardConfig = useAdminDashboardConfig();
|
|
55
|
+
return <AdminDashboardScreen config={dashboardConfig} />;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function UsersWrapper() {
|
|
59
|
+
const usersConfig = useAdminUsersConfig();
|
|
60
|
+
return <AdminUsersScreen config={usersConfig} />;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function AccountsWrapper() {
|
|
64
|
+
const accountsConfig = useAdminAccountsConfig();
|
|
65
|
+
return <AdminAccountsScreen config={accountsConfig} />;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function AccountsViewWrapper() {
|
|
69
|
+
const accountsViewConfig = useAdminAccountsViewConfig();
|
|
70
|
+
return <AdminAccountsViewScreen config={accountsViewConfig} />;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return [
|
|
74
|
+
{
|
|
75
|
+
path: "",
|
|
76
|
+
key: `${APP_PREFIX}_DASHBOARD`,
|
|
77
|
+
exact: true,
|
|
78
|
+
visible: () => true,
|
|
79
|
+
component: <DashboardWrapper />,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
path: "accounts",
|
|
83
|
+
key: `${APP_PREFIX}_ACCOUNTS`,
|
|
84
|
+
exact: true,
|
|
85
|
+
visible: (user) => userIsAdmin(user),
|
|
86
|
+
component: <AccountsWrapper />,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
path: "admin-users",
|
|
90
|
+
key: `${APP_PREFIX}_ADMIN_USERS`,
|
|
91
|
+
exact: true,
|
|
92
|
+
visible: (user) => userIsAdmin(user),
|
|
93
|
+
component: <UsersWrapper />,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
path: "accounts/:mode/:id/:group",
|
|
97
|
+
key: `${APP_PREFIX}_ADMIN_VIEW`,
|
|
98
|
+
exact: true,
|
|
99
|
+
visible: (user) => userIsAdmin(user),
|
|
100
|
+
component: <AccountsViewWrapper />,
|
|
101
|
+
},
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
|
|
@@ -9,21 +9,6 @@ class DashboardService extends BaseService {
|
|
|
9
9
|
isApp: true,
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
getUserGrowth(activeFilter) {
|
|
14
|
-
return this.apiGet({
|
|
15
|
-
url: `/accounts/dashboard/user-growth`,
|
|
16
|
-
isUserManager: true,
|
|
17
|
-
params: { activeFilter },
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
getAdminDashboard() {
|
|
22
|
-
return this.apiGet({
|
|
23
|
-
url: `/accounts/dashboard`,
|
|
24
|
-
isUserManager: true,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
12
|
}
|
|
28
13
|
|
|
29
14
|
export default createLazyService(DashboardService);
|
package/src/index.js
CHANGED
|
@@ -146,13 +146,31 @@ export { default as StakeholderMappings } from "./@daf/core/components/Graphs/St
|
|
|
146
146
|
|
|
147
147
|
//* ------------------------------ Screens ------------------------------
|
|
148
148
|
export { default as BaseScreen } from "./@daf/core/components/Screens/BaseScreen/index.jsx";
|
|
149
|
-
// Admin
|
|
149
|
+
// Admin - Base Components
|
|
150
150
|
export { default as AdminDashboard } from "./@daf/core/components/Screens/Admin/AdminDashboard/index.jsx";
|
|
151
151
|
export { default as UserTable } from "./@daf/core/components/Screens/Admin/AdminTables/UserTable/index.jsx";
|
|
152
152
|
export { default as AccountTable } from "./@daf/core/components/Screens/Admin/AdminTables/AccountTable/index.jsx";
|
|
153
153
|
export { default as LocationTable } from "./@daf/core/components/Screens/Admin/AdminTables/LocationTable/index.jsx";
|
|
154
154
|
export { default as SubjectsTable } from "./@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/index.jsx";
|
|
155
155
|
export { default as AdminView } from "./@daf/core/components/Screens/Admin/AdminViews/index.jsx";
|
|
156
|
+
|
|
157
|
+
// Admin - Ready-to-use Screen Components (Route Wrappers)
|
|
158
|
+
export {
|
|
159
|
+
AdminDashboardScreen,
|
|
160
|
+
AdminUsersScreen,
|
|
161
|
+
AdminAccountsScreen,
|
|
162
|
+
AdminAccountsViewScreen,
|
|
163
|
+
} from "./@daf/core/components/Screens/Admin/AdminScreens/index.js";
|
|
164
|
+
|
|
165
|
+
// Admin - Modals
|
|
166
|
+
export {
|
|
167
|
+
AddAccountModal,
|
|
168
|
+
AddUserModal,
|
|
169
|
+
AddUserToAccountModal,
|
|
170
|
+
} from "./@daf/core/components/Screens/Admin/AdminModals/index.js";
|
|
171
|
+
|
|
172
|
+
// Admin - Routes Generator
|
|
173
|
+
export { getAdminRoutes } from "./@daf/core/components/Screens/Admin/adminRoutes.js";
|
|
156
174
|
//Error
|
|
157
175
|
export { default as NotFound } from "./@daf/core/components/Screens/NotFound/index.jsx";
|
|
158
176
|
export { default as InformationUnavailable } from "./@daf/core/components/Screens/InformationUnavailable/index.jsx";
|
package/src/utils.js
CHANGED
|
@@ -9,7 +9,7 @@ export { renderTooltip, renderTooltipJsx } from './@daf/utils/tooltip'
|
|
|
9
9
|
export { getRangeOfTicks } from './helpers/chart'
|
|
10
10
|
|
|
11
11
|
export { propHasValue } from './helpers/deepFind'
|
|
12
|
-
export { isEmptyOrSpaces, capitalizeAll, capitalize, camelCaseToTitle, snakeCaseToTitleCase, titleToCamelCase, findOptions, getOptionAsObject, nowToIso, renderTemplateString, renderTemplateStringInObject, truncateString, splitStringInMultipleLines, safeJsonParse, cleanJSON
|
|
12
|
+
export { isEmptyOrSpaces, capitalizeAll, capitalize, camelCaseToTitle, snakeCaseToTitleCase, titleToCamelCase, findOptions, getOptionAsObject, nowToIso, renderTemplateString, renderTemplateStringInObject, truncateString, splitStringInMultipleLines, safeJsonParse, cleanJSON } from './helpers/StringHelper.js'
|
|
13
13
|
export { getNkey, groupSubsections, getImageUploadViewValue } from './@daf/core/components/ViewForm/helper'
|
|
14
14
|
export { renderRows } from './@daf/core/components/Table/helper'
|
|
15
15
|
export { filterOptions, filterString, hasNotChanged, filterSelectOptions, mapSubGroupsInSubmit, mapSubGroupsInGet, filterCreateData, changeInputMeta, renderDateFormatted } from './helpers/Forms'
|
package/build/favicon.ico
DELETED
|
Binary file
|
package/build/logo192.png
DELETED
|
Binary file
|
package/build/logo512.png
DELETED
|
Binary file
|
package/build/manifest.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"short_name": "React App",
|
|
3
|
-
"name": "Create React App Sample",
|
|
4
|
-
"icons": [
|
|
5
|
-
{
|
|
6
|
-
"src": "favicon.ico",
|
|
7
|
-
"sizes": "64x64 32x32 24x24 16x16",
|
|
8
|
-
"type": "image/x-icon"
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"src": "logo192.png",
|
|
12
|
-
"type": "image/png",
|
|
13
|
-
"sizes": "192x192"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"src": "logo512.png",
|
|
17
|
-
"type": "image/png",
|
|
18
|
-
"sizes": "512x512"
|
|
19
|
-
}
|
|
20
|
-
],
|
|
21
|
-
"start_url": ".",
|
|
22
|
-
"display": "standalone",
|
|
23
|
-
"theme_color": "#000000",
|
|
24
|
-
"background_color": "#ffffff"
|
|
25
|
-
}
|
package/build/robots.txt
DELETED