datastake-daf 0.6.835 → 0.6.837

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 (34) hide show
  1. package/dist/components/index.js +2327 -2204
  2. package/dist/hooks/index.js +7 -8
  3. package/dist/pages/index.js +409 -192
  4. package/dist/services/index.js +7 -8
  5. package/package.json +1 -1
  6. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/hook.js +3 -3
  7. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/index.jsx +2 -2
  8. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/index.jsx +2 -6
  9. package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/index.jsx +0 -1
  10. package/src/@daf/{core/components/Screens → pages/Dashboards}/ConflictManagement/components/KeyIndicators/config.js +2 -3
  11. package/src/@daf/{core/components/Screens → pages/Dashboards}/ConflictManagement/components/KeyIndicators/index.js +2 -2
  12. package/src/@daf/{core/components/Screens → pages/Dashboards}/ConflictManagement/components/MineSite/index.js +3 -3
  13. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/IncidentsTime/config.js +206 -0
  14. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/IncidentsTime/hook.js +48 -0
  15. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/IncidentsTime/index.js +154 -0
  16. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/ProblemSolver/hook.js +83 -0
  17. package/src/@daf/{core/components/Screens → pages/Dashboards}/ConflictManagement/components/RisksWidget/components/ProblemSolver/index.js +14 -7
  18. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/TerritorialDistribution/config.js +10 -0
  19. package/src/@daf/{core/components/Screens → pages/Dashboards}/ConflictManagement/components/RisksWidget/components/TerritorialDistribution/index.js +18 -13
  20. package/src/@daf/{core/components/Screens → pages/Dashboards}/ConflictManagement/components/RisksWidget/index.js +1 -1
  21. package/src/@daf/{core/components/Screens → pages/Dashboards}/ConflictManagement/index.js +17 -19
  22. package/src/@daf/services/DashboardService.js +8 -8
  23. package/src/pages.js +1 -1
  24. package/build/favicon.ico +0 -0
  25. package/build/logo192.png +0 -0
  26. package/build/logo512.png +0 -0
  27. package/build/manifest.json +0 -25
  28. package/build/robots.txt +0 -3
  29. package/src/@daf/core/components/Screens/ConflictManagement/components/RisksWidget/components/IncidentsTime/hook.js +0 -32
  30. package/src/@daf/core/components/Screens/ConflictManagement/components/RisksWidget/components/IncidentsTime/index.js +0 -73
  31. package/src/@daf/core/components/Screens/ConflictManagement/components/RisksWidget/components/ProblemSolver/hook.js +0 -86
  32. package/src/@daf/core/components/Screens/ConflictManagement/components/RisksWidget/components/TerritorialDistribution/config.js +0 -34
  33. /package/src/@daf/{core/components/Screens → pages/Dashboards}/ConflictManagement/components/MineSite/helper.js +0 -0
  34. /package/src/@daf/{core/components/Screens → pages/Dashboards}/ConflictManagement/components/RisksWidget/config.js +0 -0
@@ -1,32 +1,38 @@
1
1
  import React, { useMemo, useCallback } from 'react'
2
2
  import PropTypes from 'prop-types';
3
- import { renderTooltipJsx } from '../../../../../../../../utils/tooltip.js';
4
- import Widget from '../../../../../../../../core/components/Dashboard/Widget/index.jsx';
5
- import Chart from '../../../../../../../../core/components/Charts/PieChart/chart.jsx';
6
- import {useWidgetFetch} from '../../../../../../../../hooks/useWidgetFetch.js';
3
+ import { renderTooltipJsx } from '../../../../../../../utils/tooltip.js';
4
+ import Widget from '../../../../../../../core/components/Dashboard/Widget/index.jsx';
5
+ import Chart from '../../../../../../../core/components/Charts/PieChart/chart.jsx';
6
+ import {useWidgetFetch} from '../../../../../../../hooks/useWidgetFetch.js';
7
+ import DashboardService from '../../../../../../../services/DashboardService.js';
7
8
  import { getColors } from './config.js';
8
- import useTerritorialDistribution from './config.js';
9
9
 
10
10
  function TerritorialDistribution({ selectedPartners = {}, loading: parentLoading = false, t = (s) => s, theme = {}, category = "conflict", selectedRange ,goTo = () => {}, getRedirectLink = () => {}}) {
11
- const { filters, filtersConfig } = useTerritorialDistribution({ t });
12
11
  const colors = getColors(theme);
13
12
 
14
13
  const defaultFetchConfig = useMemo(
15
14
  () => ({
16
15
  url: "/territorial-distribution",
16
+ basepath: "dashboard/conflict-management",
17
17
  filters: {
18
- ...filters,
19
18
  category,
20
19
  period: selectedRange,
21
20
  sources: selectedPartners?.partners || [],
22
21
  },
23
- defaultData: [],
22
+ defaultData: {},
24
23
  stop: selectedPartners?.loading,
25
24
  }),
26
- [filters, category, selectedRange, selectedPartners],
25
+ [category, selectedRange, selectedPartners],
27
26
  );
28
27
 
29
- const { data, loading } = useWidgetFetch({ config: defaultFetchConfig });
28
+ const getData = useCallback(({ url, filters, basepath }) => {
29
+ return DashboardService.getWidgetConflictManagement(url, filters, basepath);
30
+ }, []);
31
+
32
+ const { data, loading } = useWidgetFetch({
33
+ config: defaultFetchConfig,
34
+ getData
35
+ });
30
36
 
31
37
  const pieData = useMemo(() => {
32
38
  if (!data || Array.isArray(data)) return [];
@@ -50,7 +56,7 @@ function TerritorialDistribution({ selectedPartners = {}, loading: parentLoading
50
56
  const isEmpty = !pieData.length;
51
57
 
52
58
  const getTooltipChildren = useCallback((items) => {
53
- const item = items[0];
59
+ const item = Array.isArray(items) ? items[0] : items;
54
60
 
55
61
  return renderTooltipJsx({
56
62
  title: item?.label || t("Undetermined"),
@@ -58,7 +64,7 @@ function TerritorialDistribution({ selectedPartners = {}, loading: parentLoading
58
64
  onClickLink: () => {
59
65
  if (item?.label) {
60
66
  goTo(
61
- `/app/incident?administrativeLevel1=${item?.locationData?.administrativeLevel1}&administrativeLevel2=${item?.locationData?.administrativeLevel2}&country=${item?.locationData?.country}`,
67
+ `/app/incidents?administrativeLevel1=${item?.locationData?.administrativeLevel1}&administrativeLevel2=${item?.locationData?.administrativeLevel2}&country=${item?.locationData?.country}`,
62
68
  );
63
69
  } else {
64
70
  goTo("/app/incident");
@@ -78,7 +84,6 @@ function TerritorialDistribution({ selectedPartners = {}, loading: parentLoading
78
84
  loading={loading || parentLoading}
79
85
  title={t("Territorial Distribution")}
80
86
  className="with-border-header"
81
- filtersConfig={filtersConfig}
82
87
  >
83
88
  <Chart
84
89
  mouseXOffset={10}
@@ -1,10 +1,10 @@
1
1
  import { Select } from "antd";
2
2
  import { useState } from "react";
3
- import Widget from "../../../../Dashboard/Widget/index.jsx";
4
3
  import IncidentsTime from "./components/IncidentsTime/index.js";
5
4
  import TerritorialDistribution from "./components/TerritorialDistribution/index.js";
6
5
  import ProblemSolver from "./components/ProblemSolver/index.js";
7
6
  import { filterOptions } from "./config.js";
7
+ import Widget from "../../../../../core/components/Dashboard/Widget/index.jsx";
8
8
 
9
9
  export default function RisksWidget({
10
10
  title = "Analytics",
@@ -1,12 +1,12 @@
1
1
  import React, { useMemo, useEffect } from "react";
2
- import Header from "../../Header/index.jsx";
3
2
  import KeyIndicators from "./components/KeyIndicators/index.js";
4
- import Multiselect from "../../Select/MultiSelect/index.jsx";
5
3
  import MineSites from "./components/MineSite/index.js";
6
4
  import RisksWidget from "./components/RisksWidget/index.js";
7
- import { useSources } from "../../../../hooks/useSources.js";
8
- import { renderBreadCrumbs } from "../../../../../helpers/breadCrumbs.js";
9
- import CustomIcon from "../../Icon/CustomIcon.jsx";
5
+ import { useSources } from "../../../hooks/useSources.js";
6
+ import { renderBreadCrumbs } from "../../../../helpers/breadCrumbs.js";
7
+ import CustomIcon from "../../../core/components/Icon/CustomIcon.jsx";
8
+ import { Header, Multiselect } from "../../../../index.js";
9
+ import DashboardLayout from '../../../core/components/Dashboard/DashboardLayout/index.jsx';
10
10
 
11
11
  export default function ConflictManagement({
12
12
  t=()=>{},
@@ -15,7 +15,9 @@ export default function ConflictManagement({
15
15
  goTo = () => {},
16
16
  getRedirectLink = (s) => s,
17
17
  theme = {},
18
- options = {}
18
+ options = {},
19
+ breadcrumbs = [],
20
+
19
21
  }) {
20
22
  const { partners, selectedPartners, setSelectedPartners, informationSources } =
21
23
  useSources({ user, t });
@@ -45,8 +47,11 @@ export default function ConflictManagement({
45
47
  }, [partners, user, theme]);
46
48
 
47
49
  return (
48
- <div className="daf-analysis">
49
- <Header
50
+
51
+ <DashboardLayout
52
+
53
+ header={
54
+ <Header
50
55
  title={t("conflict-management")}
51
56
  breadcrumbs={breadCrumbs}
52
57
  supportText={
@@ -63,7 +68,6 @@ export default function ConflictManagement({
63
68
  }
64
69
  addedHeader={
65
70
  <div>
66
- <div className="flex-1" />
67
71
  <Multiselect
68
72
  options={[...sourceOptions]}
69
73
  isAvatarGroup
@@ -82,12 +86,9 @@ export default function ConflictManagement({
82
86
  />
83
87
  </div>
84
88
  }
85
- />
89
+ />}
90
+ >
86
91
 
87
- <div className="content">
88
- <div className="view-content">
89
- <div className="daf-analysis-layout">
90
- <div className="sections-cont w-pt">
91
92
  <section>
92
93
  <KeyIndicators
93
94
  selectedPartners={selectedPartners}
@@ -126,11 +127,8 @@ export default function ConflictManagement({
126
127
  options={options}
127
128
  />
128
129
  </section>
129
- </div>
130
- </div>
131
- </div>
132
- </div>
133
- </div>
130
+
131
+ </DashboardLayout>
134
132
  );
135
133
  }
136
134
 
@@ -25,14 +25,14 @@ class DashboardService extends BaseService {
25
25
  });
26
26
  }
27
27
 
28
- // getWidgetConflictManagement({ url, params = {}, filters = {} }) {
29
- // return this.apiGet({
30
- // url: `/dashboard/conflict-management${url}`,
31
- // params: { ...params, ...filters },
32
- // isApp: true,
33
- // });
34
- // }
35
-
28
+ getWidgetConflictManagement(url, params, basepath = "dashboard/conflict-management") {
29
+ return this.apiGet({
30
+ url: `/${basepath}${url}`,
31
+ params,
32
+ isApp: true,
33
+ });
34
+ }
35
+
36
36
  }
37
37
 
38
38
  export default createLazyService(DashboardService);
package/src/pages.js CHANGED
@@ -23,4 +23,4 @@ export { default as View } from './@daf/pages/View/index.jsx';
23
23
  export { default as Edit } from './@daf/pages/Edit/index.jsx';
24
24
 
25
25
  // Conflict Management
26
- export { default as ConflictManagement } from './@daf/core/components/Screens/ConflictManagement/index.js';
26
+ export { default as ConflictManagement } from './@daf/pages/Dashboards/ConflictManagement/index.js'
package/build/favicon.ico DELETED
Binary file
package/build/logo192.png DELETED
Binary file
package/build/logo512.png DELETED
Binary file
@@ -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
@@ -1,3 +0,0 @@
1
- # https://www.robotstxt.org/robotstxt.html
2
- User-agent: *
3
- Disallow:
@@ -1,32 +0,0 @@
1
- import { useMemo, useState } from "react";
2
-
3
- export default function useIncidentsTimeline({ t=()=>{}, options = {} }) {
4
- const [filters, setFilters] = useState({ severity: "all" });
5
-
6
- const filtersConfig = useMemo(
7
- () => ({
8
- filtersConfig: {
9
- severity: {
10
- type: "select",
11
- label: "",
12
- placeholder: (t) => t(""),
13
- style: { flex: 1 },
14
- labelStyle: { flex: 1 },
15
- },
16
- },
17
- onApply: (val) => setFilters(val),
18
- options: {
19
- severity: [{ value: "all", label: t("All") }, ...(options?.severityOptions || [])],
20
- },
21
- selectedFilters: filters,
22
- type: "small",
23
- t,
24
- }),
25
- [t, filters, options?.severityOptions],
26
- );
27
-
28
- return {
29
- filters,
30
- filtersConfig,
31
- };
32
- }
@@ -1,73 +0,0 @@
1
- import { useCallback, useMemo } from "react";
2
- import StackChart from "../../../../../../Charts/StackChart/index.jsx";
3
- import Widget from "../../../../../../Dashboard/Widget/index.jsx";
4
- import PropTypes from 'prop-types';
5
- import useIncidentsTimeline from "./hook.js";
6
-
7
- export default function IncidentsTime({ selectedRange, selectedPartners = {} ,t=()=>{},goTo=(s)=>s,getRedirectLink=(s)=>s, theme = {}, APP , options = {}}) {
8
- const { filters, filtersConfig } = useIncidentsTimeline({ t, options });
9
- const { user } = useSelector((state) => state.authentication);
10
-
11
- const getSourceParam = useCallback((sourceId) => {
12
- if (user?.company?.id !== sourceId) {
13
- return `?sourceId=${sourceId}`;
14
- }
15
-
16
- return "";
17
- }, [user?.company?.id]);
18
-
19
- const defaultFetchConfig = useMemo(
20
- () => ({
21
- url: `/incidents-timeline`,
22
- filters: {
23
- ...filters,
24
- severity: filters.severity ? filters.severity : "all",
25
- period: selectedRange,
26
- sources: selectedPartners?.partners || [],
27
- },
28
- defaultData: [],
29
- stop: selectedPartners?.loading,
30
- }),
31
- [filters, selectedRange, selectedPartners],
32
- );
33
- const renderSeverity = (val) => {
34
- const colors = getColors("INCIDENTS", app);
35
-
36
- switch (val) {
37
- case "major":
38
- return <span style={{ color: colors.major }}>{t("Major")}</span>;
39
- case "minor":
40
- return <span style={{ color: colors.minor }}>{t("Minor")}</span>;
41
- case "moderate":
42
- return <span style={{ color: colors.moderate }}>{t("Moderate")}</span>;
43
- default:
44
- return null;
45
- }
46
- };
47
-
48
- const chartConfig = {}; const { data, loading } = useWidgetFetch(defaultFetchConfig);
49
-
50
-
51
- return (
52
- <Widget
53
- loading={loading}
54
- filtersConfig={filtersConfig}
55
- title={t("Incidents Timeline")}
56
- className="with-border-header"
57
- t={t}
58
- >
59
- <StackChart {...chartConfig} height="400px" t={t} />
60
- </Widget>
61
- );
62
- }
63
-
64
- IncidentsTime.propTypes = {
65
- selectedRange: PropTypes.string,
66
- selectedPartners: PropTypes.object,
67
- t: PropTypes.func,
68
- goTo: PropTypes.func,
69
- getRedirectLink: PropTypes.func,
70
- theme: PropTypes.object,
71
- APP: PropTypes.string,
72
- options: PropTypes.object,
73
- };
@@ -1,86 +0,0 @@
1
- import { useEffect, useMemo, useState } from "react";
2
- import DashboardService from "../../../../../../../../services/DashboardService.js";
3
-
4
-
5
- export default function useProblemSolvers(t = () => {}) {
6
- const [filters, setFilters] = useState({
7
- administrativeLevel1: "all",
8
- });
9
-
10
- const [filterOptions, setFilterOptions] = useState([]);
11
-
12
- useEffect(() => {
13
- async function fetchOptions() {
14
- try {
15
- const { data } = await DashboardService.getWidget({
16
- url: "/problem-solvers",
17
- });
18
-
19
-
20
- const rawOptions = Object.keys(data)
21
- .map((agentKey) => {
22
- const actions = data[agentKey]?.actions || [];
23
-
24
- return actions
25
- .map((action) => {
26
- const lvl1 = action?.location?.administrativeLevel1;
27
- const name =
28
- action?.location?.name ||
29
- action?.location?.administrativeLevel1 ||
30
- null;
31
-
32
- if (!lvl1 || !name) return undefined;
33
-
34
- return {
35
- label: name,
36
- value: lvl1,
37
- };
38
- })
39
- .filter(Boolean);
40
- })
41
- .flat();
42
-
43
- const unique = [
44
- ...new Map(rawOptions.map((item) => [item.value, item])).values(),
45
- ];
46
-
47
- setFilterOptions(unique);
48
- } catch (err) {
49
- console.error("Problem Solvers fetch failed:", err);
50
- }
51
- }
52
-
53
- fetchOptions();
54
- }, []);
55
-
56
-
57
- const filtersConfig = useMemo(
58
- () => ({
59
- filtersConfig: {
60
- administrativeLevel1: {
61
- type: "select",
62
- label: "",
63
- placeholder: t("Select"),
64
- style: { flex: 1 },
65
- labelStyle: { flex: 1 },
66
- },
67
- },
68
- onApply: (val) => setFilters(val),
69
- options: {
70
- administrativeLevel1: [
71
- { label: t("All"), value: "all" },
72
- ...filterOptions,
73
- ],
74
- },
75
- selectedFilters: filters,
76
- type: "small",
77
- t,
78
- }),
79
- [t, filters, filterOptions]
80
- );
81
-
82
- return {
83
- filters,
84
- filtersConfig,
85
- };
86
- }
@@ -1,34 +0,0 @@
1
-
2
- import { useMemo, useState } from "react";
3
-
4
- export default function useTerritorialDistribution({ t = (s)=>{s}, options = {} }) {
5
- const [filters, setFilters] = useState({ filter1: 'all', filter2: 'all' });
6
-
7
- const filtersConfig = useMemo((t) => ({
8
- onApply: (val) => setFilters(val),
9
- options: {
10
- filter1: [{ label: t('All'), value: 'all' }],
11
- filter2: [{ label: t('All'), value: 'all' }],
12
- },
13
- selectedFilters: filters,
14
- type: 'small',
15
- t,
16
- }), [t, filters]);
17
-
18
- return {
19
- filters,
20
- filtersConfig,
21
- setFilters,
22
- t,
23
- };
24
- }
25
-
26
- export const getColors = (theme) => {
27
- return [
28
- theme.colorPrimary8,
29
- theme.colorPrimary7,
30
- theme.colorPrimary5,
31
- theme.colorPrimary6,
32
- theme.colorPrimary4,
33
- ]
34
- }