datastake-daf 0.6.794 → 0.6.796
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/build/favicon.ico +0 -0
- package/build/logo192.png +0 -0
- package/build/logo512.png +0 -0
- package/build/manifest.json +25 -0
- package/build/robots.txt +3 -0
- package/dist/components/index.js +3354 -4327
- package/dist/pages/index.js +2853 -3439
- package/dist/services/index.js +3 -69
- package/dist/style/datastake/mapbox-gl.css +330 -0
- package/dist/utils/index.js +20 -14
- package/package.json +1 -1
- package/public/Vegetation/black-default.svg +23 -0
- package/public/Vegetation/black.svg +12 -0
- package/public/Vegetation/damage-from-insects-default.svg +14 -0
- package/public/Vegetation/damage-from-insects.svg +8 -0
- package/public/Vegetation/dry-or-dead-default.svg +16 -0
- package/public/Vegetation/dry-or-dead.svg +7 -0
- package/public/Vegetation/healthy-default.svg +14 -0
- package/public/Vegetation/healthy.svg +34 -0
- package/public/Vegetation/mosaic-default.svg +17 -0
- package/public/Vegetation/mosaic.svg +9 -0
- package/public/Vegetation/no-leaves-default.svg +6 -0
- package/public/Vegetation/no-leaves.svg +5 -0
- package/public/Vegetation/reddish-default.svg +23 -0
- package/public/Vegetation/reddish.svg +79 -0
- package/public/Vegetation/spider-webs-default.svg +10 -0
- package/public/Vegetation/spider-webs.svg +10 -0
- package/public/Vegetation/white-default.svg +25 -0
- package/public/Vegetation/white.svg +12 -0
- package/public/Vegetation/yellowing-default.svg +7 -0
- package/public/Vegetation/yellowing.svg +8 -0
- package/src/@daf/core/components/Dashboard/Map/hook.js +25 -1
- package/src/@daf/core/components/Dashboard/Widget/ActivityIndicators/index.jsx +24 -6
- package/src/@daf/core/components/Dashboard/Widget/ActivityIndicators/style.js +2 -6
- package/src/@daf/core/components/Dashboard/Widget/VegetationWidget/VegetationWidget.stories.jsx +76 -0
- package/src/@daf/core/components/Dashboard/Widget/VegetationWidget/config.js +31 -0
- package/src/@daf/core/components/Dashboard/Widget/VegetationWidget/index.jsx +137 -0
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/hook.js +1 -0
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/index.jsx +1 -1
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/hook.js +1 -1
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/index.jsx +1 -1
- package/src/@daf/core/components/Screens/Admin/AdminModals/AddUser/index.jsx +1 -0
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/helper.js +2 -2
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/index.jsx +8 -18
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineSubjects/index.jsx +6 -6
- package/src/@daf/core/components/Screens/Admin/AdminModals/NewAccount/index.jsx +1 -1
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Dashboard.jsx +2 -2
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Location.jsx +7 -6
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Subjects.jsx +2 -2
- package/src/@daf/core/components/Screens/Admin/AdminScreens/index.js +0 -1
- package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/index.jsx +0 -1
- package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/index.jsx +45 -73
- package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/columns.js +37 -37
- package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/index.jsx +22 -48
- package/src/@daf/core/components/Screens/Admin/AdminTables/UserTable/index.jsx +0 -1
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Edit/index.jsx +1 -3
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/SidebarMenu/index.jsx +3 -5
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/helper.js +8 -13
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/index.jsx +2 -2
- package/src/@daf/core/components/Screens/Admin/AdminViews/index.jsx +4 -3
- package/src/@daf/core/components/Screens/Admin/adminRoutes.js +2 -81
- package/src/@daf/core/components/ViewForm/components/Records/config.js +3 -0
- package/src/@daf/pages/Dashboards/SelfAssesment/components/AssociatedInformation/index.jsx +1 -1
- package/src/@daf/pages/Dashboards/SelfAssesment/components/OrganisationInformation/columns.js +0 -1
- package/src/@daf/pages/Dashboards/SelfAssesment/components/ProductionSites/columns.js +3 -2
- package/src/@daf/pages/Dashboards/SelfAssesment/components/ProductionSites/index.jsx +13 -4
- package/src/@daf/pages/Dashboards/SelfAssesment/index.jsx +22 -20
- package/src/@daf/pages/Events/Activities/columns.js +1 -1
- package/src/@daf/pages/Events/Activities/config.js +23 -30
- package/src/@daf/pages/Events/Incidents/columns.js +1 -1
- package/src/@daf/pages/Events/Incidents/config.js +23 -30
- package/src/@daf/pages/Events/config.js +7 -7
- package/src/@daf/pages/Locations/MineSite/columns.js +3 -3
- package/src/@daf/pages/Locations/MineSite/config.js +20 -14
- package/src/@daf/pages/Locations/config.js +3 -3
- package/src/@daf/pages/Stakeholders/Operators/columns.js +2 -2
- package/src/@daf/pages/Stakeholders/Operators/config.js +9 -16
- package/src/@daf/pages/Stakeholders/Workers/columns.js +1 -1
- package/src/@daf/pages/Stakeholders/Workers/config.js +23 -29
- package/src/@daf/pages/Stakeholders/config.js +3 -3
- package/src/@daf/pages/Summary/Activities/Monitoring/components/ActivityImagery/index.jsx +12 -10
- package/src/@daf/pages/Summary/Activities/Monitoring/components/BiodiversityAndHabitat/helper.js +86 -0
- package/src/@daf/pages/Summary/Activities/Monitoring/components/BiodiversityAndHabitat/index.jsx +65 -0
- package/src/@daf/pages/Summary/Activities/Monitoring/components/EnvironmentalMetrics/index.jsx +30 -0
- package/src/@daf/pages/Summary/Activities/Monitoring/components/MangroveGrowthAndSurvival/components/PlantedSpecies/index.jsx +15 -28
- package/src/@daf/pages/Summary/Activities/Monitoring/components/MangroveGrowthAndSurvival/components/SeedlingsHeight/index.jsx +17 -30
- package/src/@daf/pages/Summary/Activities/Monitoring/components/MangroveGrowthAndSurvival/components/SurvivalRate/index.jsx +38 -45
- package/src/@daf/pages/Summary/Activities/Monitoring/components/MangroveGrowthAndSurvival/index.jsx +87 -8
- package/src/@daf/pages/Summary/Activities/Monitoring/config.js +21 -4
- package/src/@daf/pages/Summary/Activities/Monitoring/helper.js +7 -1
- package/src/@daf/pages/Summary/Activities/Monitoring/index.jsx +31 -8
- package/src/@daf/pages/Summary/Operator/components/TradeRelationships/helper.js +1 -1
- package/src/@daf/pages/TablePage/helper.js +17 -1
- package/src/@daf/pages/TablePage/hook.js +3 -1
- package/src/@daf/pages/TablePage/index.jsx +8 -6
- package/src/@daf/pages/View/index.jsx +4 -2
- package/src/@daf/services/AdminService.js +7 -79
- package/src/@daf/services/DashboardService.js +1 -2
- package/src/@daf/utils/filters.js +26 -15
- package/src/constants/Vegetation.js +15 -0
- package/src/constants/locales/en/translation.js +1 -7
- package/src/constants/locales/fr/translation.js +2 -1
- package/src/constants/locales/sp/translation.js +2 -1
- package/src/index.js +1 -0
- package/src/pages.js +1 -10
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/columns.js +0 -79
- package/src/@daf/core/components/Screens/Admin/AdminScreens/SubjectsView.jsx +0 -272
- package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/column.js +0 -223
- package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/helper.js +0 -65
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditLocation/index.jsx +0 -81
- package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/index.jsx +0 -76
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/config.js +0 -38
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/helpers.js +0 -13
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/index.jsx +0 -77
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/config.js +0 -38
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/helpers.js +0 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/index.jsx +0 -75
- package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/columns.js +0 -180
- package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/config.js +0 -0
- package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/index.jsx +0 -27
- package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/columns.js +0 -157
- package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/config.js +0 -31
- package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/index.js +0 -77
- package/src/@daf/pages/SelfAssesment/components/ProductionSiteTable/columns.js +0 -117
- package/src/@daf/pages/SelfAssesment/components/ProductionSiteTable/index.jsx +0 -54
- package/src/@daf/pages/SelfAssesment/index.jsx +0 -0
package/src/@daf/core/components/Dashboard/Widget/VegetationWidget/VegetationWidget.stories.jsx
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import VegetationWidget from "./index.jsx";
|
|
2
|
+
import ThemeLayout from "../../../ThemeLayout/index.jsx";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: "Dashboard/Widgets/VegetationWidget",
|
|
6
|
+
component: VegetationWidget,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
argsTypes: {
|
|
9
|
+
activeVegetationConditions: {
|
|
10
|
+
control: {
|
|
11
|
+
type: "checkbox",
|
|
12
|
+
},
|
|
13
|
+
options: [
|
|
14
|
+
"healthy",
|
|
15
|
+
"white",
|
|
16
|
+
"black",
|
|
17
|
+
"reddish",
|
|
18
|
+
"yellowing",
|
|
19
|
+
"mosaic",
|
|
20
|
+
"dryOrDead",
|
|
21
|
+
"noLeaves",
|
|
22
|
+
"spiderWebs",
|
|
23
|
+
"damageFromInsects",
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
decorators: [
|
|
28
|
+
(Story) => (
|
|
29
|
+
<div style={{ margin: "3em" }}>
|
|
30
|
+
<ThemeLayout>
|
|
31
|
+
<Story />
|
|
32
|
+
</ThemeLayout>
|
|
33
|
+
</div>
|
|
34
|
+
),
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const Primary = {
|
|
39
|
+
name: "VegetationWidget",
|
|
40
|
+
args: {
|
|
41
|
+
title: "Vegetation Health",
|
|
42
|
+
activeVegetationConditions: [
|
|
43
|
+
"healthy",
|
|
44
|
+
"reddish",
|
|
45
|
+
"dryOrDead",
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const Empty = {
|
|
51
|
+
name: "Empty",
|
|
52
|
+
args: {
|
|
53
|
+
title: "Vegetation Health",
|
|
54
|
+
activeVegetationConditions: [],
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const AllActive = {
|
|
59
|
+
name: "All Active",
|
|
60
|
+
args: {
|
|
61
|
+
title: "Vegetation Health",
|
|
62
|
+
activeVegetationConditions: [
|
|
63
|
+
"healthy",
|
|
64
|
+
"white",
|
|
65
|
+
"black",
|
|
66
|
+
"reddish",
|
|
67
|
+
"yellowing",
|
|
68
|
+
"mosaic",
|
|
69
|
+
"dryOrDead",
|
|
70
|
+
"noLeaves",
|
|
71
|
+
"spiderWebs",
|
|
72
|
+
"damageFromInsects",
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { VEGETATION_KEYS as KEYS } from "../../../../../../constants/Vegetation";
|
|
2
|
+
|
|
3
|
+
// Mapping from growthObservations keys to VEGETATION_KEYS
|
|
4
|
+
export const GROWTH_OBSERVATIONS_TO_VEGETATION_KEYS = {
|
|
5
|
+
"white_spots": KEYS.WHITE_SPOTS,
|
|
6
|
+
"healthy_leaves": KEYS.HEALTHY,
|
|
7
|
+
"yellowing_leaves": KEYS.YELLOWING,
|
|
8
|
+
"leaf_mosaic": KEYS.MOSAIC,
|
|
9
|
+
"dry_dead_leaves": KEYS.DRY_OR_DEAD,
|
|
10
|
+
"no_leaves": KEYS.NO_LEAVES,
|
|
11
|
+
"black_spots": KEYS.BLACK_SPOTS,
|
|
12
|
+
"reddish_spots": KEYS.REDDISH_SPOTS,
|
|
13
|
+
"spider_webs": KEYS.SPIDER_WEBS,
|
|
14
|
+
"insect_damage": KEYS.DAMAGE_FROM_INSECTS,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const getVegetationConfig = () => {
|
|
18
|
+
return [
|
|
19
|
+
{ img: "/Vegetation/healthy.svg", key: KEYS.HEALTHY, disabled: "/Vegetation/healthy-default.svg" },
|
|
20
|
+
{ img: "/Vegetation/white.svg", key: KEYS.WHITE_SPOTS, disabled: "/Vegetation/white-default.svg" },
|
|
21
|
+
{ img: "/Vegetation/black.svg", key: KEYS.BLACK_SPOTS, disabled: "/Vegetation/black-default.svg" },
|
|
22
|
+
{ img: "/Vegetation/reddish.svg", key: KEYS.REDDISH_SPOTS, disabled: "/Vegetation/reddish-default.svg" },
|
|
23
|
+
{ img: "/Vegetation/yellowing.svg", key: KEYS.YELLOWING, disabled: "/Vegetation/yellowing-default.svg" },
|
|
24
|
+
{ img: "/Vegetation/mosaic.svg", key: KEYS.MOSAIC, disabled: "/Vegetation/mosaic-default.svg" },
|
|
25
|
+
{ img: "/Vegetation/dry-or-dead.svg", key: KEYS.DRY_OR_DEAD, disabled: "/Vegetation/dry-or-dead-default.svg" },
|
|
26
|
+
{ img: "/Vegetation/no-leaves.svg", key: KEYS.NO_LEAVES, disabled: "/Vegetation/no-leaves-default.svg" },
|
|
27
|
+
{ img: "/Vegetation/spider-webs.svg", key: KEYS.SPIDER_WEBS, disabled: "/Vegetation/spider-webs-default.svg" },
|
|
28
|
+
{ img: "/Vegetation/damage-from-insects.svg", key: KEYS.DAMAGE_FROM_INSECTS, disabled: "/Vegetation/damage-from-insects-default.svg" },
|
|
29
|
+
];
|
|
30
|
+
};
|
|
31
|
+
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import Widget from "../index.jsx";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import { getVegetationConfig, GROWTH_OBSERVATIONS_TO_VEGETATION_KEYS } from "./config.js";
|
|
4
|
+
import { Tooltip } from "antd";
|
|
5
|
+
|
|
6
|
+
export default function VegetationWidget({
|
|
7
|
+
title = "Vegetation Health",
|
|
8
|
+
activeVegetationConditions = [],
|
|
9
|
+
filterKeys = null,
|
|
10
|
+
columnsPerRow = null,
|
|
11
|
+
itemWidth = 140.33,
|
|
12
|
+
itemHeight = 140,
|
|
13
|
+
growthObservations = [],
|
|
14
|
+
t = (key) => key,
|
|
15
|
+
...props
|
|
16
|
+
}) {
|
|
17
|
+
let vegetationConfig = getVegetationConfig();
|
|
18
|
+
|
|
19
|
+
// Get all VEGETATION_KEYS values before filtering (needed for mapping check)
|
|
20
|
+
const allVegetationKeys = vegetationConfig.map(item => item.key);
|
|
21
|
+
|
|
22
|
+
// Filter to show only specific keys if filterKeys is provided
|
|
23
|
+
if (filterKeys && Array.isArray(filterKeys)) {
|
|
24
|
+
vegetationConfig = vegetationConfig.filter(item => filterKeys.includes(item.key));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Map growthObservations to VEGETATION_KEYS
|
|
28
|
+
// Handle both formats: growthObservations keys (e.g., "yellowing_leaves") and VEGETATION_KEYS (e.g., "yellowing")
|
|
29
|
+
const mappedGrowthObservations = Array.isArray(growthObservations)
|
|
30
|
+
? growthObservations
|
|
31
|
+
.map(obs => {
|
|
32
|
+
// First try to map from growthObservations format
|
|
33
|
+
const mapped = GROWTH_OBSERVATIONS_TO_VEGETATION_KEYS[obs];
|
|
34
|
+
if (mapped) {
|
|
35
|
+
return mapped;
|
|
36
|
+
}
|
|
37
|
+
// If not mapped, check if it's already a VEGETATION_KEY value
|
|
38
|
+
if (allVegetationKeys.includes(obs)) {
|
|
39
|
+
return obs;
|
|
40
|
+
}
|
|
41
|
+
// Debug: log unmapped observations
|
|
42
|
+
if (obs) {
|
|
43
|
+
console.warn(`VegetationWidget: Unmapped growthObservation "${obs}"`);
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
})
|
|
47
|
+
.filter(Boolean)
|
|
48
|
+
: [];
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<Widget title={title} className={`with-border-header`} {...props}>
|
|
52
|
+
<VegetationWrapper $columnsPerRow={columnsPerRow}>
|
|
53
|
+
<VegetationContainer
|
|
54
|
+
$columnsPerRow={columnsPerRow}
|
|
55
|
+
$itemWidth={itemWidth}
|
|
56
|
+
$itemHeight={itemHeight}
|
|
57
|
+
>
|
|
58
|
+
{vegetationConfig.map((item) => {
|
|
59
|
+
// Use colored SVG if the item's key exists in growthObservations (mapped)
|
|
60
|
+
// Otherwise use default SVG
|
|
61
|
+
// Also check activeVegetationConditions for backward compatibility
|
|
62
|
+
const isInGrowthObservations = mappedGrowthObservations.includes(item.key);
|
|
63
|
+
const isInActiveConditions = activeVegetationConditions.includes(item.key);
|
|
64
|
+
|
|
65
|
+
// Use colored SVG if it exists in growthObservations OR activeVegetationConditions
|
|
66
|
+
const shouldUseColored = isInGrowthObservations || isInActiveConditions;
|
|
67
|
+
|
|
68
|
+
// Debug logging for yellowing specifically
|
|
69
|
+
if (item.key === "yellowing") {
|
|
70
|
+
console.log("Yellowing debug:", {
|
|
71
|
+
itemKey: item.key,
|
|
72
|
+
growthObservations,
|
|
73
|
+
mappedGrowthObservations,
|
|
74
|
+
isInGrowthObservations,
|
|
75
|
+
isInActiveConditions,
|
|
76
|
+
shouldUseColored,
|
|
77
|
+
img: item.img,
|
|
78
|
+
disabled: item.disabled
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<Tooltip key={item.key} title={t(`straatos::${item.key}`)}>
|
|
84
|
+
<img
|
|
85
|
+
src={shouldUseColored ? item.img : item.disabled}
|
|
86
|
+
key={item.key}
|
|
87
|
+
className={`vegetation-item`}
|
|
88
|
+
alt={item.key}
|
|
89
|
+
></img>
|
|
90
|
+
</Tooltip>
|
|
91
|
+
);
|
|
92
|
+
})}
|
|
93
|
+
</VegetationContainer>
|
|
94
|
+
</VegetationWrapper>
|
|
95
|
+
</Widget>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const VegetationWrapper = styled.div`
|
|
100
|
+
${props => props.$columnsPerRow ? `
|
|
101
|
+
overflow-x: auto;
|
|
102
|
+
width: 100%;
|
|
103
|
+
` : ''}
|
|
104
|
+
`;
|
|
105
|
+
|
|
106
|
+
const VegetationContainer = styled.div`
|
|
107
|
+
display: grid;
|
|
108
|
+
grid-template-columns: ${props =>
|
|
109
|
+
props.$columnsPerRow
|
|
110
|
+
? `repeat(${props.$columnsPerRow}, 1fr)`
|
|
111
|
+
: `repeat(auto-fit, minmax(${props.$itemWidth}px, 1fr))`
|
|
112
|
+
};
|
|
113
|
+
gap: 24px;
|
|
114
|
+
${props => props.$columnsPerRow ? `
|
|
115
|
+
width: 100%;
|
|
116
|
+
` : ''}
|
|
117
|
+
|
|
118
|
+
.vegetation-item {
|
|
119
|
+
width: 100%;
|
|
120
|
+
aspect-ratio: ${props => props.$itemWidth / props.$itemHeight};
|
|
121
|
+
border-radius: 7px;
|
|
122
|
+
flex-shrink: 0;
|
|
123
|
+
|
|
124
|
+
background-size: cover;
|
|
125
|
+
background-position: center;
|
|
126
|
+
background-repeat: no-repeat;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.vegetation-item-content {
|
|
130
|
+
display: flex;
|
|
131
|
+
align-items: center;
|
|
132
|
+
height: 100%;
|
|
133
|
+
color: white;
|
|
134
|
+
text-align: center;
|
|
135
|
+
}
|
|
136
|
+
`;
|
|
137
|
+
|
|
@@ -10,6 +10,7 @@ const { useToken } = theme;
|
|
|
10
10
|
export default function useTopContributors({ container, data = [], t }) {
|
|
11
11
|
const [mainGraph, setMainGraph] = useState(null);
|
|
12
12
|
const { token } = useToken();
|
|
13
|
+
|
|
13
14
|
useEffect(() => {
|
|
14
15
|
if (container.current) {
|
|
15
16
|
if (mainGraph) {
|
|
@@ -12,7 +12,7 @@ export default function useUserGrowth({ container, data: mainData = {}, t, trans
|
|
|
12
12
|
const [mainGraph, setMainGraph] = useState(null);
|
|
13
13
|
const [data, setData] = useState([]);
|
|
14
14
|
const { token } = useToken();
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
const fetchData = () => {
|
|
17
17
|
const { dates = [] } = mainData;
|
|
18
18
|
const _data = [];
|
|
@@ -9,7 +9,7 @@ export default function UserGrowth({ loading, data = [], t, translationKeys, fet
|
|
|
9
9
|
const [selectValue, setSelectValue] = useState(selectOptions[0]?.value);
|
|
10
10
|
|
|
11
11
|
useUserGrowth({ container, data, t, translationKeys });
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
|
|
14
14
|
useEffect(() => {
|
|
15
15
|
if (typeof fetchUserGrowth === "function") {
|
|
@@ -47,7 +47,7 @@ export const getColumns = ({ t, selectOptions, module, entity }) => {
|
|
|
47
47
|
dataIndex: "administrativeLevel1",
|
|
48
48
|
key: "administrativeLevel1",
|
|
49
49
|
ellipsis: true,
|
|
50
|
-
show: entity
|
|
50
|
+
show: entity.includes("locations"),
|
|
51
51
|
render: (value, all) => {
|
|
52
52
|
let label;
|
|
53
53
|
if(all?.administrativeLevel1 && value === all?.administrativeLevel1) {
|
|
@@ -63,7 +63,7 @@ export const getColumns = ({ t, selectOptions, module, entity }) => {
|
|
|
63
63
|
title: t("Territory"),
|
|
64
64
|
dataIndex: "administrativeLevel2",
|
|
65
65
|
key: "administrativeLevel2",
|
|
66
|
-
show: entity
|
|
66
|
+
show: entity.includes("locations"),
|
|
67
67
|
render: (value, all) => {
|
|
68
68
|
let label;
|
|
69
69
|
if(all?.administrativeLevel2 && value === all?.administrativeLevel2) {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import Modal from "../../../../Modal/index.jsx";
|
|
2
2
|
import { Form, Input, Select, theme } from "antd";
|
|
3
3
|
import { Container } from "../CombineModalStyle.js";
|
|
4
|
+
import { findOptions } from "../../../../../../../helpers/StringHelper.js";
|
|
4
5
|
import DAFTable from "../../../../Table/index.jsx";
|
|
5
6
|
import { useMemo, useState } from "react";
|
|
6
|
-
import { getNameByLevel } from "../../AdminTables/SubjectsTable/helper.js";
|
|
7
7
|
import { getColumns } from "./helper.js";
|
|
8
|
+
import { getNameByLevel } from "../../AdminTables/SubjectsTable/helper.js";
|
|
8
9
|
|
|
9
10
|
const { useToken } = theme;
|
|
10
11
|
|
|
@@ -34,22 +35,10 @@ export default function CombineLocationModal({
|
|
|
34
35
|
|
|
35
36
|
const onSubmit = () => {
|
|
36
37
|
MainForm.validateFields().then((data) => {
|
|
37
|
-
const ids = selectedLocations.map((location) => location.
|
|
38
|
-
const allowedKeys = [
|
|
39
|
-
"id",
|
|
40
|
-
"name",
|
|
41
|
-
"country",
|
|
42
|
-
"category",
|
|
43
|
-
"administrativeLevel1",
|
|
44
|
-
"administrativeLevel2"
|
|
45
|
-
];
|
|
46
|
-
const filteredData = Object.fromEntries(
|
|
47
|
-
Object.entries(data).filter(([key]) => allowedKeys.includes(key))
|
|
48
|
-
);
|
|
49
|
-
|
|
38
|
+
const ids = selectedLocations.map((location) => location._id);
|
|
50
39
|
onSuccess({
|
|
51
40
|
ids,
|
|
52
|
-
data
|
|
41
|
+
data,
|
|
53
42
|
});
|
|
54
43
|
});
|
|
55
44
|
};
|
|
@@ -68,7 +57,8 @@ export default function CombineLocationModal({
|
|
|
68
57
|
setIsDisabled(() => {
|
|
69
58
|
const values = MainForm.getFieldsValue();
|
|
70
59
|
|
|
71
|
-
const requiredFields =
|
|
60
|
+
const requiredFields =
|
|
61
|
+
entity === "location"
|
|
72
62
|
? ["id", "name", "category", "country", "administrativeLevel1", "administrativeLevel2"]
|
|
73
63
|
: ["id", "name", "category", "country"];
|
|
74
64
|
|
|
@@ -124,7 +114,7 @@ export default function CombineLocationModal({
|
|
|
124
114
|
options={selectedLocations.map((location) => {
|
|
125
115
|
return {
|
|
126
116
|
label: location?.datastakeId || "-",
|
|
127
|
-
|
|
117
|
+
value: location?.datastakeId || "-",
|
|
128
118
|
};
|
|
129
119
|
})}
|
|
130
120
|
placeholder={t("ID")}
|
|
@@ -179,7 +169,7 @@ export default function CombineLocationModal({
|
|
|
179
169
|
></Select>
|
|
180
170
|
</Form.Item>
|
|
181
171
|
|
|
182
|
-
{entity
|
|
172
|
+
{entity.includes("locations") && (
|
|
183
173
|
<>
|
|
184
174
|
<Form.Item className="flex-1" name="administrativeLevel1">
|
|
185
175
|
<Select
|
|
@@ -36,7 +36,7 @@ export default function CombineSubjectsModal({
|
|
|
36
36
|
|
|
37
37
|
const onSubmit = () => {
|
|
38
38
|
MainForm.validateFields().then((data) => {
|
|
39
|
-
const ids = selectedSubjects.map((subject) => subject.
|
|
39
|
+
const ids = selectedSubjects.map((subject) => subject._id);
|
|
40
40
|
onSuccess({
|
|
41
41
|
ids,
|
|
42
42
|
data,
|
|
@@ -47,7 +47,7 @@ export default function CombineSubjectsModal({
|
|
|
47
47
|
return (
|
|
48
48
|
<Modal
|
|
49
49
|
open={isOpen}
|
|
50
|
-
title={t("merge")}
|
|
50
|
+
title={t("admin::merge")}
|
|
51
51
|
onClose={onClose}
|
|
52
52
|
onSuccess={onSubmit}
|
|
53
53
|
withModalFormWrapper={false}
|
|
@@ -59,7 +59,7 @@ export default function CombineSubjectsModal({
|
|
|
59
59
|
const values = MainForm.getFieldsValue();
|
|
60
60
|
|
|
61
61
|
const requiredFields =
|
|
62
|
-
entity
|
|
62
|
+
entity === "location"
|
|
63
63
|
? ["id", "name", "category", "country", "administrativeLevel1", "administrativeLevel2"]
|
|
64
64
|
: ["id", "name", "category", "country"];
|
|
65
65
|
|
|
@@ -75,7 +75,7 @@ export default function CombineSubjectsModal({
|
|
|
75
75
|
color: token.baseGray90,
|
|
76
76
|
}}
|
|
77
77
|
>
|
|
78
|
-
{t("current_subjects")}
|
|
78
|
+
{t("admin::current_subjects")}
|
|
79
79
|
</span>
|
|
80
80
|
<DAFTable
|
|
81
81
|
columns={columns}
|
|
@@ -93,7 +93,7 @@ export default function CombineSubjectsModal({
|
|
|
93
93
|
marginTop: 14,
|
|
94
94
|
}}
|
|
95
95
|
>
|
|
96
|
-
{t("merged_output")}
|
|
96
|
+
{t("admin::merged_output")}
|
|
97
97
|
</span>
|
|
98
98
|
|
|
99
99
|
<Form
|
|
@@ -135,7 +135,7 @@ export default function CombineSubjectsModal({
|
|
|
135
135
|
></Select>
|
|
136
136
|
</Form.Item>
|
|
137
137
|
|
|
138
|
-
{entity.includes("
|
|
138
|
+
{entity.includes("locations") && (
|
|
139
139
|
<>
|
|
140
140
|
<Form.Item className="flex-1" name="administrativeLevel1">
|
|
141
141
|
<Select
|
|
@@ -20,7 +20,7 @@ export default function AdminDashboardScreen({ config }) {
|
|
|
20
20
|
userGrowthDataLoading,
|
|
21
21
|
} = useWidgetFetch();
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
console.log({userGrowthData});
|
|
24
24
|
|
|
25
25
|
const actionsWidgetsConfig = useMemo(
|
|
26
26
|
() => getActionWidgetsConfig({ getRedirectLink }),
|
|
@@ -39,7 +39,7 @@ export default function AdminDashboardScreen({ config }) {
|
|
|
39
39
|
const safeUserActivity = Array.isArray(data?.data?.userActivity) ? data.data.userActivity : [];
|
|
40
40
|
const safeTopContributors = Array.isArray(data?.topContributors) ? data.topContributors : [];
|
|
41
41
|
const safeUserGrowth = Array.isArray(data?.userGrowthData) ? data.userGrowthData : [];
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
|
|
44
44
|
return (
|
|
45
45
|
<AdminDashboard
|
|
@@ -48,11 +48,11 @@ export default function AdminLocationScreen({ config }) {
|
|
|
48
48
|
async (mergeData) => {
|
|
49
49
|
try {
|
|
50
50
|
if (AdminService.mergeLocations) {
|
|
51
|
-
await AdminService.mergeLocations(
|
|
51
|
+
await AdminService.mergeLocations(mergeData);
|
|
52
52
|
message.success(t("Locations merged successfully"));
|
|
53
53
|
} else {
|
|
54
54
|
console.warn("AdminService.mergeLocations is not implemented");
|
|
55
|
-
message.
|
|
55
|
+
message.success(t("Locations merged successfully"));
|
|
56
56
|
}
|
|
57
57
|
} catch (err) {
|
|
58
58
|
handleError?.(err);
|
|
@@ -61,11 +61,12 @@ export default function AdminLocationScreen({ config }) {
|
|
|
61
61
|
[AdminService, t, handleError]
|
|
62
62
|
);
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
// Use custom getData if provided, otherwise use default AdminService.getLocations
|
|
65
|
+
const getLocations = useCallback((params) => {
|
|
65
66
|
if (getData) {
|
|
66
67
|
return getData(params);
|
|
67
68
|
}
|
|
68
|
-
return AdminService.
|
|
69
|
+
return AdminService.getLocations(params);
|
|
69
70
|
}, [getData, AdminService]);
|
|
70
71
|
|
|
71
72
|
return (
|
|
@@ -76,12 +77,12 @@ export default function AdminLocationScreen({ config }) {
|
|
|
76
77
|
location={location}
|
|
77
78
|
module={module}
|
|
78
79
|
headerTitle={headerTitle}
|
|
79
|
-
getData={
|
|
80
|
+
getData={getLocations}
|
|
80
81
|
isMobile={isMobile}
|
|
81
82
|
defaultPageSize={defaultPageSize}
|
|
82
83
|
view={view}
|
|
83
84
|
breadcrumbs={breadcrumbs}
|
|
84
|
-
|
|
85
|
+
mergeSubjectsFunction={handleMergeLocations}
|
|
85
86
|
refetchTrigger={refetchTrigger}
|
|
86
87
|
config={{
|
|
87
88
|
options: {
|
|
@@ -48,7 +48,7 @@ export default function AdminSubjectsScreen({ config }) {
|
|
|
48
48
|
async (mergeData) => {
|
|
49
49
|
try {
|
|
50
50
|
if (AdminService.mergeSubjects) {
|
|
51
|
-
await AdminService.mergeSubjects(
|
|
51
|
+
await AdminService.mergeSubjects(mergeData);
|
|
52
52
|
message.success(t("Subjects merged successfully"));
|
|
53
53
|
} else {
|
|
54
54
|
console.warn("AdminService.mergeSubjects is not implemented");
|
|
@@ -66,7 +66,7 @@ export default function AdminSubjectsScreen({ config }) {
|
|
|
66
66
|
if (getData) {
|
|
67
67
|
return getData(params);
|
|
68
68
|
}
|
|
69
|
-
return AdminService.getSubjects(
|
|
69
|
+
return AdminService.getSubjects(params);
|
|
70
70
|
}, [getData, AdminService]);
|
|
71
71
|
|
|
72
72
|
return (
|
|
@@ -10,4 +10,3 @@ 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
12
|
export { default as AdminLocationScreen } from "./Location.jsx";
|
|
13
|
-
export { default as AdminSubjectsViewScreen } from "./SubjectsView.jsx";
|