datastake-daf 0.6.844 → 0.6.846

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 (29) hide show
  1. package/dist/components/index.js +28 -67
  2. package/dist/hooks/index.js +12 -22
  3. package/dist/pages/index.js +4132 -4551
  4. package/dist/utils/index.js +9 -1
  5. package/package.json +1 -1
  6. package/src/@daf/core/components/EditForm/helper.js +14 -6
  7. package/src/@daf/core/components/Screens/Admin/AdminModals/NewUser/index.jsx +1 -1
  8. package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/helper.js +59 -77
  9. package/src/@daf/core/components/Screens/Admin/AdminViews/index.jsx +1 -8
  10. package/src/@daf/hooks/useSources.js +6 -4
  11. package/src/@daf/hooks/useWidgetFetch.js +3 -14
  12. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/IncidentsTime/config.js +3 -0
  13. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/IncidentsTime/hook.js +69 -4
  14. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/IncidentsTime/index.js +29 -92
  15. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/ProblemSolver/hook.js +59 -34
  16. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/ProblemSolver/index.js +36 -69
  17. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/TerritorialDistribution/hook.js +56 -0
  18. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/TerritorialDistribution/index.js +50 -75
  19. package/src/@daf/pages/Dashboards/ConflictManagement/index.js +11 -11
  20. package/src/@daf/pages/Dashboards/SupplyChain/components/ChartsContainer/components/GenderDistribution/index.js +46 -51
  21. package/src/@daf/pages/Dashboards/SupplyChain/components/ChartsContainer/components/Identification/hook.js +20 -20
  22. package/src/@daf/pages/Dashboards/SupplyChain/components/ChartsContainer/components/Identification/index.js +26 -2
  23. package/src/@daf/pages/Dashboards/SupplyChain/index.jsx +0 -1
  24. package/src/@daf/pages/Dashboards/UserDashboard/components/DataChainOfCustody/index.jsx +2 -1
  25. package/src/@daf/pages/Dashboards/UserDashboard/components/MineSites/config.js +10 -1
  26. package/src/@daf/pages/Dashboards/UserDashboard/index.jsx +1 -0
  27. package/src/@daf/pages/Dashboards/helper.js +25 -20
  28. package/src/constants/locales/fr/translation.js +9 -0
  29. package/src/constants/locales/sp/translation.js +1 -0
@@ -1,55 +1,77 @@
1
1
  import { useEffect, useMemo, useState } from "react";
2
2
  import DashboardService from "../../../../../../../services/DashboardService.js";
3
+ import { useWidgetFetch } from "../../../../../../../hooks/useWidgetFetch.js";
3
4
 
5
+ const distributionColors = ["#3061A8", "#6698E4", "#A6C3EF", "#D6E3F8", "#E6EEFB"];
4
6
 
5
- export default function useProblemSolvers({ t = () => {} } = {}) {
7
+ export default function useProblemSolvers({ t = () => {}, selectedRange, selectedPartners }) {
6
8
  const [filters, setFilters] = useState({
7
9
  administrativeLevel1: "all",
8
10
  });
9
11
 
10
12
  const [filterOptions, setFilterOptions] = useState([]);
11
13
 
14
+ const defaultFetchConfig = useMemo(
15
+ () => ({
16
+ url: "/problem-solvers",
17
+ basepath: "dashboard/conflict-management",
18
+ filters: {
19
+ ...filters,
20
+ period: selectedRange,
21
+ sources: selectedPartners?.partners || [],
22
+ },
23
+ stop: selectedPartners?.loading,
24
+ }),
25
+ [filters, selectedRange, selectedPartners],
26
+ );
27
+
28
+ const { data, loading } = useWidgetFetch({ config: defaultFetchConfig });
12
29
 
13
30
  useEffect(() => {
14
- async function fetchOptions() {
15
- try {
16
- const { data } = await DashboardService.getWidgetConflictManagement(
17
- "/problem-solvers",
18
- {},
19
- "dashboard/conflict-management"
20
- );
31
+ if(Object.keys(data).length > 0) {
21
32
 
22
- const all = Object.keys(data);
33
+ const options = Object.keys(data).flatMap((key) => {
34
+ const actions = data[key].actions;
23
35
 
24
- const options = all
25
- .map((key) => {
26
- const actions = data[key].actions;
36
+ return actions.filter((action) => action.location !== undefined).flatMap((action) => {
37
+ const administrativeLevel1 = action?.location?.administrativeLevel1;
38
+ const name =
39
+ action?.location?.linking?.SCL?.[administrativeLevel1]?.name;
40
+ return {
41
+ label: name,
42
+ value: administrativeLevel1,
43
+ };
44
+ });
45
+ }).filter((item) => item !== undefined);
27
46
 
28
- return actions.map((action) => {
29
- if (action.location === undefined) {
30
- return;
31
- }
32
- const administrativeLevel1 = action?.location?.administrativeLevel1;
33
- const name =
34
- action?.location?.linking?.SCL?.[administrativeLevel1]?.name;
35
- return {
36
- label: name,
37
- value: administrativeLevel1,
38
- };
39
- });
40
- })
41
- .flat()
42
- .filter((item) => item !== undefined);
43
-
44
- setFilterOptions(options);
45
- } catch (err) {
46
- console.log(err);
47
- }
47
+ const uniqueOptions = Array.from(
48
+ new Map(options.map(item => [item.value, item])).values()
49
+ );
50
+
51
+ setFilterOptions(uniqueOptions);
48
52
  }
53
+ }, [data])
54
+
55
+ const pieData = useMemo(() => {
56
+ if (!data || Array.isArray(data)) return [];
57
+ const all = Object.keys(data);
58
+ const totalActions = all.reduce((acc, key) => acc + (data[key]?.actions?.length || 0), 0);
49
59
 
50
- fetchOptions();
51
- }, []);
60
+ return all
61
+ .sort((a, b) => (data[b]?.actions?.length || 0) - (data[a]?.actions?.length || 0))
62
+ .map((key, index) => {
63
+ const item = data[key];
64
+ return {
65
+ value: item?.actions?.length,
66
+ label: item?.implementerData?.name,
67
+ implementerData: item?.implementerData,
68
+ color: distributionColors[index % distributionColors.length],
69
+ percent: totalActions ? (item?.actions?.length / totalActions) : 0,
70
+ }
71
+ });
72
+ }, [data]);
52
73
 
74
+ const isEmpty = !pieData.length;
53
75
 
54
76
  const filtersConfig = useMemo(
55
77
  () => ({
@@ -79,5 +101,8 @@ export default function useProblemSolvers({ t = () => {} } = {}) {
79
101
  return {
80
102
  filters,
81
103
  filtersConfig,
104
+ pieData,
105
+ loading,
106
+ isEmpty,
82
107
  };
83
108
  }
@@ -3,77 +3,28 @@ import PropTypes from 'prop-types';
3
3
  import { renderTooltipJsx } from '../../../../../../../utils/tooltip.js';
4
4
  import Widget from '../../../../../../../core/components/Dashboard/Widget/index.jsx';
5
5
  import Chart from '../../../../../../../core/components/Charts/PieChart/chart.jsx';
6
- import {useWidgetFetch} from '../../../../../../../hooks/useWidgetFetch.js';
7
- import DashboardService from '../../../../../../../services/DashboardService.js';
8
6
  import useProblemSolvers from './hook.js';
9
7
 
10
- const distributionColors = ["#3061A8", "#6698E4", "#A6C3EF", "#D6E3F8", "#E6EEFB"];
11
-
12
- function ProblemSolvers({ selectedPartners = {}, loading: parentLoading = false, t=()=>{}, theme = {}, selectedRange ,goTo = () => {}, getRedirectLink = () => {}}) {
13
- const { filters, filtersConfig } = useProblemSolvers({ t });
14
-
15
- const defaultFetchConfig = useMemo(
16
- () => ({
17
- url: "/problem-solvers",
18
- basepath: "dashboard/conflict-management",
19
- filters: {
20
- ...filters,
21
- period: selectedRange,
22
- sources: selectedPartners?.partners || [],
23
- },
24
- defaultData: [],
25
- stop: selectedPartners?.loading,
26
- }),
27
- [filters, selectedRange, selectedPartners],
28
- );
29
-
30
- const getData = useCallback(({ url, filters, basepath }) => {
31
- return DashboardService.getWidgetConflictManagement(url, filters, basepath);
32
- }, []);
33
-
34
- const { data, loading } = useWidgetFetch({
35
- config: defaultFetchConfig,
36
- getData
37
- });
38
-
39
- const pieData = useMemo(() => {
40
- if (!data || Array.isArray(data)) return [];
41
- const all = Object.keys(data);
42
- const totalActions = all.reduce((acc, key) => acc + (data[key]?.actions?.length || 0), 0);
43
-
44
- return all
45
- .sort((a, b) => (data[b]?.actions?.length || 0) - (data[a]?.actions?.length || 0))
46
- .map((key, index) => {
47
- const item = data[key];
48
- return {
49
- value: item?.actions?.length,
50
- label: item?.implementerData?.name,
51
- implementerData: item?.implementerData,
52
- color: distributionColors[index % distributionColors.length],
53
- percent: totalActions ? (item?.actions?.length / totalActions) : 0,
54
- }
55
- });
56
- }, [data]);
57
-
58
- const isEmpty = !pieData.length;
59
-
60
- const getTooltipChildren = useCallback((items) => {
61
- const item = Array.isArray(items) ? items[0] : items;
62
-
63
- return renderTooltipJsx({
64
- title: item?.label || t("Undetermined"),
65
- link: true,
66
- onClickLink: () => {
67
- goTo("/app/corrective-actions");
68
- },
69
- items: [
70
- {
71
- label: t("Number of actions"),
72
- value: item?.value,
73
- },
74
- ],
8
+ function ProblemSolvers({
9
+ selectedPartners = {},
10
+ loading: parentLoading = false,
11
+ t=()=>{},
12
+ theme = {},
13
+ selectedRange,
14
+ goTo = () => {},
15
+ getRedirectLink = () => {}
16
+ }) {
17
+ const {
18
+ filters,
19
+ filtersConfig,
20
+ pieData,
21
+ loading,
22
+ isEmpty
23
+ } = useProblemSolvers({
24
+ t,
25
+ selectedRange,
26
+ selectedPartners
75
27
  });
76
- }, [t, goTo]);
77
28
 
78
29
  return (
79
30
  <Widget
@@ -91,7 +42,23 @@ function ProblemSolvers({ selectedPartners = {}, loading: parentLoading = false,
91
42
  isPie
92
43
  t={t}
93
44
  isEmpty={isEmpty}
94
- getTooltipChildren={getTooltipChildren}
45
+ getTooltipChildren={(items) => {
46
+ const item = Array.isArray(items) ? items[0] : items;
47
+
48
+ return renderTooltipJsx({
49
+ title: item?.label || t("Undetermined"),
50
+ link: true,
51
+ onClickLink: () => {
52
+ goTo("/app/corrective-actions");
53
+ },
54
+ items: [
55
+ {
56
+ label: t("Number of actions"),
57
+ value: item?.value,
58
+ },
59
+ ],
60
+ });
61
+ }}
95
62
  />
96
63
  </Widget>
97
64
  );
@@ -0,0 +1,56 @@
1
+ import { useMemo } from 'react';
2
+ import { getColors } from './config.js';
3
+ import { useWidgetFetch } from '../../../../../../../hooks/useWidgetFetch.js';
4
+
5
+ export const useTerritorialDistribution = ({
6
+ category,
7
+ selectedRange,
8
+ selectedPartners,
9
+ theme,
10
+ }) => {
11
+ const colors = getColors(theme);
12
+
13
+ const defaultFetchConfig = useMemo(
14
+ () => ({
15
+ url: "/territorial-distribution",
16
+ basepath: "dashboard/conflict-management",
17
+ filters: {
18
+ category,
19
+ period: selectedRange,
20
+ sources: selectedPartners?.partners || [],
21
+ },
22
+ defaultData: {},
23
+ stop: selectedPartners?.loading,
24
+ }),
25
+ [category, selectedRange, selectedPartners],
26
+ );
27
+
28
+ const { data, loading } = useWidgetFetch({ config: defaultFetchConfig });
29
+
30
+ const pieData = useMemo(() => {
31
+ if (!data || Array.isArray(data)) return [];
32
+ const all = Object.keys(data);
33
+ const totalEvents = all.reduce((acc, key) => acc + (data[key]?.events?.length || 0), 0);
34
+
35
+ return all
36
+ .sort((a, b) => (data[b]?.events?.length || 0) - (data[a]?.events?.length || 0))
37
+ .map((key, index) => {
38
+ const item = data[key];
39
+ return {
40
+ value: item?.events?.length,
41
+ label: item?.locationData?.name,
42
+ locationData: item?.locationData,
43
+ color: colors[index % colors.length],
44
+ percent: totalEvents ? (item?.events?.length / totalEvents) : 0,
45
+ }
46
+ });
47
+ }, [data, colors]);
48
+
49
+ const isEmpty = !pieData.length;
50
+
51
+ return {
52
+ pieData,
53
+ loading,
54
+ isEmpty,
55
+ }
56
+ }
@@ -3,88 +3,37 @@ import PropTypes from 'prop-types';
3
3
  import { renderTooltipJsx } from '../../../../../../../utils/tooltip.js';
4
4
  import Widget from '../../../../../../../core/components/Dashboard/Widget/index.jsx';
5
5
  import Chart from '../../../../../../../core/components/Charts/PieChart/chart.jsx';
6
- import {useWidgetFetch} from '../../../../../../../hooks/useWidgetFetch.js';
7
- import DashboardService from '../../../../../../../services/DashboardService.js';
8
- import { getColors } from './config.js';
6
+ import { buildQueryString } from '../../../../../../../../helpers/urlHelpers.js';
7
+ import { useTerritorialDistribution } from './hook.js';
9
8
 
10
- function TerritorialDistribution({ selectedPartners = {}, loading: parentLoading = false, t = (s) => s, theme = {}, category = "conflict", selectedRange ,goTo = () => {}, getRedirectLink = () => {}}) {
11
- const colors = getColors(theme);
12
-
13
- const defaultFetchConfig = useMemo(
14
- () => ({
15
- url: "/territorial-distribution",
16
- basepath: "dashboard/conflict-management",
17
- filters: {
18
- category,
19
- period: selectedRange,
20
- sources: selectedPartners?.partners || [],
21
- },
22
- defaultData: {},
23
- stop: selectedPartners?.loading,
24
- }),
25
- [category, selectedRange, selectedPartners],
26
- );
27
-
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
9
+ function TerritorialDistribution({
10
+ selectedPartners = {},
11
+ loading: parentLoading = false,
12
+ t = (s) => s, theme = {},
13
+ category = "conflict",
14
+ selectedRange,
15
+ goTo = () => {},
16
+ getRedirectLink = () => {}
17
+ }) {
18
+ const {
19
+ pieData,
20
+ loading,
21
+ isEmpty
22
+ } = useTerritorialDistribution({
23
+ category,
24
+ selectedRange,
25
+ selectedPartners,
26
+ theme,
35
27
  });
36
28
 
37
- const pieData = useMemo(() => {
38
- if (!data || Array.isArray(data)) return [];
39
- const all = Object.keys(data);
40
- const totalEvents = all.reduce((acc, key) => acc + (data[key]?.events?.length || 0), 0);
41
-
42
- return all
43
- .sort((a, b) => (data[b]?.events?.length || 0) - (data[a]?.events?.length || 0))
44
- .map((key, index) => {
45
- const item = data[key];
46
- return {
47
- value: item?.events?.length,
48
- label: item?.locationData?.name,
49
- locationData: item?.locationData,
50
- color: colors[index % colors.length],
51
- percent: totalEvents ? (item?.events?.length / totalEvents) : 0,
52
- }
53
- });
54
- }, [data, colors]);
55
-
56
- const isEmpty = !pieData.length;
57
-
58
- const getTooltipChildren = useCallback((items) => {
59
- const item = Array.isArray(items) ? items[0] : items;
60
-
61
- return renderTooltipJsx({
62
- title: item?.label || t("Undetermined"),
63
- link: true,
64
- onClickLink: () => {
65
- if (item?.label) {
66
- goTo(
67
- `/app/incidents?administrativeLevel1=${item?.locationData?.administrativeLevel1}&administrativeLevel2=${item?.locationData?.administrativeLevel2}&country=${item?.locationData?.country}`,
68
- );
69
- } else {
70
- goTo("/app/incident");
71
- }
72
- },
73
- items: [
74
- {
75
- label: t("Number of incidents"),
76
- value: item?.value,
77
- },
78
- ],
79
- });
80
- }, [t, goTo]);
81
-
82
29
  return (
83
30
  <Widget
84
31
  loading={loading || parentLoading}
85
32
  title={t("Territorial Distribution")}
86
- className="with-border-header"
33
+
34
+ className="with-border-header h-w-btn-header"
87
35
  >
36
+
88
37
  <Chart
89
38
  mouseXOffset={10}
90
39
  mouseYOffset={10}
@@ -94,8 +43,34 @@ function TerritorialDistribution({ selectedPartners = {}, loading: parentLoading
94
43
  isPie
95
44
  t={t}
96
45
  isEmpty={isEmpty}
97
- getTooltipChildren={getTooltipChildren}
46
+ getTooltipChildren={(items) => {
47
+ const item = Array.isArray(items) ? items[0] : items;
48
+
49
+ return renderTooltipJsx({
50
+ title: item?.label || t("Undetermined"),
51
+ link: true,
52
+ onClickLink: () => {
53
+ if (item?.label) {
54
+ const queryString = buildQueryString({
55
+ administrativeLevel1: item?.locationData?.administrativeLevel1,
56
+ administrativeLevel2: item?.locationData?.administrativeLevel2,
57
+ country: item?.locationData?.country,
58
+ });
59
+ goTo(`/app/incidents${queryString}`);
60
+ } else {
61
+ goTo("/app/incidents");
62
+ }
63
+ },
64
+ items: [
65
+ {
66
+ label: t("Number of incidents"),
67
+ value: item?.value,
68
+ },
69
+ ],
70
+ });
71
+ }}
98
72
  />
73
+
99
74
  </Widget>
100
75
  );
101
76
  }
@@ -2,8 +2,6 @@ import React, { useMemo, useEffect } from "react";
2
2
  import KeyIndicators from "./components/KeyIndicators/index.js";
3
3
  import MineSites from "./components/MineSite/index.js";
4
4
  import RisksWidget from "./components/RisksWidget/index.js";
5
- import { useSources } from "../../../hooks/useSources.js";
6
- import { renderBreadCrumbs } from "../../../../helpers/breadCrumbs.js";
7
5
  import CustomIcon from "../../../core/components/Icon/CustomIcon.jsx";
8
6
  import { Header, Multiselect } from "../../../../index.js";
9
7
  import DashboardLayout from '../../../core/components/Dashboard/DashboardLayout/index.jsx';
@@ -16,21 +14,23 @@ export default function ConflictManagement({
16
14
  getRedirectLink = (s) => s,
17
15
  theme = {},
18
16
  options = {},
19
- breadcrumbs = [],
20
-
17
+ breadcrumbs = [],
18
+ partners,
19
+ selectedPartners,
20
+ setSelectedPartners,
21
+ informationSources
21
22
  }) {
22
- const { partners, selectedPartners, setSelectedPartners, informationSources } =
23
- useSources({ user, t });
24
-
25
23
  // const { pushPath } = useHistory();
26
24
 
27
25
  // useEffect(() => {
28
26
  // pushPath(`/app/conflict-management`);
29
27
  // }, []);
30
28
 
31
- const breadCrumbs = useMemo(() => {
32
- return renderBreadCrumbs({ t, view: "conflict-management", mod: APP, goTo });
33
- }, [t, APP, goTo]);
29
+ console.log(partners, "partners");
30
+
31
+ // const breadCrumbs = useMemo(() => {
32
+ // return renderBreadCrumbs({ t, view: "conflict-management", mod: APP, goTo });
33
+ // }, [t, APP, goTo]);
34
34
 
35
35
  const sourceOptions = useMemo(() => {
36
36
  return partners.map((partner) => {
@@ -53,7 +53,7 @@ export default function ConflictManagement({
53
53
  header={
54
54
  <Header
55
55
  title={t("conflict-management")}
56
- breadcrumbs={breadCrumbs}
56
+ breadcrumbs={breadcrumbs}
57
57
  supportText={
58
58
  <>
59
59
  {t("Supported by")}{" "}
@@ -39,56 +39,6 @@ function GenderDistribution({
39
39
 
40
40
  const isEmpty = useMemo(() => Object.keys(data).filter((k) => !!data[k]).length === 0, [data]);
41
41
 
42
- const getTooltipChildren = useCallback(
43
- (item) => {
44
- if (isTradeActions) {
45
- if (isEmpty) {
46
- return;
47
- }
48
-
49
- return renderTooltipJsx({
50
- title: t("Role"),
51
- items: [
52
- {
53
- label:
54
- (options?.optionPositionSupplyChain || options?.positionSupplyChainOptions || [])?.find((o) => {
55
- return o.value === item.key;
56
- }).label || item.key,
57
- value: data[item.key] || 0,
58
- },
59
- ],
60
- });
61
- } else {
62
- if (isEmpty) {
63
- return renderTooltipJsx({
64
- title: t("Gender"),
65
- items: config.map((conf) => ({
66
- label: t(conf.label),
67
- value: 0,
68
- })),
69
- });
70
- }
71
-
72
- const _config = config?.find((c) => c.key === item.key);
73
-
74
- if (_config) {
75
- return renderTooltipJsx({
76
- title: t("Gender"),
77
- items: [
78
- {
79
- label: t(_config.label),
80
- value: `${Math.round(item.percent * 100)}%`,
81
- },
82
- ],
83
- });
84
- }
85
-
86
- return null;
87
- }
88
- },
89
- [t, data, isTradeActions],
90
- );
91
-
92
42
  return (
93
43
  <Widget
94
44
  loading={loading}
@@ -110,7 +60,52 @@ function GenderDistribution({
110
60
  isPie
111
61
  t={t}
112
62
  isEmpty={isEmpty}
113
- getTooltipChildren={getTooltipChildren}
63
+ getTooltipChildren={ (item) => {
64
+ if (isTradeActions) {
65
+ if (isEmpty) {
66
+ return;
67
+ }
68
+
69
+ return renderTooltipJsx({
70
+ title: t("Role"),
71
+ items: [
72
+ {
73
+ label:
74
+ (options?.optionPositionSupplyChain || options?.positionSupplyChainOptions || [])?.find((o) => {
75
+ return o.value === item.key;
76
+ }).label || item.key,
77
+ value: data[item.key] || 0,
78
+ },
79
+ ],
80
+ });
81
+ } else {
82
+ if (isEmpty) {
83
+ return renderTooltipJsx({
84
+ title: t("Gender"),
85
+ items: config.map((conf) => ({
86
+ label: t(conf.label),
87
+ value: 0,
88
+ })),
89
+ });
90
+ }
91
+
92
+ const _config = config?.find((c) => c.key === item.key);
93
+
94
+ if (_config) {
95
+ return renderTooltipJsx({
96
+ title: t("Gender"),
97
+ items: [
98
+ {
99
+ label: t(_config.label),
100
+ value: `${Math.round(item.percent * 100)}%`,
101
+ },
102
+ ],
103
+ });
104
+ }
105
+
106
+ return null;
107
+ }
108
+ }}
114
109
  />
115
110
  </div>
116
111
  </Widget>
@@ -53,27 +53,27 @@ export function useIdentification({ data, theme = {}, options = {} }) {
53
53
  yFieldKey: "value",
54
54
  seriesField: "typeOfProduct",
55
55
  color: allSeenProducts.map((_, index) => colors[index % colors.length]),
56
- renderTooltipContent: (title, items) => {
57
- if (Array.isArray(items) && items[0]) {
58
- const title = items[0].title;
59
- const values = graphData.filter((d) => d.date === title);
60
- return {
61
- title: "Products",
62
- items: values.map((val) => {
63
- return{
64
- label: findOptions(val.typeOfProduct, options?.mineralOptions) || val.typeOfProduct,
65
- color: colors[
66
- allSeenProducts.indexOf(val.typeOfProduct) % colors.length
67
- ],
68
- value: val.value.toLocaleString(),
69
- }
70
- }),
71
- };
72
- }
73
- return { title: "", items: [] };
74
- },
56
+ // renderTooltipContent: (title, items) => {
57
+ // if (Array.isArray(items) && items[0]) {
58
+ // const title = items[0].title;
59
+ // const values = graphData.filter((d) => d.date === title);
60
+ // return {
61
+ // title: "Products",
62
+ // items: values.map((val) => {
63
+ // return{
64
+ // label: findOptions(val.typeOfProduct, options?.mineralOptions) || val.typeOfProduct,
65
+ // color: colors[
66
+ // allSeenProducts.indexOf(val.typeOfProduct) % colors.length
67
+ // ],
68
+ // value: val.value.toLocaleString(),
69
+ // }
70
+ // }),
71
+ // };
72
+ // }
73
+ // return { title: "", items: [] };
74
+ // },
75
75
  };
76
76
  }, [graphData, allSeenProducts, options.minerals]);
77
77
 
78
- return chartConfig;
78
+ return { chartConfig, colors, allSeenProducts, graphData};
79
79
  }