datastake-daf 0.6.765 → 0.6.766

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.
Files changed (57) hide show
  1. package/dist/components/index.js +312 -143
  2. package/dist/layouts/index.js +0 -3
  3. package/dist/pages/index.js +206 -219
  4. package/dist/services/index.js +18 -0
  5. package/dist/utils/index.js +312 -4
  6. package/package.json +1 -2
  7. package/src/@daf/core/components/Charts/BarChart/index.jsx +4 -0
  8. package/src/@daf/core/components/Dashboard/Map/ChainIcon/index.js +0 -7
  9. package/src/@daf/core/components/Graphs/StakeholderMappings/index.jsx +0 -2
  10. package/src/@daf/core/components/Graphs/components/BaseGraph.jsx +3 -4
  11. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/KeyIndicatorsWidget/config.js +2 -2
  12. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/KeyIndicatorsWidget/index.jsx +1 -1
  13. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserActivity/helper.js +4 -1
  14. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserActivity/index.jsx +5 -0
  15. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/index.jsx +1 -0
  16. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/index.jsx +34 -26
  17. package/src/@daf/core/components/Screens/Admin/AdminDashboard/index.jsx +56 -52
  18. package/src/@daf/core/components/Screens/Admin/AdminScreens/Dashboard.jsx +52 -67
  19. package/src/@daf/core/components/Screens/Admin/AdminScreens/Location.jsx +96 -0
  20. package/src/@daf/core/components/Screens/Admin/AdminScreens/Subjects.jsx +96 -0
  21. package/src/@daf/core/components/Screens/Admin/AdminScreens/index.js +2 -1
  22. package/src/@daf/core/components/Screens/Admin/adminRoutes.js +116 -89
  23. package/src/@daf/core/components/Table/MoreTags/index.jsx +17 -5
  24. package/src/@daf/layouts/AuthLayout/components/Navbar/index.jsx +0 -1
  25. package/src/@daf/pages/Dashboards/SupplyChain/components/ChartsContainer/components/Identification/hook.js +10 -10
  26. package/src/@daf/pages/Dashboards/SupplyChain/components/SupplyChainMap/index.js +6 -3
  27. package/src/@daf/pages/Dashboards/UserDashboard/components/ContributionsGraph/helper.js +1 -14
  28. package/src/@daf/pages/Dashboards/UserDashboard/components/ContributionsGraph/hook.js +12 -5
  29. package/src/@daf/pages/Dashboards/UserDashboard/components/MineSites/index.jsx +1 -1
  30. package/src/@daf/pages/Dashboards/UserDashboard/components/Triangulation/hook.js +1 -1
  31. package/src/@daf/pages/Data/Channels/columns.js +175 -0
  32. package/src/@daf/pages/Data/Channels/config.js +0 -0
  33. package/src/@daf/pages/Data/Channels/create.jsx +0 -0
  34. package/src/@daf/pages/Data/Channels/index.jsx +0 -0
  35. package/src/@daf/pages/Events/Activities/columns.js +1 -4
  36. package/src/@daf/pages/Events/helper.js +3 -2
  37. package/src/@daf/pages/Events/index.jsx +1 -1
  38. package/src/@daf/pages/Locations/MineSite/columns.js +6 -4
  39. package/src/@daf/pages/Stakeholders/Operators/columns.js +4 -2
  40. package/src/@daf/pages/Summary/Activities/PlantingCycle/index.jsx +1 -0
  41. package/src/@daf/pages/Summary/Minesite/components/StakeholderMapping/config.js +2 -2
  42. package/src/@daf/pages/Summary/Minesite/components/StakeholderMapping/helper.js +7 -7
  43. package/src/@daf/pages/Summary/Minesite/components/StakeholderMapping/index.js +3 -2
  44. package/src/@daf/pages/Summary/Minesite/index.jsx +3 -1
  45. package/src/@daf/pages/Summary/Operator/components/Governance/index.js +0 -1
  46. package/src/@daf/pages/Summary/Operator/components/KeyInformation/config.js +33 -21
  47. package/src/@daf/pages/Summary/Operator/components/TradeRelationships/helper.js +13 -13
  48. package/src/@daf/pages/Summary/Operator/components/TradeRelationships/hook.js +8 -8
  49. package/src/@daf/pages/Summary/Operator/components/TradeRelationships/index.js +5 -2
  50. package/src/@daf/pages/Summary/Operator/index.jsx +3 -0
  51. package/src/@daf/pages/Summary/components/InformationAvailability/index.js +4 -3
  52. package/src/@daf/services/AdminService.js +14 -0
  53. package/src/constants/locales/en/translation.js +104 -2
  54. package/src/constants/locales/fr/translation.js +104 -1
  55. package/src/constants/locales/sp/translation.js +104 -1
  56. package/src/index.js +2 -0
  57. package/dist/style/datastake/mapbox-gl.css +0 -330
@@ -5,60 +5,64 @@ import KeyIndicatorsWidget from "./components/KeyIndicatorsWidget/index.jsx";
5
5
  import UserStatistics from "./components/UserStatistics/index.jsx";
6
6
 
7
7
  export default function AdminDashboard({
8
- actionWidgetConfig,
9
- loading,
10
- data,
11
- goTo,
12
- adminTranslationIdentifier,
13
- t,
14
- loadingUserGrowth,
15
- fetchUserGrowth = () => {},
8
+ actionWidgetConfig,
9
+ loading,
10
+ data,
11
+ goTo,
12
+ adminTranslationIdentifier,
13
+ t,
14
+ loadingUserGrowth,
15
+ fetchUserGrowth = () => {},
16
+ userGrowthData,
16
17
  }) {
17
- const { keyIndicatorsData } = data;
18
+ const keyIndicatorsCards = Array.isArray(data?.keyIndicatorsData)
19
+ ? data.keyIndicatorsData
20
+ : [];
18
21
 
19
- return (
20
- <div className="daf-analysis admin-dashboard">
21
- <Header title={t(`${adminTranslationIdentifier}::dashboard`)} />
22
- <div className="content">
23
- <div className="view-content">
24
- <div className="daf-analysis-layout">
25
- <div className="sections-cont w-pt">
26
- <section>
27
- {actionWidgetConfig.map((widgetConfig) => {
28
- return (
29
- <ActionWidget
30
- key={widgetConfig.title}
31
- {...widgetConfig}
32
- onClick={() => goTo(widgetConfig.goToPath)}
33
- title={t(`admin::${widgetConfig.title}`)}
34
- />
35
- );
36
- })}
37
- </section>
22
+ console.log("AdminDashboard:data", data);
38
23
 
39
- <section>
40
- <KeyIndicatorsWidget
41
- data={keyIndicatorsData}
42
- loading={loading}
43
- goTo={goTo}
44
- t={t}
45
- />
46
- </section>
24
+ return (
25
+ <div className="daf-analysis admin-dashboard">
26
+ <Header title={t(`${adminTranslationIdentifier}::dashboard`)} />
27
+ <div className="content">
28
+ <div className="view-content">
29
+ <div className="daf-analysis-layout">
30
+ <div className="sections-cont w-pt">
31
+ <section>
32
+ {actionWidgetConfig.map((widgetConfig) => (
33
+ <ActionWidget
34
+ key={widgetConfig.title}
35
+ {...widgetConfig}
36
+ onClick={() => goTo(widgetConfig.goToPath)}
37
+ title={t(`${widgetConfig.title}`)}
38
+ />
39
+ ))}
40
+ </section>
47
41
 
48
- <section>
49
- <UserStatistics
50
- data={data}
51
- loading={loading}
52
- t={t}
53
- loadingUserGrowth={loadingUserGrowth}
54
- fetchUserGrowth={fetchUserGrowth}
55
- translationKeys={adminTranslationIdentifier}
56
- ></UserStatistics>
57
- </section>
58
- </div>
59
- </div>
60
- </div>
61
- </div>
62
- </div>
63
- );
42
+ <section>
43
+ <KeyIndicatorsWidget
44
+ data={keyIndicatorsCards}
45
+ loading={loading}
46
+ goTo={goTo}
47
+ t={t}
48
+ />
49
+ </section>
50
+
51
+ <section>
52
+ <UserStatistics
53
+ data={{ ...data }}
54
+ userGrowthData={userGrowthData}
55
+ loading={loading}
56
+ t={t}
57
+ loadingUserGrowth={loadingUserGrowth}
58
+ fetchUserGrowth={fetchUserGrowth}
59
+ translationKeys={adminTranslationIdentifier}
60
+ />
61
+ </section>
62
+ </div>
63
+ </div>
64
+ </div>
65
+ </div>
66
+ </div>
67
+ );
64
68
  }
@@ -1,77 +1,62 @@
1
1
  import React, { useMemo } from "react";
2
2
  import AdminDashboard from "../AdminDashboard/index.jsx";
3
3
 
4
- /**
5
- * Admin Dashboard Screen Wrapper
6
- * This is a ready-to-use route component that can be configured per application
7
- *
8
- * @param {Object} config - Application configuration
9
- * @param {string} config.appName - Application name for translations (e.g., "wazi", "tazama")
10
- * @param {Function} config.goTo - Navigation function (useNavigate)
11
- * @param {Function} config.t - Translation function (useTranslation)
12
- * @param {Function} config.getRedirectLink - Function to get redirect links
13
- * @param {Function} config.getActionWidgetsConfig - Function that returns action widgets config
14
- * @param {Function} config.getKeyIndicatorsConfig - Function that returns key indicators config
15
- * @param {Function} config.useWidgetFetch - Hook to fetch dashboard data
16
- */
17
4
  export default function AdminDashboardScreen({ config }) {
18
- const {
19
- appName = "app",
20
- goTo,
21
- t,
22
- getRedirectLink,
23
- getActionWidgetsConfig,
24
- getKeyIndicatorsConfig,
25
- useWidgetFetch,
26
- } = config;
5
+ const {
6
+ appName = "app",
7
+ goTo,
8
+ t,
9
+ getRedirectLink,
10
+ getActionWidgetsConfig,
11
+ getKeyIndicatorsConfig,
12
+ useWidgetFetch,
13
+ } = config;
27
14
 
28
- const {
29
- data,
30
- loading,
31
- userGrowthData,
32
- fetchUserGrowth,
33
- userGrowthDataLoading,
34
- } = useWidgetFetch();
15
+ const {
16
+ data,
17
+ loading,
18
+ userGrowthData,
19
+ fetchUserGrowth,
20
+ userGrowthDataLoading,
21
+ } = useWidgetFetch();
35
22
 
36
- const actionsWidgetsConfig = useMemo(
37
- () => getActionWidgetsConfig({ getRedirectLink }),
38
- [getRedirectLink]
39
- );
23
+ console.log({userGrowthData});
40
24
 
41
- const keyIndicatorsConfig = useMemo(
42
- () =>
43
- getKeyIndicatorsConfig({
44
- getRedirectLink,
45
- keyIndicatorsData: data?.keyInformation,
46
- }),
47
- [data?.keyInformation, getRedirectLink]
48
- );
25
+ const actionsWidgetsConfig = useMemo(
26
+ () => getActionWidgetsConfig({ getRedirectLink }),
27
+ [getRedirectLink, getActionWidgetsConfig]
28
+ );
49
29
 
50
- // Dummy data for top contributors if not provided
51
- const TOTAL_DUMMY = [
52
- { label: "Contributor 1", Score: 0 },
53
- { label: "Contributor 2", Score: 0 },
54
- { label: "Contributor 3", Score: 0 },
55
- { label: "Contributor 4", Score: 0 },
56
- { label: "Contributor 5", Score: 0 },
57
- ];
30
+ const keyIndicatorsConfig = useMemo(
31
+ () =>
32
+ getKeyIndicatorsConfig({
33
+ getRedirectLink,
34
+ keyIndicators: data?.keyIndicators ?? data?.keyInformation,
35
+ }),
36
+ [data?.keyIndicators, data?.keyInformation, getRedirectLink, getKeyIndicatorsConfig]
37
+ );
38
+
39
+ const safeUserActivity = Array.isArray(data?.data?.userActivity) ? data.data.userActivity : [];
40
+ const safeTopContributors = Array.isArray(data?.topContributors) ? data.topContributors : [];
41
+ const safeUserGrowth = Array.isArray(data?.userGrowthData) ? data.userGrowthData : [];
58
42
 
59
- return (
60
- <AdminDashboard
61
- t={t}
62
- loading={loading}
63
- goTo={goTo}
64
- actionWidgetConfig={actionsWidgetsConfig}
65
- loadingUserGrowth={userGrowthDataLoading}
66
- fetchUserGrowth={fetchUserGrowth}
67
- data={{
68
- keyIndicatorsData: keyIndicatorsConfig,
69
- userActivityData: data?.userActivity,
70
- topContributorsData: data?.topContributors || TOTAL_DUMMY,
71
- userGrowthData: userGrowthData,
72
- }}
73
- adminTranslationIdentifier={appName}
74
- />
75
- );
76
- }
77
43
 
44
+ return (
45
+ <AdminDashboard
46
+ t={t}
47
+ goTo={goTo}
48
+ loading={loading}
49
+ actionWidgetConfig={actionsWidgetsConfig}
50
+ loadingUserGrowth={userGrowthDataLoading}
51
+ fetchUserGrowth={fetchUserGrowth}
52
+ adminTranslationIdentifier={appName}
53
+ data={{
54
+ keyIndicatorsData: keyIndicatorsConfig,
55
+ userActivityData: safeUserActivity,
56
+ topContributorsData: safeTopContributors,
57
+ userGrowthData: safeUserGrowth,
58
+ data: data,
59
+ }}
60
+ />
61
+ );
62
+ }
@@ -0,0 +1,96 @@
1
+ import React, { useCallback } from "react";
2
+ import { message } from "antd";
3
+ import LocationTable from "../AdminTables/LocationTable/index.jsx";
4
+
5
+ /**
6
+ * Admin Location Screen Wrapper
7
+ * This is a ready-to-use route component that can be configured per application
8
+ *
9
+ * @param {Object} config - Application configuration
10
+ * @param {string} config.appName - Application name
11
+ * @param {string} config.module - Module identifier (APP constant)
12
+ * @param {Function} config.goTo - Navigation function
13
+ * @param {Function} config.t - Translation function
14
+ * @param {Object} config.location - Router location object
15
+ * @param {boolean} config.isMobile - Is mobile viewport
16
+ * @param {Function} config.getRedirectLink - Function to get redirect links
17
+ * @param {Object} config.AdminService - Admin service with methods
18
+ * @param {Object} config.options - Options object with categories, countries, etc.
19
+ * @param {Function} config.handleError - Error handling function
20
+ * @param {number} config.defaultPageSize - Default pagination page size
21
+ * @param {string} config.view - View identifier
22
+ * @param {string} config.headerTitle - Header title for the table
23
+ * @param {Array} config.breadcrumbs - Breadcrumbs configuration
24
+ * @param {any} config.refetchTrigger - Trigger to refetch data
25
+ * @param {Function} config.getData - Optional custom getData function
26
+ */
27
+ export default function AdminLocationScreen({ config }) {
28
+ const {
29
+ appName = "app",
30
+ module,
31
+ goTo,
32
+ t,
33
+ location,
34
+ isMobile,
35
+ getRedirectLink,
36
+ AdminService,
37
+ options,
38
+ handleError,
39
+ defaultPageSize = 20,
40
+ view,
41
+ headerTitle = "location",
42
+ breadcrumbs,
43
+ refetchTrigger,
44
+ getData
45
+ } = config;
46
+
47
+ const handleMergeLocations = useCallback(
48
+ async (mergeData) => {
49
+ try {
50
+ if (AdminService.mergeLocations) {
51
+ await AdminService.mergeLocations(mergeData);
52
+ message.success(t("Locations merged successfully"));
53
+ } else {
54
+ console.warn("AdminService.mergeLocations is not implemented");
55
+ message.success(t("Locations merged successfully"));
56
+ }
57
+ } catch (err) {
58
+ handleError?.(err);
59
+ }
60
+ },
61
+ [AdminService, t, handleError]
62
+ );
63
+
64
+ // Use custom getData if provided, otherwise use default AdminService.getLocations
65
+ const getLocations = useCallback((params) => {
66
+ if (getData) {
67
+ return getData(params);
68
+ }
69
+ return AdminService.getLocations(params);
70
+ }, [getData, AdminService]);
71
+
72
+ return (
73
+ <LocationTable
74
+ t={t}
75
+ goTo={goTo}
76
+ getRedirectLink={getRedirectLink}
77
+ location={location}
78
+ module={module}
79
+ headerTitle={headerTitle}
80
+ getData={getLocations}
81
+ isMobile={isMobile}
82
+ defaultPageSize={defaultPageSize}
83
+ view={view}
84
+ breadcrumbs={breadcrumbs}
85
+ mergeSubjectsFunction={handleMergeLocations}
86
+ refetchTrigger={refetchTrigger}
87
+ config={{
88
+ options: {
89
+ category: options?.category,
90
+ countries: options?.countries,
91
+ },
92
+ }}
93
+ />
94
+ );
95
+ }
96
+
@@ -0,0 +1,96 @@
1
+ import React, { useCallback } from "react";
2
+ import { message } from "antd";
3
+ import SubjectsTable from "../AdminTables/SubjectsTable/index.jsx";
4
+
5
+ /**
6
+ * Admin Subjects Screen Wrapper
7
+ * This is a ready-to-use route component that can be configured per application
8
+ *
9
+ * @param {Object} config - Application configuration
10
+ * @param {string} config.appName - Application name
11
+ * @param {string} config.module - Module identifier (APP constant)
12
+ * @param {Function} config.goTo - Navigation function
13
+ * @param {Function} config.t - Translation function
14
+ * @param {Object} config.location - Router location object
15
+ * @param {boolean} config.isMobile - Is mobile viewport
16
+ * @param {Function} config.getRedirectLink - Function to get redirect links
17
+ * @param {Object} config.AdminService - Admin service with methods
18
+ * @param {Object} config.options - Options object with categories, countries, etc.
19
+ * @param {Function} config.handleError - Error handling function
20
+ * @param {number} config.defaultPageSize - Default pagination page size
21
+ * @param {string} config.view - View identifier
22
+ * @param {string} config.headerTitle - Header title for the table
23
+ * @param {Array} config.breadcrumbs - Breadcrumbs configuration
24
+ * @param {any} config.refetchTrigger - Trigger to refetch data
25
+ * @param {Function} config.getData - Optional custom getData function
26
+ */
27
+ export default function AdminSubjectsScreen({ config }) {
28
+ const {
29
+ appName = "app",
30
+ module,
31
+ goTo,
32
+ t,
33
+ location,
34
+ isMobile,
35
+ getRedirectLink,
36
+ AdminService,
37
+ options,
38
+ handleError,
39
+ defaultPageSize = 20,
40
+ view,
41
+ headerTitle = "subjects",
42
+ breadcrumbs,
43
+ refetchTrigger,
44
+ getData,
45
+ } = config;
46
+
47
+ const handleMergeSubjects = useCallback(
48
+ async (mergeData) => {
49
+ try {
50
+ if (AdminService.mergeSubjects) {
51
+ await AdminService.mergeSubjects(mergeData);
52
+ message.success(t("Subjects merged successfully"));
53
+ } else {
54
+ console.warn("AdminService.mergeSubjects is not implemented");
55
+ message.success(t("Subjects merged successfully"));
56
+ }
57
+ } catch (err) {
58
+ handleError?.(err);
59
+ }
60
+ },
61
+ [AdminService, t, handleError]
62
+ );
63
+
64
+ // Use custom getData if provided, otherwise use default AdminService.getSubjects
65
+ const getSubjects = useCallback((params) => {
66
+ if (getData) {
67
+ return getData(params);
68
+ }
69
+ return AdminService.getSubjects(params);
70
+ }, [getData, AdminService]);
71
+
72
+ return (
73
+ <SubjectsTable
74
+ t={t}
75
+ goTo={goTo}
76
+ getRedirectLink={getRedirectLink}
77
+ location={location}
78
+ module={module}
79
+ headerTitle={headerTitle}
80
+ getData={getSubjects}
81
+ isMobile={isMobile}
82
+ defaultPageSize={defaultPageSize}
83
+ view={view}
84
+ breadcrumbs={breadcrumbs}
85
+ mergeSubjectsFunction={handleMergeSubjects}
86
+ refetchTrigger={refetchTrigger}
87
+ config={{
88
+ options: {
89
+ category: options?.category,
90
+ countries: options?.countries,
91
+ },
92
+ }}
93
+ />
94
+ );
95
+ }
96
+
@@ -8,4 +8,5 @@ export { default as AdminDashboardScreen } from "./Dashboard.jsx";
8
8
  export { default as AdminUsersScreen } from "./Users.jsx";
9
9
  export { default as AdminAccountsScreen } from "./Accounts.jsx";
10
10
  export { default as AdminAccountsViewScreen } from "./AccountsView.jsx";
11
-
11
+ export { default as AdminSubjectsScreen } from "./Subjects.jsx";
12
+ export { default as AdminLocationScreen } from "./Location.jsx";
@@ -3,102 +3,129 @@ import AdminDashboardScreen from "./AdminScreens/Dashboard.jsx";
3
3
  import AdminUsersScreen from "./AdminScreens/Users.jsx";
4
4
  import AdminAccountsScreen from "./AdminScreens/Accounts.jsx";
5
5
  import AdminAccountsViewScreen from "./AdminScreens/AccountsView.jsx";
6
+ import AdminSubjectsScreen from "./AdminScreens/Subjects.jsx";
7
+ import AdminLocationScreen from "./AdminScreens/Location.jsx";
6
8
 
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 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
9
  export function getAdminRoutes(config) {
41
- const {
42
- appName,
43
- useAdminDashboardConfig,
44
- useAdminUsersConfig,
45
- useAdminAccountsConfig,
46
- useAdminAccountsViewConfig,
47
- userIsAdmin,
48
- } = config;
10
+ const {
11
+ appName,
12
+ useAdminDashboardConfig,
13
+ useAdminUsersConfig,
14
+ useAdminAccountsConfig,
15
+ useAdminAccountsViewConfig,
16
+ useAdminSubjectsConfig,
17
+ useAdminLocationConfig,
18
+ userIsAdmin,
19
+ } = config;
49
20
 
50
- const APP_PREFIX = `APP_${appName.toUpperCase()}`;
21
+ const APP_PREFIX = `APP_${appName.toUpperCase()}`;
51
22
 
52
- // Wrapper components that use the configuration hooks
53
- function DashboardWrapper() {
54
- const dashboardConfig = useAdminDashboardConfig();
55
- return <AdminDashboardScreen config={dashboardConfig} />;
56
- }
23
+ function DashboardWrapper() {
24
+ const dashboardConfig = useAdminDashboardConfig();
25
+ return <AdminDashboardScreen config={dashboardConfig} />;
26
+ }
57
27
 
58
- function UsersWrapper() {
59
- const usersConfig = useAdminUsersConfig();
60
- return <AdminUsersScreen config={usersConfig} />;
61
- }
28
+ function UsersWrapper() {
29
+ const usersConfig = useAdminUsersConfig();
30
+ return <AdminUsersScreen config={usersConfig} />;
31
+ }
62
32
 
63
- function AccountsWrapper() {
64
- const accountsConfig = useAdminAccountsConfig();
65
- return <AdminAccountsScreen config={accountsConfig} />;
66
- }
33
+ function AccountsWrapper() {
34
+ const accountsConfig = useAdminAccountsConfig();
35
+ return <AdminAccountsScreen config={accountsConfig} />;
36
+ }
67
37
 
68
- function AccountsViewWrapper() {
69
- const accountsViewConfig = useAdminAccountsViewConfig();
70
- return <AdminAccountsViewScreen config={accountsViewConfig} />;
71
- }
38
+ function AccountsViewWrapper() {
39
+ const accountsViewConfig = useAdminAccountsViewConfig();
40
+ return <AdminAccountsViewScreen config={accountsViewConfig} />;
41
+ }
72
42
 
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
- ];
43
+ function SubjectsWrapper() {
44
+ const subjectsConfig =
45
+ typeof useAdminSubjectsConfig === "function"
46
+ ? useAdminSubjectsConfig()
47
+ : undefined;
48
+ return <AdminSubjectsScreen config={subjectsConfig} />;
49
+ }
50
+
51
+ function LocationWrapper() {
52
+ const locationConfig =
53
+ typeof useAdminLocationConfig === "function"
54
+ ? useAdminLocationConfig()
55
+ : undefined;
56
+ return <AdminLocationScreen config={locationConfig} />;
57
+ }
58
+
59
+ const subjectsIndexComponent =
60
+ typeof useAdminLocationConfig === "function"
61
+ ? <LocationWrapper />
62
+ : typeof useAdminSubjectsConfig === "function"
63
+ ? <SubjectsWrapper />
64
+ : <div />;
65
+
66
+ const routes = [
67
+ {
68
+ path: "",
69
+ key: `${APP_PREFIX}_DASHBOARD`,
70
+ exact: true,
71
+ visible: (user) => userIsAdmin(user),
72
+ component: <DashboardWrapper />,
73
+ },
74
+ {
75
+ path: "accounts",
76
+ key: `${APP_PREFIX}_ACCOUNTS`,
77
+ exact: true,
78
+ visible: (user) => userIsAdmin(user),
79
+ component: <AccountsWrapper />,
80
+ },
81
+ {
82
+ path: "admin-users",
83
+ key: `${APP_PREFIX}_ADMIN_USERS`,
84
+ exact: true,
85
+ visible: (user) => userIsAdmin(user),
86
+ component: <UsersWrapper />,
87
+ },
88
+ {
89
+ path: "accounts/:mode/:id/:group",
90
+ key: `${APP_PREFIX}_ADMIN_VIEW`,
91
+ exact: true,
92
+ visible: (user) => userIsAdmin(user),
93
+ component: <AccountsViewWrapper />,
94
+ },
95
+
96
+ {
97
+ path: "subjects",
98
+ key: `${APP_PREFIX}_SUBJECTS_INDEX`,
99
+ exact: true,
100
+ visible: (user) => userIsAdmin(user),
101
+ component: subjectsIndexComponent,
102
+ },
103
+
104
+ ...(typeof useAdminLocationConfig === "function"
105
+ ? [
106
+ {
107
+ path: "subjects/location",
108
+ key: `${APP_PREFIX}_ADMIN_SUBJECTS_LOCATIONS`,
109
+ exact: true,
110
+ visible: (user) => userIsAdmin(user),
111
+ component: <LocationWrapper />,
112
+ },
113
+ ]
114
+ : []),
115
+ ...(typeof useAdminSubjectsConfig === "function"
116
+ ? [
117
+ {
118
+ path: "subjects/stakeholder",
119
+ key: `${APP_PREFIX}_ADMIN_SUBJECTS_STAKEHOLDERS`,
120
+ exact: true,
121
+ visible: (user) => userIsAdmin(user),
122
+ component: <SubjectsWrapper />,
123
+ },
124
+ ]
125
+ : []),
126
+ ];
127
+
128
+ return routes;
103
129
  }
104
130
 
131
+ export default getAdminRoutes;