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.
Files changed (32) hide show
  1. package/build/favicon.ico +0 -0
  2. package/build/logo192.png +0 -0
  3. package/build/logo512.png +0 -0
  4. package/build/manifest.json +25 -0
  5. package/build/robots.txt +3 -0
  6. package/dist/components/index.js +773 -768
  7. package/dist/hooks/index.js +4 -6
  8. package/dist/layouts/index.js +6 -0
  9. package/dist/pages/index.js +187 -133
  10. package/package.json +1 -1
  11. package/src/@daf/core/components/DynamicForm/hook.js +2 -2
  12. package/src/@daf/core/components/DynamicForm/index.jsx +1 -1
  13. package/src/@daf/core/components/Filters/selectFilters/index.jsx +7 -1
  14. package/src/@daf/core/components/Graphs/TradeRelationship/index.jsx +1 -27
  15. package/src/@daf/core/components/Graphs/components/BaseGraph.jsx +22 -18
  16. package/src/@daf/core/components/Select/MultiSelect/style.js +1 -1
  17. package/src/@daf/core/components/ViewForm/components/DataLink/flat.js +7 -3
  18. package/src/@daf/core/components/ViewForm/components/DataLink/index.js +6 -2
  19. package/src/@daf/core/components/ViewForm/components/input.js +7 -7
  20. package/src/@daf/hooks/useWidgetFetch.js +26 -35
  21. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/IncidentsTime/index.js +1 -0
  22. package/src/@daf/pages/Dashboards/SupplyChain/components/ChartsContainer/components/Locations/index.js +20 -19
  23. package/src/@daf/pages/Dashboards/SupplyChain/components/ChartsContainer/index.js +5 -2
  24. package/src/@daf/pages/Events/Activities/columns.js +7 -3
  25. package/src/@daf/pages/Events/Incidents/columns.js +7 -3
  26. package/src/@daf/pages/Summary/Operator/components/KeyInformation/config.js +0 -1
  27. package/src/@daf/pages/Summary/Operator/components/TradeRelationships/helper.js +7 -5
  28. package/src/@daf/pages/Summary/Operator/components/TradeRelationships/hook.js +29 -14
  29. package/src/@daf/pages/Summary/Operator/components/TradeRelationships/index.js +69 -20
  30. package/src/@daf/pages/Summary/Operator/index.jsx +1 -0
  31. package/src/@daf/pages/View/index.jsx +1 -1
  32. package/src/helpers/Forms.js +7 -5
@@ -1,4 +1,4 @@
1
- import React, { useState, useMemo, useEffect } from 'react'
1
+ import React, { useState, useMemo, useEffect, useRef } from 'react'
2
2
  import { getFilterConfig } from './helper.js';
3
3
  import { useTradeRelationship } from './hook.js';
4
4
  import Widget from '../../../../../core/components/Dashboard/Widget/index.jsx';
@@ -16,19 +16,33 @@ const TradeRelationships = ({
16
16
  options = {},
17
17
  getRedirectLink = () => {},
18
18
  APP,
19
+ user = {}
19
20
  }) => {
20
21
  const [filters, setFilters] = useState({});
21
22
  const [isFullyRendered, setIsFullyRendered] = useState(true);
23
+ const [isProductsFilterReady, setIsProductsFilterReady] = useState(false);
24
+ const [hasProducts, setHasProducts] = useState(true);
25
+ const [delayedLoading, setDelayedLoading] = useState(false);
26
+ const [delayedDataLoading, setDelayedDataLoading] = useState(false);
22
27
 
23
28
  const onFilterChange = (filters) => {
24
- setFilters((p) => ({ ...p, ...filters }));
29
+ setFilters(filters);
25
30
  };
26
31
 
27
32
  const filterConfig = useMemo(() => {
28
- return getFilterConfig({operatorData, options, filters, t, APP});
33
+ const filterConfig = Object.keys(operatorData).length > 0 ? getFilterConfig({operatorData, options, filters, t, APP}) : {};
34
+ return filterConfig;
29
35
  }, [filters.products, t, options?.mineralOptions, operatorData, options?.minerals, APP]);
30
36
 
31
- const { graphData, loading, fetchedProducts, setFetchedProducts } = useTradeRelationship({
37
+ useEffect(() => {
38
+ if (filterConfig?.products?.options?.length >= 0 && !isProductsFilterReady) {
39
+ console.log('setting has products', filterConfig?.products?.options?.length)
40
+ setHasProducts(filterConfig?.products?.options?.length > 0);
41
+ setIsProductsFilterReady(true);
42
+ }
43
+ }, [filterConfig, isProductsFilterReady]);
44
+
45
+ const { graphData, loading, fetchedProducts, setFetchedProducts, dataLoading } = useTradeRelationship({
32
46
  id,
33
47
  selectedPartners,
34
48
  options,
@@ -36,31 +50,68 @@ const TradeRelationships = ({
36
50
  getRedirectLink,
37
51
  filters,
38
52
  operatorData,
39
- APP
53
+ APP,
54
+ isProductsFilterReady,
55
+ hasProducts,
40
56
  });
41
57
 
42
- console.log({graphData});
58
+ const defaultProduct = useMemo(() => {
59
+ if (filterConfig?.products?.options?.length) {
60
+ return filterConfig?.products?.options?.[0]?.value || null;
61
+ }
62
+ }, [filterConfig]);
43
63
 
44
- useEffect(() => {
45
- const defaultProduct = filterConfig?.[0]?.options?.[0]?.value;
46
64
 
47
- if (!filters.products && defaultProduct) {
48
- setFilters((prev) => {
49
- const data = { ...prev, products: defaultProduct };
50
- return data;
51
- });
65
+ useEffect(() => {
66
+ if (defaultProduct) {
67
+ setFilters({ products: defaultProduct });
52
68
  }
69
+ }, [defaultProduct]);
70
+
71
+
72
+ const _filtersConfig = useMemo(() => ({
73
+ filtersConfig: {
74
+ ...filterConfig,
75
+ },
76
+ options: Object.fromEntries(
77
+ Object.keys(filterConfig).map(key => [key, filterConfig[key].options])
78
+ ),
79
+ language: user?.language,
80
+ selectedFilters: filters,
81
+ onApply: onFilterChange,
82
+ t: t,
83
+ }), [filterConfig, user?.language, filters, t]);
53
84
 
54
- if (!fetchedProducts) {
55
- setFetchedProducts(true);
85
+ useEffect(() => {
86
+ if (loading) {
87
+ setDelayedLoading(true);
88
+ } else {
89
+ const timer = setTimeout(() => {
90
+ setDelayedLoading(false);
91
+ }, 500);
92
+
93
+ return () => clearTimeout(timer);
56
94
  }
57
- }, [filterConfig]);
95
+ }, [loading]);
96
+
97
+ useEffect(() => {
98
+ if (dataLoading) {
99
+ setDelayedDataLoading(true);
100
+ } else {
101
+ const timer = setTimeout(() => {
102
+ setDelayedDataLoading(false);
103
+ }, 500);
104
+
105
+ return () => clearTimeout(timer);
106
+ }
107
+ }, [dataLoading]);
58
108
 
59
109
  return (
60
110
  <Widget
61
111
  title={t("Trade Relationships")}
62
112
  className="flex flex-1 with-border-header no-p-body"
63
- loading={loading || isFullyRendered}
113
+ loading={delayedLoading || delayedDataLoading}
114
+ filtersConfig={_filtersConfig}
64
115
  >
65
116
  <div className="flex flex-1 flex-column justify-content-center">
66
117
  <div style={{ height: 600 }} className="flex flex-column">
@@ -84,12 +135,10 @@ const TradeRelationships = ({
84
135
  maxZoom={1.2}
85
136
  minZoom={0.4}
86
137
  tooltipTitle="Trade"
87
- filtersConfig={filterConfig}
88
- onFilterChange={onFilterChange}
89
138
  onRenderComplete={(data) => {
90
- console.log("onRenderComplete");
91
139
  setIsFullyRendered(!data);
92
140
  }}
141
+ filters={filters}
93
142
  />
94
143
  </div>
95
144
  </div>
@@ -160,6 +160,7 @@ const OperatorSummary = ({
160
160
  getRedirectLink={getRedirectLink}
161
161
  operatorData={singleItemData}
162
162
  APP={APP}
163
+ user={user}
163
164
  />
164
165
  </section>
165
166
  <section>
@@ -260,7 +260,7 @@ const View = ({
260
260
  <Multiselect
261
261
  options={[...sourceOptions]}
262
262
  isAvatarGroup
263
- selectionType="checkbox"
263
+ selectionType="radio"
264
264
  key={partners?.length}
265
265
  canUnselectLast={false}
266
266
  isSingle
@@ -6,6 +6,7 @@ import dayjs from "dayjs";
6
6
  import customParseFormat from "dayjs/plugin/customParseFormat";
7
7
  import utc from "dayjs/plugin/utc";
8
8
  import localizedFormat from "dayjs/plugin/localizedFormat";
9
+ import { findOptions } from "./StringHelper";
9
10
  import "dayjs/locale/fr"; // import desired locales
10
11
  import "dayjs/locale/es";
11
12
  import "dayjs/locale/en";
@@ -897,7 +898,7 @@ export const transformPayload = (payload) => {
897
898
  * @param {object} obj - Object to traverse
898
899
  * @returns {any} - Resolved value or undefined
899
900
  */
900
- export const resolveValuePath = (path, obj) => {
901
+ export const resolveValuePath = (path, obj, form) => {
901
902
  if (!path || !obj) return undefined;
902
903
 
903
904
  // Split by / and traverse the object
@@ -918,7 +919,8 @@ export const resolveValuePath = (path, obj) => {
918
919
  }
919
920
  }
920
921
 
921
- return current;
922
+ const value = Object.keys(form || {})?.length > 0 ? findOptions(current, form?.options || []) : current;
923
+ return value;
922
924
  };
923
925
 
924
926
  /**
@@ -989,7 +991,7 @@ export const getCombinedPrefilledValues = (form) => {
989
991
  * @param {object} parentValues - Parent form values
990
992
  * @returns {string|null} - Resolved string with placeholders replaced by actual values, or null if not ready
991
993
  */
992
- export const resolveCombinedPrefilledValue = (template, values = {}, parentValues = {}) => {
994
+ export const resolveCombinedPrefilledValue = (template, values = {}, parentValues = {}, form) => {
993
995
  if (!template || typeof template !== 'string') return '';
994
996
 
995
997
  // Regular expression to match placeholders like {path} or {path^subpath}
@@ -1005,7 +1007,7 @@ export const resolveCombinedPrefilledValue = (template, values = {}, parentValue
1005
1007
  if (nonParentPaths.length > 0) {
1006
1008
  // Check if at least one non-parent value has actual data
1007
1009
  hasNonParentValue = nonParentPaths.some(path => {
1008
- const value = resolveValuePath(path, values);
1010
+ const value = resolveValuePath(path, values, form?.inputs?.[path]);
1009
1011
  return value !== undefined && value !== null && value !== '';
1010
1012
  });
1011
1013
 
@@ -1027,7 +1029,7 @@ export const resolveCombinedPrefilledValue = (template, values = {}, parentValue
1027
1029
  return formatValue(resolved);
1028
1030
  } else {
1029
1031
  // Regular path in current values
1030
- const resolved = resolveValuePath(path, values);
1032
+ const resolved = resolveValuePath(path, values, form?.inputs?.[path]);
1031
1033
  return formatValue(resolved);
1032
1034
  }
1033
1035
  });