datastake-daf 0.6.841 → 0.6.843
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 +773 -768
- package/dist/hooks/index.js +4 -6
- package/dist/layouts/index.js +6 -0
- package/dist/pages/index.js +187 -133
- package/package.json +1 -1
- package/src/@daf/core/components/DynamicForm/hook.js +2 -2
- package/src/@daf/core/components/DynamicForm/index.jsx +1 -1
- package/src/@daf/core/components/Filters/selectFilters/index.jsx +7 -1
- package/src/@daf/core/components/Graphs/TradeRelationship/index.jsx +1 -27
- package/src/@daf/core/components/Graphs/components/BaseGraph.jsx +22 -18
- package/src/@daf/core/components/Select/MultiSelect/style.js +1 -1
- package/src/@daf/core/components/ViewForm/components/DataLink/flat.js +7 -3
- package/src/@daf/core/components/ViewForm/components/DataLink/index.js +6 -2
- package/src/@daf/core/components/ViewForm/components/input.js +7 -7
- package/src/@daf/hooks/useWidgetFetch.js +26 -35
- package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/IncidentsTime/index.js +1 -0
- package/src/@daf/pages/Dashboards/SupplyChain/components/ChartsContainer/components/Locations/index.js +20 -19
- package/src/@daf/pages/Dashboards/SupplyChain/components/ChartsContainer/index.js +5 -2
- package/src/@daf/pages/Events/Activities/columns.js +7 -3
- package/src/@daf/pages/Events/Incidents/columns.js +7 -3
- package/src/@daf/pages/Summary/Operator/components/KeyInformation/config.js +0 -1
- package/src/@daf/pages/Summary/Operator/components/TradeRelationships/helper.js +7 -5
- package/src/@daf/pages/Summary/Operator/components/TradeRelationships/hook.js +29 -14
- package/src/@daf/pages/Summary/Operator/components/TradeRelationships/index.js +69 -20
- package/src/@daf/pages/Summary/Operator/index.jsx +1 -0
- package/src/@daf/pages/View/index.jsx +1 -1
- package/src/helpers/Forms.js +7 -5
package/dist/pages/index.js
CHANGED
|
@@ -5840,7 +5840,7 @@ const transformPayload = payload => {
|
|
|
5840
5840
|
* @param {object} obj - Object to traverse
|
|
5841
5841
|
* @returns {any} - Resolved value or undefined
|
|
5842
5842
|
*/
|
|
5843
|
-
const resolveValuePath = (path, obj) => {
|
|
5843
|
+
const resolveValuePath = (path, obj, form) => {
|
|
5844
5844
|
if (!path || !obj) return undefined;
|
|
5845
5845
|
|
|
5846
5846
|
// Split by / and traverse the object
|
|
@@ -5859,7 +5859,8 @@ const resolveValuePath = (path, obj) => {
|
|
|
5859
5859
|
current = current[part];
|
|
5860
5860
|
}
|
|
5861
5861
|
}
|
|
5862
|
-
|
|
5862
|
+
const value = Object.keys(form || {})?.length > 0 ? findOptions(current, form?.options || []) : current;
|
|
5863
|
+
return value;
|
|
5863
5864
|
};
|
|
5864
5865
|
|
|
5865
5866
|
/**
|
|
@@ -5927,7 +5928,7 @@ const getCombinedPrefilledValues = form => {
|
|
|
5927
5928
|
* @param {object} parentValues - Parent form values
|
|
5928
5929
|
* @returns {string|null} - Resolved string with placeholders replaced by actual values, or null if not ready
|
|
5929
5930
|
*/
|
|
5930
|
-
const resolveCombinedPrefilledValue = (template, values = {}, parentValues = {}) => {
|
|
5931
|
+
const resolveCombinedPrefilledValue = (template, values = {}, parentValues = {}, form) => {
|
|
5931
5932
|
if (!template || typeof template !== 'string') return '';
|
|
5932
5933
|
|
|
5933
5934
|
// Regular expression to match placeholders like {path} or {path^subpath}
|
|
@@ -5940,7 +5941,7 @@ const resolveCombinedPrefilledValue = (template, values = {}, parentValues = {})
|
|
|
5940
5941
|
if (nonParentPaths.length > 0) {
|
|
5941
5942
|
// Check if at least one non-parent value has actual data
|
|
5942
5943
|
hasNonParentValue = nonParentPaths.some(path => {
|
|
5943
|
-
const value = resolveValuePath(path, values);
|
|
5944
|
+
const value = resolveValuePath(path, values, form?.inputs?.[path]);
|
|
5944
5945
|
return value !== undefined && value !== null && value !== '';
|
|
5945
5946
|
});
|
|
5946
5947
|
|
|
@@ -5960,7 +5961,7 @@ const resolveCombinedPrefilledValue = (template, values = {}, parentValues = {})
|
|
|
5960
5961
|
return formatValue(resolved);
|
|
5961
5962
|
} else {
|
|
5962
5963
|
// Regular path in current values
|
|
5963
|
-
const resolved = resolveValuePath(path, values);
|
|
5964
|
+
const resolved = resolveValuePath(path, values, form?.inputs?.[path]);
|
|
5964
5965
|
return formatValue(resolved);
|
|
5965
5966
|
}
|
|
5966
5967
|
});
|
|
@@ -6099,6 +6100,12 @@ const SelectFilters = ({
|
|
|
6099
6100
|
}) => {
|
|
6100
6101
|
const [filters, setFilters] = React.useState(selectedFilters || {});
|
|
6101
6102
|
const [initFilters, setInitFilters] = React.useState(selectedFilters || {});
|
|
6103
|
+
|
|
6104
|
+
// Sync internal state with selectedFilters prop when it changes
|
|
6105
|
+
React.useEffect(() => {
|
|
6106
|
+
setFilters(selectedFilters || {});
|
|
6107
|
+
setInitFilters(selectedFilters || {});
|
|
6108
|
+
}, [selectedFilters]);
|
|
6102
6109
|
const getClearLabel = () => {
|
|
6103
6110
|
switch (type) {
|
|
6104
6111
|
case 'small':
|
|
@@ -6656,7 +6663,7 @@ const MultiSelectStyled = styled__default["default"](antd.Select)`
|
|
|
6656
6663
|
&.ant-select-single {
|
|
6657
6664
|
.ant-select-selector {
|
|
6658
6665
|
padding-inline-end: 24px !important;
|
|
6659
|
-
padding:
|
|
6666
|
+
padding: 3px !important;
|
|
6660
6667
|
max-width: 56px !important;
|
|
6661
6668
|
width: 56px !important;
|
|
6662
6669
|
}
|
|
@@ -7493,7 +7500,6 @@ var DashboardService$1 = createLazyService(DashboardService);
|
|
|
7493
7500
|
// url: string
|
|
7494
7501
|
// basePath: string,
|
|
7495
7502
|
// }
|
|
7496
|
-
|
|
7497
7503
|
const useWidgetFetch = ({
|
|
7498
7504
|
config,
|
|
7499
7505
|
getData = DashboardService$1.getWidget,
|
|
@@ -7509,9 +7515,6 @@ const useWidgetFetch = ({
|
|
|
7509
7515
|
const [initFetchDone, setInitFetchDone] = React.useState(false);
|
|
7510
7516
|
const isMounted = React.useRef(true);
|
|
7511
7517
|
const fetchData = async () => {
|
|
7512
|
-
if (stop) {
|
|
7513
|
-
return;
|
|
7514
|
-
}
|
|
7515
7518
|
setLoading(true);
|
|
7516
7519
|
try {
|
|
7517
7520
|
const {
|
|
@@ -7540,8 +7543,10 @@ const useWidgetFetch = ({
|
|
|
7540
7543
|
};
|
|
7541
7544
|
}, []);
|
|
7542
7545
|
React.useEffect(() => {
|
|
7543
|
-
|
|
7544
|
-
|
|
7546
|
+
if (!stop) {
|
|
7547
|
+
fetchData();
|
|
7548
|
+
}
|
|
7549
|
+
}, [JSON.stringify(config), stop]);
|
|
7545
7550
|
return {
|
|
7546
7551
|
data,
|
|
7547
7552
|
loading,
|
|
@@ -12480,6 +12485,7 @@ const BaseGraph = /*#__PURE__*/React.forwardRef(function BaseGraph({
|
|
|
12480
12485
|
getViewport,
|
|
12481
12486
|
fitView
|
|
12482
12487
|
} = react.useReactFlow();
|
|
12488
|
+
const hasInitialFitRef = React.useRef(false);
|
|
12483
12489
|
const nodesToFit = React.useMemo(() => {
|
|
12484
12490
|
let result;
|
|
12485
12491
|
if (mandatoryNodesToFit) {
|
|
@@ -12490,27 +12496,29 @@ const BaseGraph = /*#__PURE__*/React.forwardRef(function BaseGraph({
|
|
|
12490
12496
|
return result;
|
|
12491
12497
|
}, [nodes.length, mandatoryNodesToFit?.length, mandatoryNodesToFit]);
|
|
12492
12498
|
|
|
12493
|
-
//
|
|
12499
|
+
// Only auto-fit on initial render or when node count changes, not on property changes
|
|
12494
12500
|
React.useEffect(() => {
|
|
12495
12501
|
if (nodesToFit.length === 0) return;
|
|
12496
12502
|
|
|
12497
|
-
//
|
|
12498
|
-
|
|
12499
|
-
|
|
12500
|
-
|
|
12501
|
-
|
|
12502
|
-
|
|
12503
|
-
|
|
12504
|
-
|
|
12505
|
-
|
|
12506
|
-
|
|
12507
|
-
|
|
12508
|
-
|
|
12503
|
+
// Only auto-fit on initial render or when node count changes
|
|
12504
|
+
if (!hasInitialFitRef.current) {
|
|
12505
|
+
hasInitialFitRef.current = true;
|
|
12506
|
+
const timer = setTimeout(() => {
|
|
12507
|
+
fitView({
|
|
12508
|
+
padding: 0.4,
|
|
12509
|
+
nodes: [...nodesToFit],
|
|
12510
|
+
maxZoom: 0.9
|
|
12511
|
+
});
|
|
12512
|
+
}, 100);
|
|
12513
|
+
return () => clearTimeout(timer);
|
|
12514
|
+
}
|
|
12515
|
+
}, [nodesToFit.length, withDuration]);
|
|
12509
12516
|
return /*#__PURE__*/jsxRuntime.jsx(ComponentWithFocus, {
|
|
12510
12517
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
12511
12518
|
style: {
|
|
12512
12519
|
height: "100%",
|
|
12513
|
-
width: "100%"
|
|
12520
|
+
width: "100%",
|
|
12521
|
+
position: "relative"
|
|
12514
12522
|
},
|
|
12515
12523
|
ref: ref,
|
|
12516
12524
|
children: [filtersConfig ? /*#__PURE__*/jsxRuntime.jsx(Filters, {
|
|
@@ -13677,7 +13685,7 @@ const getColors$1 = theme => {
|
|
|
13677
13685
|
|
|
13678
13686
|
function Locations({
|
|
13679
13687
|
selectedSources = {},
|
|
13680
|
-
data =
|
|
13688
|
+
data = {},
|
|
13681
13689
|
loading = false,
|
|
13682
13690
|
t = () => {},
|
|
13683
13691
|
options = {},
|
|
@@ -13688,23 +13696,23 @@ function Locations({
|
|
|
13688
13696
|
} = options;
|
|
13689
13697
|
const colors = getColors$1(theme);
|
|
13690
13698
|
const pieData = React.useMemo(() => {
|
|
13691
|
-
|
|
13692
|
-
const
|
|
13693
|
-
undefined: undefined$1,
|
|
13694
|
-
...rest
|
|
13695
|
-
} = data;
|
|
13696
|
-
const total = Object.values(rest).reduce((all, val) => all + (val || 0), 0);
|
|
13699
|
+
const rest = data || {};
|
|
13700
|
+
const total = Object.values(rest).reduce((sum, val) => sum + (val || 0), 0);
|
|
13697
13701
|
return Object.keys(rest).map((key, index) => {
|
|
13698
13702
|
const color = colors[index % colors.length];
|
|
13703
|
+
const value = rest[key] || 0;
|
|
13699
13704
|
return {
|
|
13700
|
-
value
|
|
13701
|
-
percent:
|
|
13702
|
-
color
|
|
13703
|
-
label: findOptions(key, countries),
|
|
13704
|
-
key
|
|
13705
|
+
value,
|
|
13706
|
+
percent: total ? value / total : 0,
|
|
13707
|
+
color,
|
|
13708
|
+
label: findOptions(key, countries) || key,
|
|
13709
|
+
key
|
|
13705
13710
|
};
|
|
13706
13711
|
});
|
|
13707
|
-
}, [data, countries]);
|
|
13712
|
+
}, [data, countries, colors]);
|
|
13713
|
+
console.log({
|
|
13714
|
+
data
|
|
13715
|
+
});
|
|
13708
13716
|
const isEmpty = React.useMemo(() => Object.keys(data).filter(k => !!data[k]).length === 0, [data]);
|
|
13709
13717
|
const getTooltipChildren = React.useCallback(item => {
|
|
13710
13718
|
if (isEmpty) {
|
|
@@ -13904,7 +13912,7 @@ function ChartsContainer({
|
|
|
13904
13912
|
range: selectedRange
|
|
13905
13913
|
},
|
|
13906
13914
|
stop: selectedSources?.loading,
|
|
13907
|
-
defaultData:
|
|
13915
|
+
defaultData: {}
|
|
13908
13916
|
}), [isTradeActions, selectedSources, selectedRange]);
|
|
13909
13917
|
const {
|
|
13910
13918
|
loading,
|
|
@@ -13913,6 +13921,7 @@ function ChartsContainer({
|
|
|
13913
13921
|
config: defaultConfig,
|
|
13914
13922
|
onFetch: () => setPreviousRange(selectedRange)
|
|
13915
13923
|
});
|
|
13924
|
+
console.log('ChartsContainer data:', data);
|
|
13916
13925
|
return /*#__PURE__*/jsxRuntime.jsx(Widget, {
|
|
13917
13926
|
title: isTradeActions ? t("Trade Actors") : t("Mining Sites"),
|
|
13918
13927
|
className: "with-border-header",
|
|
@@ -13929,7 +13938,7 @@ function ChartsContainer({
|
|
|
13929
13938
|
selectedRange: selectedRange,
|
|
13930
13939
|
options: options
|
|
13931
13940
|
}), /*#__PURE__*/jsxRuntime.jsx(Locations, {
|
|
13932
|
-
data: data?.
|
|
13941
|
+
data: data?.location,
|
|
13933
13942
|
t: t,
|
|
13934
13943
|
theme: theme,
|
|
13935
13944
|
selectedSources: selectedSources,
|
|
@@ -23203,11 +23212,15 @@ function DataLink$1({
|
|
|
23203
23212
|
getToken
|
|
23204
23213
|
});
|
|
23205
23214
|
const data = React.useMemo(() => {
|
|
23215
|
+
const filteredPrefilledValues = Object.entries(form?.meta?.prefilledValues || {}).filter(([_, value]) => !(value && typeof value === 'object' && 'combine' in value)).reduce((acc, [key, value]) => ({
|
|
23216
|
+
...acc,
|
|
23217
|
+
[key]: value
|
|
23218
|
+
}), {});
|
|
23206
23219
|
const _formData = isSingle ? formData && !Array.isArray(formData) ? [{
|
|
23207
|
-
...
|
|
23220
|
+
...filteredPrefilledValues,
|
|
23208
23221
|
...formData
|
|
23209
23222
|
}] : [] : (Array.isArray(formData) ? formData : []).map(f => ({
|
|
23210
|
-
...
|
|
23223
|
+
...filteredPrefilledValues,
|
|
23211
23224
|
...f
|
|
23212
23225
|
}));
|
|
23213
23226
|
return (_formData || []).map((f, i) => {
|
|
@@ -25601,11 +25614,15 @@ function DataLinkFlat$1({
|
|
|
25601
25614
|
}
|
|
25602
25615
|
}, [entity, values.linking]);
|
|
25603
25616
|
const dataLinkFormData = React.useMemo(() => {
|
|
25617
|
+
const filteredPrefilledValues = Object.entries(form?.meta?.prefilledValues || {}).filter(([_, value]) => !(value && typeof value === 'object' && 'combine' in value)).reduce((acc, [key, value]) => ({
|
|
25618
|
+
...acc,
|
|
25619
|
+
[key]: value
|
|
25620
|
+
}), {});
|
|
25604
25621
|
const _formData = isSingle ? formData && !Array.isArray(formData) ? [{
|
|
25605
|
-
...
|
|
25622
|
+
...filteredPrefilledValues,
|
|
25606
25623
|
...formData
|
|
25607
25624
|
}] : [] : (Array.isArray(formData) ? formData : []).map(f => ({
|
|
25608
|
-
...
|
|
25625
|
+
...filteredPrefilledValues,
|
|
25609
25626
|
...f
|
|
25610
25627
|
}));
|
|
25611
25628
|
return (_formData || []).map((f, i) => {
|
|
@@ -26501,10 +26518,10 @@ const BasicInput = ({
|
|
|
26501
26518
|
case 'text':
|
|
26502
26519
|
case 'phoneNumber':
|
|
26503
26520
|
case 'textarea':
|
|
26504
|
-
return item ? propHasValue$1(item[inputName]) ? item[inputName] : placeholder(item, inputName, withPlaceholder) : propHasValue$1(data[inputName]) ? data[inputName] : placeholder(data, inputName, withPlaceholder);
|
|
26521
|
+
return item ? propHasValue$1(item[inputName]) && item[inputName] !== '' ? item[inputName] : placeholder(item, inputName, withPlaceholder) : propHasValue$1(data[inputName]) && data[inputName] !== '' ? data[inputName] : placeholder(data, inputName, withPlaceholder);
|
|
26505
26522
|
case 'website':
|
|
26506
26523
|
case 'link':
|
|
26507
|
-
const v = item ? propHasValue$1(item[inputName]) ? item[inputName] : placeholder(item, inputName, withPlaceholder) : propHasValue$1(data[inputName]) ? data[inputName] : placeholder(data, inputName, withPlaceholder);
|
|
26524
|
+
const v = item ? propHasValue$1(item[inputName]) && item[inputName] !== '' ? item[inputName] : placeholder(item, inputName, withPlaceholder) : propHasValue$1(data[inputName]) && data[inputName] !== '' ? data[inputName] : placeholder(data, inputName, withPlaceholder);
|
|
26508
26525
|
if (isModal) {
|
|
26509
26526
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
26510
26527
|
className: "flex flex-column ant-upload-list",
|
|
@@ -27132,7 +27149,7 @@ const Input = ({
|
|
|
27132
27149
|
ajaxOptions: ajaxOptions,
|
|
27133
27150
|
evaluationConfig: evaluationConfig
|
|
27134
27151
|
}, key);
|
|
27135
|
-
}), isRepeatable && Array.isArray(modalData) && !modalData.length ? /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
27152
|
+
}), isRepeatable && Array.isArray(modalData) && !modalData.length || modalData === "" ? /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
27136
27153
|
className: "text-muted",
|
|
27137
27154
|
children: t('Not answered')
|
|
27138
27155
|
}) : null]
|
|
@@ -27167,7 +27184,7 @@ const Input = ({
|
|
|
27167
27184
|
linkingData: linkingData,
|
|
27168
27185
|
evaluationConfig: evaluationConfig
|
|
27169
27186
|
}, key);
|
|
27170
|
-
}), !modalData || Array.isArray(modalData) && !modalData.length ? /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
27187
|
+
}), !modalData || Array.isArray(modalData) && !modalData.length || modalData === "" ? /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
27171
27188
|
className: "text-muted",
|
|
27172
27189
|
children: t('Not answered')
|
|
27173
27190
|
}) : (Array.isArray(modalData) ? modalData : [modalData]).map((item, itemId) => /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -27253,7 +27270,7 @@ const Input = ({
|
|
|
27253
27270
|
linkingData: linkingData,
|
|
27254
27271
|
evaluationConfig: evaluationConfig
|
|
27255
27272
|
}, key);
|
|
27256
|
-
}), !formData || Array.isArray(formData) && !formData.length ? /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
27273
|
+
}), !formData || Array.isArray(formData) && !formData.length || formData === "" ? /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
27257
27274
|
className: "text-muted",
|
|
27258
27275
|
children: t('Not answered')
|
|
27259
27276
|
}) : (Array.isArray(formData) ? formData : [formData])?.map((item, itemId) => /*#__PURE__*/jsxRuntime.jsxs(React__default["default"].Fragment, {
|
|
@@ -39740,7 +39757,7 @@ const getGrouContent = (form, values, i, formId, excludedKeys, getData, setValue
|
|
|
39740
39757
|
});
|
|
39741
39758
|
};
|
|
39742
39759
|
|
|
39743
|
-
const useCombinedPrefilledValues = (combinedPrefilledValues, values, parentValues, setValues, MainForm) => {
|
|
39760
|
+
const useCombinedPrefilledValues = (combinedPrefilledValues, values, parentValues, setValues, MainForm, form) => {
|
|
39744
39761
|
const combinedValuesRef = React.useRef({});
|
|
39745
39762
|
React.useEffect(() => {
|
|
39746
39763
|
if (!combinedPrefilledValues || Object.keys(combinedPrefilledValues).length === 0) {
|
|
@@ -39750,7 +39767,7 @@ const useCombinedPrefilledValues = (combinedPrefilledValues, values, parentValue
|
|
|
39750
39767
|
let hasChanges = false;
|
|
39751
39768
|
Object.keys(combinedPrefilledValues).forEach(fieldKey => {
|
|
39752
39769
|
const template = combinedPrefilledValues[fieldKey];
|
|
39753
|
-
const resolvedValue = resolveCombinedPrefilledValue(template, values, parentValues);
|
|
39770
|
+
const resolvedValue = resolveCombinedPrefilledValue(template, values, parentValues, form);
|
|
39754
39771
|
if (resolvedValue === null) {
|
|
39755
39772
|
return;
|
|
39756
39773
|
}
|
|
@@ -39940,7 +39957,7 @@ function DynamicForm({
|
|
|
39940
39957
|
}, [data, isCreate]);
|
|
39941
39958
|
|
|
39942
39959
|
// Handle combined prefilled values (auto-fill based on templates)
|
|
39943
|
-
useCombinedPrefilledValues(combinedPrefilledValues, values, parentValues, setValues, MainForm);
|
|
39960
|
+
useCombinedPrefilledValues(combinedPrefilledValues, values, parentValues, setValues, MainForm, form);
|
|
39944
39961
|
|
|
39945
39962
|
// Initialize default values for hidden and disabled fields
|
|
39946
39963
|
React.useEffect(() => {
|
|
@@ -43309,7 +43326,7 @@ const getColumns$a = ({
|
|
|
43309
43326
|
className: "daf-default-cell"
|
|
43310
43327
|
});
|
|
43311
43328
|
}
|
|
43312
|
-
const region = getLinkValue(all?.location?.administrativeLevel1, all?.location?.linking?.SCL);
|
|
43329
|
+
const region = all?.location ? getLinkValue(all?.location?.administrativeLevel1, all?.location?.linking?.SCL) : getLinkValue(all?.administrativeLevel1Name, all?.linking?.SCL) || all?.administrativeLevel1Name;
|
|
43313
43330
|
return region ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
|
|
43314
43331
|
title: region,
|
|
43315
43332
|
children: region
|
|
@@ -43317,7 +43334,7 @@ const getColumns$a = ({
|
|
|
43317
43334
|
}
|
|
43318
43335
|
}, {
|
|
43319
43336
|
dataIndex: 'territory',
|
|
43320
|
-
title: findOptions(user?.company?.country, options?.administrativeLevel2)?.length > 2 ? findOptions(user?.company?.country, options?.
|
|
43337
|
+
title: findOptions(user?.company?.country, options?.administrativeLevel2)?.length > 2 ? findOptions(user?.company?.country, options?.administrativeLevel2Name) : t("Territory"),
|
|
43321
43338
|
ellipsis: true,
|
|
43322
43339
|
show: true,
|
|
43323
43340
|
render: (v, all) => {
|
|
@@ -43326,7 +43343,7 @@ const getColumns$a = ({
|
|
|
43326
43343
|
className: "daf-default-cell"
|
|
43327
43344
|
});
|
|
43328
43345
|
}
|
|
43329
|
-
const district = getLinkValue(all?.location?.administrativeLevel2, all?.location?.linking?.SCL);
|
|
43346
|
+
const district = all?.location ? getLinkValue(all?.location?.administrativeLevel2, all?.location?.linking?.SCL) : getLinkValue(all?.administrativeLevel2, all?.linking?.SCL) || all?.administrativeLevel2;
|
|
43330
43347
|
return district ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
|
|
43331
43348
|
title: district,
|
|
43332
43349
|
children: district
|
|
@@ -43739,7 +43756,7 @@ const getColumns$9 = ({
|
|
|
43739
43756
|
className: "daf-default-cell"
|
|
43740
43757
|
});
|
|
43741
43758
|
}
|
|
43742
|
-
const region = getLinkValue(all?.location?.administrativeLevel1, all?.location?.linking?.SCL);
|
|
43759
|
+
const region = all?.location ? getLinkValue(all?.location?.administrativeLevel1, all?.location?.linking?.SCL) : getLinkValue(all?.administrativeLevel1Name, all?.linking?.SCL) || all?.administrativeLevel1Name;
|
|
43743
43760
|
return region ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
|
|
43744
43761
|
title: region,
|
|
43745
43762
|
children: region
|
|
@@ -43756,7 +43773,7 @@ const getColumns$9 = ({
|
|
|
43756
43773
|
className: "daf-default-cell"
|
|
43757
43774
|
});
|
|
43758
43775
|
}
|
|
43759
|
-
const district = getLinkValue(all?.location?.administrativeLevel2, all?.location?.linking?.SCL);
|
|
43776
|
+
const district = all?.location ? getLinkValue(all?.location?.administrativeLevel2, all?.location?.linking?.SCL) : getLinkValue(all?.administrativeLevel2, all?.linking?.SCL) || all?.administrativeLevel2;
|
|
43760
43777
|
return district ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
|
|
43761
43778
|
title: district,
|
|
43762
43779
|
children: district
|
|
@@ -46035,11 +46052,6 @@ const getKeyIndicatorConfig = ({
|
|
|
46035
46052
|
label: t("Legal Form"),
|
|
46036
46053
|
render: () => {
|
|
46037
46054
|
const subCategory = findOptions(data?.subCategory, options?.subCategoriesOptions || options?.subCategory);
|
|
46038
|
-
console.log({
|
|
46039
|
-
subCategory,
|
|
46040
|
-
initialSub: data?.subCategory,
|
|
46041
|
-
options: options?.subCategoriesOptions || options?.subCategory
|
|
46042
|
-
});
|
|
46043
46055
|
if (subCategory?.length > 22) {
|
|
46044
46056
|
const _subCategory = truncateString(subCategory, 22);
|
|
46045
46057
|
return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
|
|
@@ -46550,6 +46562,9 @@ const getFilterConfig = ({
|
|
|
46550
46562
|
t = () => {},
|
|
46551
46563
|
APP
|
|
46552
46564
|
}) => {
|
|
46565
|
+
console.log({
|
|
46566
|
+
operatorData
|
|
46567
|
+
});
|
|
46553
46568
|
const productSet = new Set();
|
|
46554
46569
|
const allTradeMineralOptions = [...(operatorData?.suppliers || []), ...(operatorData?.clients || []), ...(operatorData?.locationSuppliers || [])].flatMap(trade => (trade?.products || []).filter(product => !!product?.typeOfProduct && !productSet.has(product.typeOfProduct)).map(product => {
|
|
46555
46570
|
productSet.add(product.typeOfProduct);
|
|
@@ -46562,17 +46577,22 @@ const getFilterConfig = ({
|
|
|
46562
46577
|
const combinedMineralOptions = [...allTradeMineralOptions].filter((option, index, self) => {
|
|
46563
46578
|
return option && index === self.findIndex(o => o.value === option.value);
|
|
46564
46579
|
});
|
|
46565
|
-
|
|
46566
|
-
value: filters
|
|
46580
|
+
filters?.products ? {
|
|
46581
|
+
value: filters?.products
|
|
46567
46582
|
} : {};
|
|
46568
|
-
return
|
|
46569
|
-
|
|
46570
|
-
|
|
46571
|
-
|
|
46572
|
-
|
|
46573
|
-
|
|
46574
|
-
|
|
46575
|
-
|
|
46583
|
+
return {
|
|
46584
|
+
products: {
|
|
46585
|
+
label: t("Products"),
|
|
46586
|
+
placeholder: t("Select"),
|
|
46587
|
+
key: "products",
|
|
46588
|
+
type: "select",
|
|
46589
|
+
// ...value,
|
|
46590
|
+
style: {
|
|
46591
|
+
flex: 1
|
|
46592
|
+
},
|
|
46593
|
+
options: combinedMineralOptions
|
|
46594
|
+
}
|
|
46595
|
+
};
|
|
46576
46596
|
};
|
|
46577
46597
|
const getLeft = (data = {}, mapChildren = () => {}, supplierLocations = []) => {
|
|
46578
46598
|
if (data?.suppliers?.length > 0) {
|
|
@@ -46617,6 +46637,8 @@ const mapItem = (data, options, goTo, getRedirectLink, operatorData = {}, APP) =
|
|
|
46617
46637
|
const useTradeRelationship = ({
|
|
46618
46638
|
id,
|
|
46619
46639
|
selectedPartners,
|
|
46640
|
+
isProductsFilterReady,
|
|
46641
|
+
hasProducts,
|
|
46620
46642
|
options,
|
|
46621
46643
|
goTo,
|
|
46622
46644
|
getRedirectLink,
|
|
@@ -46627,18 +46649,31 @@ const useTradeRelationship = ({
|
|
|
46627
46649
|
const [graphData, setGraphData] = React.useState({});
|
|
46628
46650
|
const [loading, setLoading] = React.useState(false);
|
|
46629
46651
|
const [fetchedProducts, setFetchedProducts] = React.useState(false);
|
|
46652
|
+
React.useRef(false);
|
|
46653
|
+
const product = React.useMemo(() => {
|
|
46654
|
+
return filters?.products;
|
|
46655
|
+
}, [filters?.products]);
|
|
46656
|
+
console.log({
|
|
46657
|
+
hasProducts,
|
|
46658
|
+
product,
|
|
46659
|
+
isProductsFilterReady,
|
|
46660
|
+
stop: !selectedPartners?.partners?.length || selectedPartners?.loading || !isProductsFilterReady || isProductsFilterReady && hasProducts && !product
|
|
46661
|
+
}, !selectedPartners?.partners?.length, selectedPartners?.loading, !isProductsFilterReady, isProductsFilterReady && hasProducts && !product);
|
|
46630
46662
|
const config = React.useMemo(() => ({
|
|
46631
46663
|
basepath: "analytics",
|
|
46632
46664
|
url: `/widgets/trade-relationship-map`,
|
|
46633
46665
|
filters: {
|
|
46634
46666
|
datastakeId: id,
|
|
46635
|
-
product
|
|
46667
|
+
...(product && {
|
|
46668
|
+
product: product
|
|
46669
|
+
}),
|
|
46636
46670
|
sources: selectedPartners?.partners || []
|
|
46637
46671
|
},
|
|
46638
|
-
stop: !selectedPartners?.partners?.length || selectedPartners?.loading
|
|
46639
|
-
}), [id,
|
|
46672
|
+
stop: !selectedPartners?.partners?.length || selectedPartners?.loading || !isProductsFilterReady || isProductsFilterReady && hasProducts && !product
|
|
46673
|
+
}), [id, product, selectedPartners?.partners, selectedPartners?.loading, isProductsFilterReady, hasProducts]);
|
|
46640
46674
|
const {
|
|
46641
|
-
data
|
|
46675
|
+
data,
|
|
46676
|
+
loading: dataLoading
|
|
46642
46677
|
} = useWidgetFetch({
|
|
46643
46678
|
config: config
|
|
46644
46679
|
});
|
|
@@ -46646,7 +46681,7 @@ const useTradeRelationship = ({
|
|
|
46646
46681
|
return mapItem(data, options, goTo, getRedirectLink, operatorData, APP);
|
|
46647
46682
|
};
|
|
46648
46683
|
React.useEffect(() => {
|
|
46649
|
-
if (id && selectedPartners?.partners?.length > 0
|
|
46684
|
+
if (id && selectedPartners?.partners?.length > 0) {
|
|
46650
46685
|
const _fetch = async () => {
|
|
46651
46686
|
setLoading(true);
|
|
46652
46687
|
try {
|
|
@@ -46733,7 +46768,8 @@ const useTradeRelationship = ({
|
|
|
46733
46768
|
setFetchedProducts,
|
|
46734
46769
|
setGraphData,
|
|
46735
46770
|
setLoading,
|
|
46736
|
-
data
|
|
46771
|
+
data,
|
|
46772
|
+
dataLoading
|
|
46737
46773
|
};
|
|
46738
46774
|
};
|
|
46739
46775
|
|
|
@@ -46748,8 +46784,7 @@ function TradeRelationship({
|
|
|
46748
46784
|
filtersConfig,
|
|
46749
46785
|
onFilterChange = () => {},
|
|
46750
46786
|
renderTooltipItems = () => [],
|
|
46751
|
-
getTotal = () => 0
|
|
46752
|
-
onRenderComplete = () => {}
|
|
46787
|
+
getTotal = () => 0
|
|
46753
46788
|
}) {
|
|
46754
46789
|
const reactFlowWrapper = React.useRef(null);
|
|
46755
46790
|
const [nodes, setNodes] = react.useNodesState([]);
|
|
@@ -46762,27 +46797,6 @@ function TradeRelationship({
|
|
|
46762
46797
|
const [activeNode, setActiveNode] = React.useState(null);
|
|
46763
46798
|
// const [initCenter, setInitCenter] = useState(true);
|
|
46764
46799
|
const [associatedNodes, setAssociatedNodes] = React.useState(null);
|
|
46765
|
-
const isFullyRenderedRef = React.useRef(false);
|
|
46766
|
-
const [isFullyRendered, setIsFullyRendered] = React.useState(false);
|
|
46767
|
-
React.useEffect(() => {
|
|
46768
|
-
isFullyRenderedRef.current = false;
|
|
46769
|
-
setIsFullyRendered(false);
|
|
46770
|
-
setActiveNode(null);
|
|
46771
|
-
}, [data]);
|
|
46772
|
-
React.useEffect(() => {
|
|
46773
|
-
if (nodes.length > 0 && edges.length > 0 && !isFullyRenderedRef.current) {
|
|
46774
|
-
const timeoutId = setTimeout(() => {
|
|
46775
|
-
isFullyRenderedRef.current = true;
|
|
46776
|
-
setIsFullyRendered(true);
|
|
46777
|
-
onRenderComplete(true);
|
|
46778
|
-
}, 200);
|
|
46779
|
-
return () => clearTimeout(timeoutId);
|
|
46780
|
-
}
|
|
46781
|
-
if (nodes.length === 0 || edges.length === 0) {
|
|
46782
|
-
setIsFullyRendered(true);
|
|
46783
|
-
onRenderComplete(true);
|
|
46784
|
-
}
|
|
46785
|
-
}, [nodes.length, edges.length, associatedNodes]);
|
|
46786
46800
|
React.useEffect(() => {
|
|
46787
46801
|
setActiveNode(null);
|
|
46788
46802
|
}, [data]);
|
|
@@ -46968,7 +46982,7 @@ function TradeRelationship({
|
|
|
46968
46982
|
|
|
46969
46983
|
// Cleanup to prevent memory leaks if component unmounts quickly
|
|
46970
46984
|
return () => clearTimeout(timeoutId);
|
|
46971
|
-
}, [data
|
|
46985
|
+
}, [data]);
|
|
46972
46986
|
React.useEffect(() => {
|
|
46973
46987
|
if (activeNode) {
|
|
46974
46988
|
let _associatedNodesRight = [activeNode];
|
|
@@ -47046,30 +47060,41 @@ const TradeRelationships = ({
|
|
|
47046
47060
|
id,
|
|
47047
47061
|
options = {},
|
|
47048
47062
|
getRedirectLink = () => {},
|
|
47049
|
-
APP
|
|
47063
|
+
APP,
|
|
47064
|
+
user = {}
|
|
47050
47065
|
}) => {
|
|
47051
47066
|
const [filters, setFilters] = React.useState({});
|
|
47052
47067
|
const [isFullyRendered, setIsFullyRendered] = React.useState(true);
|
|
47068
|
+
const [isProductsFilterReady, setIsProductsFilterReady] = React.useState(false);
|
|
47069
|
+
const [hasProducts, setHasProducts] = React.useState(true);
|
|
47070
|
+
const [delayedLoading, setDelayedLoading] = React.useState(false);
|
|
47071
|
+
const [delayedDataLoading, setDelayedDataLoading] = React.useState(false);
|
|
47053
47072
|
const onFilterChange = filters => {
|
|
47054
|
-
setFilters(
|
|
47055
|
-
...p,
|
|
47056
|
-
...filters
|
|
47057
|
-
}));
|
|
47073
|
+
setFilters(filters);
|
|
47058
47074
|
};
|
|
47059
47075
|
const filterConfig = React.useMemo(() => {
|
|
47060
|
-
|
|
47076
|
+
const filterConfig = Object.keys(operatorData).length > 0 ? getFilterConfig({
|
|
47061
47077
|
operatorData,
|
|
47062
47078
|
options,
|
|
47063
47079
|
filters,
|
|
47064
47080
|
t,
|
|
47065
47081
|
APP
|
|
47066
|
-
});
|
|
47082
|
+
}) : {};
|
|
47083
|
+
return filterConfig;
|
|
47067
47084
|
}, [filters.products, t, options?.mineralOptions, operatorData, options?.minerals, APP]);
|
|
47085
|
+
React.useEffect(() => {
|
|
47086
|
+
if (filterConfig?.products?.options?.length >= 0 && !isProductsFilterReady) {
|
|
47087
|
+
console.log('setting has products', filterConfig?.products?.options?.length);
|
|
47088
|
+
setHasProducts(filterConfig?.products?.options?.length > 0);
|
|
47089
|
+
setIsProductsFilterReady(true);
|
|
47090
|
+
}
|
|
47091
|
+
}, [filterConfig, isProductsFilterReady]);
|
|
47068
47092
|
const {
|
|
47069
47093
|
graphData,
|
|
47070
47094
|
loading,
|
|
47071
47095
|
fetchedProducts,
|
|
47072
|
-
setFetchedProducts
|
|
47096
|
+
setFetchedProducts,
|
|
47097
|
+
dataLoading
|
|
47073
47098
|
} = useTradeRelationship({
|
|
47074
47099
|
id,
|
|
47075
47100
|
selectedPartners,
|
|
@@ -47078,30 +47103,57 @@ const TradeRelationships = ({
|
|
|
47078
47103
|
getRedirectLink,
|
|
47079
47104
|
filters,
|
|
47080
47105
|
operatorData,
|
|
47081
|
-
APP
|
|
47082
|
-
|
|
47083
|
-
|
|
47084
|
-
graphData
|
|
47106
|
+
APP,
|
|
47107
|
+
isProductsFilterReady,
|
|
47108
|
+
hasProducts
|
|
47085
47109
|
});
|
|
47110
|
+
const defaultProduct = React.useMemo(() => {
|
|
47111
|
+
if (filterConfig?.products?.options?.length) {
|
|
47112
|
+
return filterConfig?.products?.options?.[0]?.value || null;
|
|
47113
|
+
}
|
|
47114
|
+
}, [filterConfig]);
|
|
47086
47115
|
React.useEffect(() => {
|
|
47087
|
-
|
|
47088
|
-
|
|
47089
|
-
|
|
47090
|
-
const data = {
|
|
47091
|
-
...prev,
|
|
47092
|
-
products: defaultProduct
|
|
47093
|
-
};
|
|
47094
|
-
return data;
|
|
47116
|
+
if (defaultProduct) {
|
|
47117
|
+
setFilters({
|
|
47118
|
+
products: defaultProduct
|
|
47095
47119
|
});
|
|
47096
47120
|
}
|
|
47097
|
-
|
|
47098
|
-
|
|
47121
|
+
}, [defaultProduct]);
|
|
47122
|
+
const _filtersConfig = React.useMemo(() => ({
|
|
47123
|
+
filtersConfig: {
|
|
47124
|
+
...filterConfig
|
|
47125
|
+
},
|
|
47126
|
+
options: Object.fromEntries(Object.keys(filterConfig).map(key => [key, filterConfig[key].options])),
|
|
47127
|
+
language: user?.language,
|
|
47128
|
+
selectedFilters: filters,
|
|
47129
|
+
onApply: onFilterChange,
|
|
47130
|
+
t: t
|
|
47131
|
+
}), [filterConfig, user?.language, filters, t]);
|
|
47132
|
+
React.useEffect(() => {
|
|
47133
|
+
if (loading) {
|
|
47134
|
+
setDelayedLoading(true);
|
|
47135
|
+
} else {
|
|
47136
|
+
const timer = setTimeout(() => {
|
|
47137
|
+
setDelayedLoading(false);
|
|
47138
|
+
}, 500);
|
|
47139
|
+
return () => clearTimeout(timer);
|
|
47099
47140
|
}
|
|
47100
|
-
}, [
|
|
47141
|
+
}, [loading]);
|
|
47142
|
+
React.useEffect(() => {
|
|
47143
|
+
if (dataLoading) {
|
|
47144
|
+
setDelayedDataLoading(true);
|
|
47145
|
+
} else {
|
|
47146
|
+
const timer = setTimeout(() => {
|
|
47147
|
+
setDelayedDataLoading(false);
|
|
47148
|
+
}, 500);
|
|
47149
|
+
return () => clearTimeout(timer);
|
|
47150
|
+
}
|
|
47151
|
+
}, [dataLoading]);
|
|
47101
47152
|
return /*#__PURE__*/jsxRuntime.jsx(Widget, {
|
|
47102
47153
|
title: t("Trade Relationships"),
|
|
47103
47154
|
className: "flex flex-1 with-border-header no-p-body",
|
|
47104
|
-
loading:
|
|
47155
|
+
loading: delayedLoading || delayedDataLoading,
|
|
47156
|
+
filtersConfig: _filtersConfig,
|
|
47105
47157
|
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
47106
47158
|
className: "flex flex-1 flex-column justify-content-center",
|
|
47107
47159
|
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -47126,12 +47178,10 @@ const TradeRelationships = ({
|
|
|
47126
47178
|
maxZoom: 1.2,
|
|
47127
47179
|
minZoom: 0.4,
|
|
47128
47180
|
tooltipTitle: "Trade",
|
|
47129
|
-
filtersConfig: filterConfig,
|
|
47130
|
-
onFilterChange: onFilterChange,
|
|
47131
47181
|
onRenderComplete: data => {
|
|
47132
|
-
console.log("onRenderComplete");
|
|
47133
47182
|
setIsFullyRendered(!data);
|
|
47134
|
-
}
|
|
47183
|
+
},
|
|
47184
|
+
filters: filters
|
|
47135
47185
|
})
|
|
47136
47186
|
})
|
|
47137
47187
|
})
|
|
@@ -47848,7 +47898,8 @@ const OperatorSummary = ({
|
|
|
47848
47898
|
goTo: goTo,
|
|
47849
47899
|
getRedirectLink: getRedirectLink,
|
|
47850
47900
|
operatorData: singleItemData,
|
|
47851
|
-
APP: APP
|
|
47901
|
+
APP: APP,
|
|
47902
|
+
user: user
|
|
47852
47903
|
})
|
|
47853
47904
|
}), /*#__PURE__*/jsxRuntime.jsx("section", {
|
|
47854
47905
|
children: /*#__PURE__*/jsxRuntime.jsx(Governance, {
|
|
@@ -62962,7 +63013,7 @@ const View = ({
|
|
|
62962
63013
|
children: /*#__PURE__*/jsxRuntime.jsx(Multiselect, {
|
|
62963
63014
|
options: [...sourceOptions],
|
|
62964
63015
|
isAvatarGroup: true,
|
|
62965
|
-
selectionType: "
|
|
63016
|
+
selectionType: "radio",
|
|
62966
63017
|
canUnselectLast: false,
|
|
62967
63018
|
isSingle: true,
|
|
62968
63019
|
onChange: selected => {
|
|
@@ -64225,6 +64276,9 @@ function IncidentsTimeline({
|
|
|
64225
64276
|
if (selectedRange === "12") return baseMonths.map(m => m.label);
|
|
64226
64277
|
return baseWeeks.map(w => w.label);
|
|
64227
64278
|
}, [selectedRange, baseMonths, baseWeeks]);
|
|
64279
|
+
console.log({
|
|
64280
|
+
filtersConfig
|
|
64281
|
+
});
|
|
64228
64282
|
const getTooltipContent = React.useCallback(({
|
|
64229
64283
|
item
|
|
64230
64284
|
}) => {
|