datastake-daf 0.6.764 → 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.
- package/dist/components/index.js +353 -191
- package/dist/layouts/index.js +0 -3
- package/dist/pages/index.js +308 -223
- package/dist/services/index.js +18 -0
- package/dist/utils/index.js +312 -4
- package/package.json +1 -2
- package/src/@daf/core/components/Charts/BarChart/index.jsx +4 -0
- package/src/@daf/core/components/Dashboard/Map/ChainIcon/index.js +0 -7
- package/src/@daf/core/components/Graphs/StakeholderMappings/index.jsx +0 -2
- package/src/@daf/core/components/Graphs/components/BaseGraph.jsx +3 -4
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/KeyIndicatorsWidget/config.js +2 -2
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/KeyIndicatorsWidget/index.jsx +1 -1
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserActivity/helper.js +4 -1
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserActivity/index.jsx +5 -0
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/index.jsx +1 -0
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/index.jsx +34 -26
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/index.jsx +56 -52
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Dashboard.jsx +52 -67
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Location.jsx +96 -0
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Subjects.jsx +96 -0
- package/src/@daf/core/components/Screens/Admin/AdminScreens/index.js +2 -1
- package/src/@daf/core/components/Screens/Admin/adminRoutes.js +116 -89
- package/src/@daf/core/components/Table/MoreTags/index.jsx +17 -5
- package/src/@daf/layouts/AuthLayout/components/Navbar/index.jsx +0 -1
- package/src/@daf/pages/Dashboards/SupplyChain/components/ChartsContainer/components/Identification/hook.js +10 -10
- package/src/@daf/pages/Dashboards/SupplyChain/components/SupplyChainMap/index.js +6 -3
- package/src/@daf/pages/Dashboards/UserDashboard/components/ContributionsGraph/helper.js +1 -14
- package/src/@daf/pages/Dashboards/UserDashboard/components/ContributionsGraph/hook.js +12 -5
- package/src/@daf/pages/Dashboards/UserDashboard/components/MineSites/index.jsx +1 -1
- package/src/@daf/pages/Dashboards/UserDashboard/components/Triangulation/hook.js +1 -1
- package/src/@daf/pages/Data/Channels/columns.js +175 -0
- package/src/@daf/pages/Data/Channels/config.js +0 -0
- package/src/@daf/pages/Data/Channels/create.jsx +0 -0
- package/src/@daf/pages/Data/Channels/index.jsx +0 -0
- package/src/@daf/pages/Events/Activities/columns.js +1 -4
- package/src/@daf/pages/Events/helper.js +3 -2
- package/src/@daf/pages/Events/index.jsx +1 -1
- package/src/@daf/pages/Locations/MineSite/columns.js +6 -4
- package/src/@daf/pages/Stakeholders/Operators/columns.js +4 -2
- package/src/@daf/pages/Summary/Activities/PlantingCycle/config.js +40 -0
- package/src/@daf/pages/Summary/Activities/PlantingCycle/helper.js +122 -0
- package/src/@daf/pages/Summary/Activities/PlantingCycle/index.jsx +47 -0
- package/src/@daf/pages/Summary/Activities/Restoration/config.js +1 -1
- package/src/@daf/pages/Summary/Minesite/components/StakeholderMapping/config.js +2 -2
- package/src/@daf/pages/Summary/Minesite/components/StakeholderMapping/helper.js +7 -7
- package/src/@daf/pages/Summary/Minesite/components/StakeholderMapping/index.js +3 -2
- package/src/@daf/pages/Summary/Minesite/index.jsx +3 -1
- package/src/@daf/pages/Summary/Operator/components/Governance/index.js +0 -1
- package/src/@daf/pages/Summary/Operator/components/KeyInformation/config.js +33 -21
- package/src/@daf/pages/Summary/Operator/components/TradeRelationships/helper.js +13 -13
- package/src/@daf/pages/Summary/Operator/components/TradeRelationships/hook.js +8 -8
- package/src/@daf/pages/Summary/Operator/components/TradeRelationships/index.js +5 -2
- package/src/@daf/pages/Summary/Operator/index.jsx +3 -0
- package/src/@daf/pages/Summary/components/InformationAvailability/index.js +4 -3
- package/src/@daf/services/AdminService.js +14 -0
- package/src/constants/locales/en/translation.js +104 -2
- package/src/constants/locales/fr/translation.js +104 -1
- package/src/constants/locales/sp/translation.js +104 -1
- package/src/index.js +2 -0
- package/src/pages.js +1 -0
|
@@ -9,6 +9,9 @@ export default function MoreTags({
|
|
|
9
9
|
maxWidthCont = 120,
|
|
10
10
|
maxTextCont = 100,
|
|
11
11
|
diff = 30,
|
|
12
|
+
style = {},
|
|
13
|
+
tagColor,
|
|
14
|
+
limit,
|
|
12
15
|
}) {
|
|
13
16
|
const ref = useRef();
|
|
14
17
|
const [width, setWidth] = useState(0);
|
|
@@ -27,6 +30,12 @@ export default function MoreTags({
|
|
|
27
30
|
}, []);
|
|
28
31
|
|
|
29
32
|
const _calculate = () => {
|
|
33
|
+
// If limit prop is provided and valid, use it instead of calculating
|
|
34
|
+
if (typeof limit === 'number' && limit > 0) {
|
|
35
|
+
setIndexToReturn(Math.min(limit - 1, values.length - 1));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
30
39
|
const tabs = ref.current.querySelectorAll(".check-tabs");
|
|
31
40
|
let filled = 0;
|
|
32
41
|
let indexToReturn;
|
|
@@ -60,7 +69,7 @@ export default function MoreTags({
|
|
|
60
69
|
|
|
61
70
|
useEffect(() => {
|
|
62
71
|
_calculate();
|
|
63
|
-
}, [width, values]);
|
|
72
|
+
}, [width, values, limit]);
|
|
64
73
|
|
|
65
74
|
return (
|
|
66
75
|
<div className="daf-more-tags">
|
|
@@ -76,8 +85,9 @@ export default function MoreTags({
|
|
|
76
85
|
overflow: "hidden",
|
|
77
86
|
textOverflow: "ellipsis",
|
|
78
87
|
whiteSpace: "nowrap",
|
|
88
|
+
...style,
|
|
79
89
|
}}
|
|
80
|
-
color={ac.color}
|
|
90
|
+
color={tagColor || ac.color}
|
|
81
91
|
>
|
|
82
92
|
<Tooltip title={typeof ac === "object" ? ac.label : ac}>
|
|
83
93
|
<span
|
|
@@ -86,6 +96,7 @@ export default function MoreTags({
|
|
|
86
96
|
overflow: "hidden",
|
|
87
97
|
textOverflow: "ellipsis",
|
|
88
98
|
whiteSpace: "nowrap",
|
|
99
|
+
...style,
|
|
89
100
|
}}
|
|
90
101
|
>
|
|
91
102
|
{typeof ac === "object" ? ac.label : ac}
|
|
@@ -100,7 +111,7 @@ export default function MoreTags({
|
|
|
100
111
|
.map((ac) => (typeof ac === "object" ? ac.label : ac))
|
|
101
112
|
.join(", ")}
|
|
102
113
|
>
|
|
103
|
-
<Tag>+{other.length}</Tag>
|
|
114
|
+
<Tag color={tagColor || 'default'} style={style}>+{other.length}</Tag>
|
|
104
115
|
</Tooltip>
|
|
105
116
|
) : null}
|
|
106
117
|
</div>
|
|
@@ -110,10 +121,10 @@ export default function MoreTags({
|
|
|
110
121
|
ac.renderTag("check-tabs")
|
|
111
122
|
) : (
|
|
112
123
|
<Tag
|
|
113
|
-
color={ac.color}
|
|
124
|
+
color={tagColor || ac.color}
|
|
114
125
|
key={`${ac}-${i}`}
|
|
115
126
|
className="check-tabs"
|
|
116
|
-
style={{ maxWidth: _maxWidthCont }}
|
|
127
|
+
style={{ maxWidth: _maxWidthCont, ...style }}
|
|
117
128
|
>
|
|
118
129
|
<Text
|
|
119
130
|
ellipsis={{ tooltip: typeof ac === "object" ? ac.label : ac }}
|
|
@@ -134,4 +145,5 @@ MoreTags.propTypes = {
|
|
|
134
145
|
maxWidthCont: PropTypes.number,
|
|
135
146
|
maxTextCont: PropTypes.number,
|
|
136
147
|
diff: PropTypes.number,
|
|
148
|
+
limit: PropTypes.number,
|
|
137
149
|
};
|
|
@@ -23,7 +23,6 @@ const AuthNavbar = ({
|
|
|
23
23
|
defaultValue = StorageManager.get('datastakeLng') || 'en',
|
|
24
24
|
onClose
|
|
25
25
|
}) => {
|
|
26
|
-
console.log({navbarDefaultValue: defaultValue})
|
|
27
26
|
return (
|
|
28
27
|
<Style className={formatClassname([typeof onClose === 'function' && 'bordered'])}>
|
|
29
28
|
<div className="d-navbar flex-c jus-c">
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useEffect, useState, useMemo } from "react";
|
|
2
|
+
import { findOptions } from '../../../../../../../../helpers/StringHelper.js';
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
export function useIdentification({ data, theme = {}, options = {} }) {
|
|
@@ -58,16 +59,15 @@ export function useIdentification({ data, theme = {}, options = {} }) {
|
|
|
58
59
|
const values = graphData.filter((d) => d.date === title);
|
|
59
60
|
return {
|
|
60
61
|
title: "Products",
|
|
61
|
-
items: values.map((val) =>
|
|
62
|
-
|
|
63
|
-
options?.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
})),
|
|
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
71
|
};
|
|
72
72
|
}
|
|
73
73
|
return { title: "", items: [] };
|
|
@@ -35,6 +35,7 @@ function SupplyChainMap({selectedSources = {}, t = () => {}, goTo = () => {}, op
|
|
|
35
35
|
renderTooltip={(data) => {
|
|
36
36
|
const productsText = data?.products?.[0];
|
|
37
37
|
const minerals = options?.minerals || [];
|
|
38
|
+
const participants = data?.stakeholders?.map((stakeholder) => stakeholder.name);
|
|
38
39
|
return [
|
|
39
40
|
{
|
|
40
41
|
label: t("Products"),
|
|
@@ -46,14 +47,16 @@ function SupplyChainMap({selectedSources = {}, t = () => {}, goTo = () => {}, op
|
|
|
46
47
|
},
|
|
47
48
|
{
|
|
48
49
|
label: t("Participants"),
|
|
49
|
-
value:
|
|
50
|
+
value: participants?.length > 0 ? participants.join(', ') : "-",
|
|
50
51
|
},
|
|
51
52
|
];
|
|
52
53
|
}}
|
|
53
54
|
link
|
|
54
55
|
onClickLink={(data) => {
|
|
55
|
-
const locationTypes = ['
|
|
56
|
-
if
|
|
56
|
+
const locationTypes = ['village', 'town', 'area', 'territory'];
|
|
57
|
+
if(data?.type === 'mineSite') {
|
|
58
|
+
goTo(getRedirectLink(`/app/mine-summary/${data.datastakeId}`));
|
|
59
|
+
} else if (locationTypes.includes(data.type)) {
|
|
57
60
|
goTo(getRedirectLink(`/app/view/locations/${data.datastakeId}`));
|
|
58
61
|
} else {
|
|
59
62
|
goTo(getRedirectLink(`/app/view/stakeholders/${data.datastakeId}`));
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
export const mapData = ({ t, data = [], tabSelected }) => {
|
|
2
2
|
if (!data.length) {
|
|
3
|
-
return [
|
|
4
|
-
{ category: "", type: t("Stakeholders"), value: 0.5 },
|
|
5
|
-
{ category: "", type: t("Locations"), value: 0.5 },
|
|
6
|
-
{ category: "", type: t("Events"), value: 0.5 },
|
|
7
|
-
{ category: " ", type: "Stakeholders", value: 0.5 },
|
|
8
|
-
{ category: " ", type: "Locations", value: 0.5 },
|
|
9
|
-
{ category: " ", type: t("Events"), value: 0.5 },
|
|
10
|
-
{ category: " ", type: t("Stakeholders"), value: 0.5 },
|
|
11
|
-
{ category: " ", type: t("Locations"), value: 0.5 },
|
|
12
|
-
{ category: " ", type: t("Events"), value: 0.5 },
|
|
13
|
-
{ category: " ", type: t("Stakeholders"), value: 0.5 },
|
|
14
|
-
{ category: " ", type: t("Locations"), value: 0.5 },
|
|
15
|
-
{ category: " ", type: t("Events"), value: 0.5 },
|
|
16
|
-
];
|
|
3
|
+
return [];
|
|
17
4
|
}
|
|
18
5
|
|
|
19
6
|
const metricTypes = {
|
|
@@ -11,16 +11,23 @@ export const useContributionsGraph = ({
|
|
|
11
11
|
return mapData({ t, data, tabSelected });
|
|
12
12
|
}, [data, t]);
|
|
13
13
|
|
|
14
|
+
const isEmpty = useMemo(() => _data?.length === 0, [_data]);
|
|
15
|
+
|
|
14
16
|
const chartConfig = useMemo(() => {
|
|
15
17
|
return {
|
|
16
18
|
data: _data,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
xFieldKey: "value",
|
|
20
|
+
yFieldKey: "category",
|
|
19
21
|
seriesField: "type",
|
|
20
22
|
isGroup: true,
|
|
23
|
+
...(isEmpty && {
|
|
24
|
+
xAxisConfig: {
|
|
25
|
+
min: 0,
|
|
26
|
+
max: 10,
|
|
27
|
+
tickCount: 5,
|
|
28
|
+
}
|
|
29
|
+
}),
|
|
21
30
|
renderTooltipContent: (title, items) => {
|
|
22
|
-
const isEmpty = !data.length;
|
|
23
|
-
|
|
24
31
|
const tooltipItems = items.map((item) => ({
|
|
25
32
|
label: item.name,
|
|
26
33
|
color: item.color,
|
|
@@ -40,7 +47,7 @@ export const useContributionsGraph = ({
|
|
|
40
47
|
],
|
|
41
48
|
}
|
|
42
49
|
|
|
43
|
-
}, [_data, t, theme]);
|
|
50
|
+
}, [_data, t, theme, isEmpty]);
|
|
44
51
|
|
|
45
52
|
return chartConfig;
|
|
46
53
|
}
|
|
@@ -59,7 +59,7 @@ export const useTriangulation = ({ widgetData, t = () => {}, section, theme = {}
|
|
|
59
59
|
return renderTooltipJsx({
|
|
60
60
|
title: t(
|
|
61
61
|
section === "data-compilation"
|
|
62
|
-
? "
|
|
62
|
+
? "Information Sharing"
|
|
63
63
|
: "Triangulation",
|
|
64
64
|
),
|
|
65
65
|
items: [
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Tooltip, Tag } from 'antd';
|
|
3
|
+
import { findOptions } from '../../../../helpers/StringHelper.js';
|
|
4
|
+
import { renderDateFormatted } from '../../../../helpers/Forms.js';
|
|
5
|
+
import CustomIcon from '../../../core/components/Icon/CustomIcon.jsx';
|
|
6
|
+
import AvatarGroup from '../../../core/components/AvatarGroup/index.jsx';
|
|
7
|
+
import sourceAvatarConfig from '../../../../helpers/sourceAvatarConfig.js';
|
|
8
|
+
import MoreMenu from '../../../core/components/Table/MoreMenu/index.jsx';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const getLinkValue = (value, linkingObject) => {
|
|
12
|
+
if(linkingObject && linkingObject?.[value]) {
|
|
13
|
+
return linkingObject?.[value]?.name;
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink, theme, subject, data, applications}) => [
|
|
19
|
+
{
|
|
20
|
+
dataIndex: 'datastakeId',
|
|
21
|
+
title: t('ID'),
|
|
22
|
+
ellipsis: true,
|
|
23
|
+
show: true,
|
|
24
|
+
render: (v, all) => {
|
|
25
|
+
if (all.empty) {
|
|
26
|
+
return <div className="daf-default-cell" />
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return <Tooltip title={v}>{v}</Tooltip>;
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
dataIndex: 'partner',
|
|
34
|
+
title: t('Partner'),
|
|
35
|
+
ellipsis: true,
|
|
36
|
+
show: true,
|
|
37
|
+
render: (v, all) => {
|
|
38
|
+
if (all.empty) {
|
|
39
|
+
return <div className="daf-default-cell" />
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return <Tooltip title={v}>{v}</Tooltip>;
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
dataIndex: 'dataPoints',
|
|
47
|
+
title: t('Data Points'),
|
|
48
|
+
ellipsis: true,
|
|
49
|
+
show: true,
|
|
50
|
+
render: (v, all) => {
|
|
51
|
+
if (all.empty) {
|
|
52
|
+
return <div className="daf-default-cell" />
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const category = findOptions(v, data?.options?.locationCategories);
|
|
56
|
+
|
|
57
|
+
return category ? <Tooltip title={category}>{category}</Tooltip> : '-';
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
dataIndex: 'country',
|
|
62
|
+
title: t('Country'),
|
|
63
|
+
ellipsis: true,
|
|
64
|
+
show: true,
|
|
65
|
+
render: (v, all) => {
|
|
66
|
+
if (all.empty) {
|
|
67
|
+
return <div className="daf-default-cell" />
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const country = findOptions(v, options?.countries);
|
|
71
|
+
|
|
72
|
+
return country ? <Tooltip title={country}>{country}</Tooltip> : '-';
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
dataIndex: 'province',
|
|
77
|
+
title: t('Province'),
|
|
78
|
+
ellipsis: true,
|
|
79
|
+
show: true,
|
|
80
|
+
render: (v, all) => {
|
|
81
|
+
if (all.empty) {
|
|
82
|
+
return <div className="daf-default-cell" />
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const province = getLinkValue(all?.administrativeLevel1, all?.linking?.SCL);
|
|
86
|
+
|
|
87
|
+
return province ? <Tooltip title={province}>{province}</Tooltip> : '-';
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
dataIndex: 'territory',
|
|
92
|
+
title: t('Territory'),
|
|
93
|
+
ellipsis: true,
|
|
94
|
+
show: true,
|
|
95
|
+
render: (v, all) => {
|
|
96
|
+
if (all.empty) {
|
|
97
|
+
return <div className="daf-default-cell" />
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const territory = getLinkValue(all?.administrativeLevel2, all?.linking?.SCL);
|
|
101
|
+
|
|
102
|
+
return territory ? <Tooltip title={territory}>{territory}</Tooltip> : '-';
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
title: t("Sources"),
|
|
107
|
+
dataIndex: "sources",
|
|
108
|
+
key: "sources",
|
|
109
|
+
show: activeTab !== "own",
|
|
110
|
+
render: (val, all) => {
|
|
111
|
+
if (all.empty) {
|
|
112
|
+
return <div className="daf-default-cell" />;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const sources = sourceAvatarConfig(val, user, applications);
|
|
116
|
+
|
|
117
|
+
return <AvatarGroup items={sources}></AvatarGroup>;
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
title: t("Last Update"),
|
|
122
|
+
dataIndex: "updatedAt",
|
|
123
|
+
key: "updatedAt",
|
|
124
|
+
width: 125,
|
|
125
|
+
render: (date, all) => {
|
|
126
|
+
if (all.empty) {
|
|
127
|
+
return <div className="daf-default-cell" />;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
|
|
131
|
+
return <Tooltip title={_date}>{_date}</Tooltip>;
|
|
132
|
+
},
|
|
133
|
+
ellipsis: true,
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
{
|
|
137
|
+
id: 'actions',
|
|
138
|
+
title: "",
|
|
139
|
+
width: 60,
|
|
140
|
+
render: (_, all) => {
|
|
141
|
+
if (all.empty) {
|
|
142
|
+
return <div className="daf-default-cell" />;
|
|
143
|
+
}
|
|
144
|
+
const onClick = () => {
|
|
145
|
+
const link = `/app/view/${subject}/${all.datastakeId}`;
|
|
146
|
+
if (activeTab === "shared") {
|
|
147
|
+
link += `?sourceId=${all?.authorId?.id}`;
|
|
148
|
+
}
|
|
149
|
+
goTo(getRedirectLink(link));
|
|
150
|
+
};
|
|
151
|
+
const moreMenuItems = [
|
|
152
|
+
{
|
|
153
|
+
label: t("Details"),
|
|
154
|
+
value: "details",
|
|
155
|
+
onClick: onClick,
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
label: t("Summary"),
|
|
159
|
+
value: "Summary",
|
|
160
|
+
onClick: () => {
|
|
161
|
+
let link = `/app/summary/${subject}/${all.datastakeId}`
|
|
162
|
+
if (activeTab === "shared") {
|
|
163
|
+
link += `?sourceId=${all?.authorId?.id}`;
|
|
164
|
+
}
|
|
165
|
+
goTo(getRedirectLink(link));
|
|
166
|
+
},
|
|
167
|
+
// disabled: true,
|
|
168
|
+
},
|
|
169
|
+
];
|
|
170
|
+
return <div >
|
|
171
|
+
<MoreMenu items={moreMenuItems} />
|
|
172
|
+
</div>;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
].filter((column) => column.show !== false);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -106,10 +106,7 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
const eventCategory = findOptions(v, data?.options?.eventCategoryOptions);
|
|
109
|
-
const categoryValue = getEventCategoryBySubject(eventCategory,
|
|
110
|
-
console.log({categoryValue})
|
|
111
|
-
console.log({eventCategory})
|
|
112
|
-
console.log({subject})
|
|
109
|
+
const categoryValue = getEventCategoryBySubject(eventCategory, "correctiveActions", true);
|
|
113
110
|
|
|
114
111
|
return categoryValue ? <Tooltip title={categoryValue}>{categoryValue}</Tooltip> : '-';
|
|
115
112
|
},
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export const getEventCategoryBySubject = (eventCategoryObject, subject) => {
|
|
1
|
+
export const getEventCategoryBySubject = (eventCategoryObject, subject, isSingular = false) => {
|
|
2
|
+
console.log({eventCategoryObject, subject})
|
|
2
3
|
if (!eventCategoryObject || typeof eventCategoryObject !== 'object') {
|
|
3
4
|
return null;
|
|
4
5
|
}
|
|
5
6
|
|
|
6
|
-
const subjectSingular = subject.endsWith('ies')
|
|
7
|
+
const subjectSingular = isSingular ? subject : subject.endsWith('ies')
|
|
7
8
|
? subject.slice(0, -3) + 'y'
|
|
8
9
|
: subject.endsWith('s')
|
|
9
10
|
? subject.slice(0, -1)
|
|
@@ -7,6 +7,7 @@ import AvatarGroup from '../../../core/components/AvatarGroup/index.jsx';
|
|
|
7
7
|
import sourceAvatarConfig from '../../../../helpers/sourceAvatarConfig.js';
|
|
8
8
|
import MoreMenu from '../../../core/components/Table/MoreMenu/index.jsx';
|
|
9
9
|
import MoreOptions from '../../../core/components/Table/MoreOptions/index.jsx';
|
|
10
|
+
import { renderStatusTag } from '../../../utils/tags.js';
|
|
10
11
|
|
|
11
12
|
export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink, theme, subject, data, applications}) => [
|
|
12
13
|
{
|
|
@@ -89,8 +90,8 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
|
|
|
89
90
|
return <div className="daf-default-cell" />
|
|
90
91
|
}
|
|
91
92
|
|
|
92
|
-
const operators = all?.
|
|
93
|
-
return (operators && operators.length > 0) ? <MoreOptions data={operators || []}
|
|
93
|
+
const operators = all?.operator?.map((operator) => operator?.clientLocation?.name);
|
|
94
|
+
return (operators && operators.length > 0) ? <MoreOptions data={operators || []} toolTipPlacement={operators?.length < 2 ? "topLeft" : "top"} /> : '-';
|
|
94
95
|
},
|
|
95
96
|
},
|
|
96
97
|
{
|
|
@@ -117,8 +118,9 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
|
|
|
117
118
|
if (all.empty) {
|
|
118
119
|
return <div className="daf-default-cell" />
|
|
119
120
|
}
|
|
120
|
-
const
|
|
121
|
-
|
|
121
|
+
const _val = all?.published || all?.status === "submitted" ? "submitted" : v;
|
|
122
|
+
|
|
123
|
+
return renderStatusTag({ value: _val, t });
|
|
122
124
|
},
|
|
123
125
|
},
|
|
124
126
|
|
|
@@ -6,6 +6,7 @@ import CustomIcon from '../../../core/components/Icon/CustomIcon.jsx';
|
|
|
6
6
|
import AvatarGroup from '../../../core/components/AvatarGroup/index.jsx';
|
|
7
7
|
import sourceAvatarConfig from '../../../../helpers/sourceAvatarConfig.js';
|
|
8
8
|
import MoreMenu from '../../../core/components/Table/MoreMenu/index.jsx';
|
|
9
|
+
import { renderStatusTag } from '../../../utils/tags.js';
|
|
9
10
|
|
|
10
11
|
export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink, theme, subject, data, applications}) => [
|
|
11
12
|
{
|
|
@@ -133,8 +134,9 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
|
|
|
133
134
|
if (all.empty) {
|
|
134
135
|
return <div className="daf-default-cell" />
|
|
135
136
|
}
|
|
136
|
-
const
|
|
137
|
-
|
|
137
|
+
const _val = all?.published || all?.status === "submitted" ? "submitted" : v;
|
|
138
|
+
|
|
139
|
+
return renderStatusTag({ value: _val, t });
|
|
138
140
|
},
|
|
139
141
|
},
|
|
140
142
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export const getKeyIndicatorsRowConfig = ({ t, data = {} }) => [
|
|
4
|
+
{
|
|
5
|
+
label: t('Region'),
|
|
6
|
+
render: () => {
|
|
7
|
+
// const region = data?.region;
|
|
8
|
+
return <div>{ '-'}</div>;
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
label: t('Associated Plots'),
|
|
13
|
+
render: () => {
|
|
14
|
+
// const plotsCount = data?.associatedPlotsCount || '0';
|
|
15
|
+
return <div>{'0'}</div>
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
label: t('Implementation Partners'),
|
|
20
|
+
render: () => {
|
|
21
|
+
// const partnersCount = data?.partnersCount || '0';
|
|
22
|
+
return <div>{'0'}</div>
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
label: t('Total Activities'),
|
|
27
|
+
render: () => {
|
|
28
|
+
// const activitiesCount = data?.activitiesCount || '0';
|
|
29
|
+
return <div>{'0'}</div>
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
label: t('Information Sources'),
|
|
34
|
+
render: () => {
|
|
35
|
+
// const sourcesCount = data?.informationSourcesCount || '0';
|
|
36
|
+
return <div>{'0'}</div>
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import L from "leaflet";
|
|
2
|
+
|
|
3
|
+
export const getMapDataFromActivity = (activityData, t) => {
|
|
4
|
+
const location = activityData?.location;
|
|
5
|
+
const perimeter = location?.perimeter;
|
|
6
|
+
|
|
7
|
+
const area = Array.isArray(perimeter) && perimeter.length > 0
|
|
8
|
+
? perimeter
|
|
9
|
+
.filter((coord) => Array.isArray(coord) && coord.length >= 2)
|
|
10
|
+
.map((coord) => {
|
|
11
|
+
const first = typeof coord[0] === 'number' ? coord[0] : parseFloat(coord[0]);
|
|
12
|
+
const second = typeof coord[1] === 'number' ? coord[1] : parseFloat(coord[1]);
|
|
13
|
+
|
|
14
|
+
if (isNaN(first) || isNaN(second) || !isFinite(first) || !isFinite(second)) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Try both formats and use Leaflet to validate
|
|
19
|
+
// First try as [lat, lng]
|
|
20
|
+
try {
|
|
21
|
+
const latLng1 = L.latLng(first, second);
|
|
22
|
+
if (latLng1.lat >= -90 && latLng1.lat <= 90 &&
|
|
23
|
+
latLng1.lng >= -180 && latLng1.lng <= 180) {
|
|
24
|
+
return [latLng1.lat, latLng1.lng];
|
|
25
|
+
}
|
|
26
|
+
} catch (e) {
|
|
27
|
+
// Not valid as [lat, lng], try swapping
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Try as [lng, lat] (GeoJSON format) - swap them
|
|
31
|
+
try {
|
|
32
|
+
const latLng2 = L.latLng(second, first);
|
|
33
|
+
if (latLng2.lat >= -90 && latLng2.lat <= 90 &&
|
|
34
|
+
latLng2.lng >= -180 && latLng2.lng <= 180) {
|
|
35
|
+
return [latLng2.lat, latLng2.lng];
|
|
36
|
+
}
|
|
37
|
+
} catch (e) {
|
|
38
|
+
// Invalid coordinates
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return null;
|
|
42
|
+
})
|
|
43
|
+
.filter((coord) => coord !== null)
|
|
44
|
+
: null;
|
|
45
|
+
|
|
46
|
+
const mapData = [];
|
|
47
|
+
const baseColor = '#15FFFFB2';
|
|
48
|
+
const locationName = location?.name || activityData?.name || t("Activity Location");
|
|
49
|
+
const datastakeId = location?.datastakeId || activityData?.datastakeId;
|
|
50
|
+
|
|
51
|
+
// Helper to validate coordinates
|
|
52
|
+
const isValidCoordinate = (coord) => {
|
|
53
|
+
const num = typeof coord === 'number' ? coord : parseFloat(coord);
|
|
54
|
+
return !isNaN(num) && isFinite(num);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// Entry 1: Perimeter polygon (independent - show if it exists)
|
|
58
|
+
if (area && area.length >= 3) {
|
|
59
|
+
mapData.push({
|
|
60
|
+
_id: {},
|
|
61
|
+
id: `${activityData?.id || activityData?.datastakeId || 'perimeter'}-perimeter`,
|
|
62
|
+
area: area,
|
|
63
|
+
color: baseColor,
|
|
64
|
+
name: locationName,
|
|
65
|
+
plotName: locationName,
|
|
66
|
+
territoryTitle: t("Associated Plot"),
|
|
67
|
+
subTitle: t("Activity Location"),
|
|
68
|
+
type: t("Activity Location"),
|
|
69
|
+
datastakeId: datastakeId,
|
|
70
|
+
sources: null,
|
|
71
|
+
link: null,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Entry 2: Arrival marker (independent - show if it exists)
|
|
76
|
+
const arrivalLat = activityData?.locationCheckArrival?.latitude;
|
|
77
|
+
const arrivalLng = activityData?.locationCheckArrival?.longitude;
|
|
78
|
+
if (isValidCoordinate(arrivalLat) && isValidCoordinate(arrivalLng)) {
|
|
79
|
+
mapData.push({
|
|
80
|
+
_id: {},
|
|
81
|
+
id: `${activityData?.id || activityData?.datastakeId || 'arrival'}-arrival`,
|
|
82
|
+
area: area && area.length >= 3 ? area : null,
|
|
83
|
+
color: baseColor,
|
|
84
|
+
gps: {
|
|
85
|
+
latitude: typeof arrivalLat === 'number' ? arrivalLat : parseFloat(arrivalLat),
|
|
86
|
+
longitude: typeof arrivalLng === 'number' ? arrivalLng : parseFloat(arrivalLng),
|
|
87
|
+
},
|
|
88
|
+
name: t("Activity Start"),
|
|
89
|
+
plotName: locationName,
|
|
90
|
+
territoryTitle: t("Associated Plot"),
|
|
91
|
+
datastakeId: `${datastakeId}-arrival`,
|
|
92
|
+
sources: null,
|
|
93
|
+
link: null,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Entry 3: Departure marker (independent - show if it exists)
|
|
98
|
+
const departureLat = activityData?.locationCheckDeparture?.latitude;
|
|
99
|
+
const departureLng = activityData?.locationCheckDeparture?.longitude;
|
|
100
|
+
if (isValidCoordinate(departureLat) && isValidCoordinate(departureLng)) {
|
|
101
|
+
mapData.push({
|
|
102
|
+
_id: {},
|
|
103
|
+
id: `${activityData?.id || activityData?.datastakeId || 'departure'}-departure`,
|
|
104
|
+
area: area && area.length >= 3 ? area : null,
|
|
105
|
+
color: baseColor,
|
|
106
|
+
gps: {
|
|
107
|
+
latitude: typeof departureLat === 'number' ? departureLat : parseFloat(departureLat),
|
|
108
|
+
longitude: typeof departureLng === 'number' ? departureLng : parseFloat(departureLng),
|
|
109
|
+
},
|
|
110
|
+
name: t("Activity End"),
|
|
111
|
+
plotName: locationName,
|
|
112
|
+
territoryTitle: t("Associated Plot"),
|
|
113
|
+
datastakeId: `${datastakeId}-departure`,
|
|
114
|
+
markerColor: "#FF7A45",
|
|
115
|
+
sources: null,
|
|
116
|
+
link: null,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return mapData;
|
|
121
|
+
};
|
|
122
|
+
|