datastake-daf 0.6.842 → 0.6.844

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 (30) hide show
  1. package/dist/components/index.js +800 -774
  2. package/dist/hooks/index.js +4 -6
  3. package/dist/layouts/index.js +6 -0
  4. package/dist/pages/index.js +172 -115
  5. package/package.json +1 -1
  6. package/src/@daf/core/components/DynamicForm/hook.js +2 -2
  7. package/src/@daf/core/components/DynamicForm/index.jsx +1 -1
  8. package/src/@daf/core/components/Filters/selectFilters/index.jsx +7 -1
  9. package/src/@daf/core/components/Graphs/TradeRelationship/index.jsx +1 -27
  10. package/src/@daf/core/components/Graphs/components/BaseGraph.jsx +22 -18
  11. package/src/@daf/core/components/Screens/Admin/AdminModals/NewAccount/index.jsx +19 -6
  12. package/src/@daf/core/components/Screens/Admin/AdminScreens/Accounts.jsx +4 -1
  13. package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/index.jsx +2 -0
  14. package/src/@daf/core/components/Select/MultiSelect/style.js +1 -1
  15. package/src/@daf/core/components/ViewForm/components/DataLink/flat.js +7 -3
  16. package/src/@daf/core/components/ViewForm/components/DataLink/index.js +6 -2
  17. package/src/@daf/core/components/ViewForm/components/input.js +7 -7
  18. package/src/@daf/hooks/useWidgetFetch.js +26 -35
  19. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/IncidentsTime/index.js +1 -0
  20. package/src/@daf/pages/ResetPassword/index.jsx +228 -228
  21. package/src/@daf/pages/Summary/Operator/components/KeyInformation/config.js +0 -1
  22. package/src/@daf/pages/Summary/Operator/components/TradeRelationships/helper.js +7 -5
  23. package/src/@daf/pages/Summary/Operator/components/TradeRelationships/hook.js +29 -14
  24. package/src/@daf/pages/Summary/Operator/components/TradeRelationships/index.js +69 -20
  25. package/src/@daf/pages/Summary/Operator/index.jsx +1 -0
  26. package/src/@daf/pages/Template/components/LinkingTemplate/config.js +1 -0
  27. package/src/@daf/pages/Template/components/LinkingTemplate/index.jsx +3 -1
  28. package/src/@daf/pages/View/index.jsx +1 -1
  29. package/src/@daf/services/LinkedSubjects.js +1 -0
  30. package/src/helpers/Forms.js +7 -5
@@ -2294,7 +2294,6 @@ var DashboardService$1 = createLazyService(DashboardService);
2294
2294
  // url: string
2295
2295
  // basePath: string,
2296
2296
  // }
2297
-
2298
2297
  const useWidgetFetch = ({
2299
2298
  config,
2300
2299
  getData = DashboardService$1.getWidget,
@@ -2310,9 +2309,6 @@ const useWidgetFetch = ({
2310
2309
  const [initFetchDone, setInitFetchDone] = React.useState(false);
2311
2310
  const isMounted = React.useRef(true);
2312
2311
  const fetchData = async () => {
2313
- if (stop) {
2314
- return;
2315
- }
2316
2312
  setLoading(true);
2317
2313
  try {
2318
2314
  const {
@@ -2341,8 +2337,10 @@ const useWidgetFetch = ({
2341
2337
  };
2342
2338
  }, []);
2343
2339
  React.useEffect(() => {
2344
- fetchData();
2345
- }, [JSON.stringify(config)]);
2340
+ if (!stop) {
2341
+ fetchData();
2342
+ }
2343
+ }, [JSON.stringify(config), stop]);
2346
2344
  return {
2347
2345
  data,
2348
2346
  loading,
@@ -7071,6 +7071,12 @@ const SelectFilters = ({
7071
7071
  }) => {
7072
7072
  const [filters, setFilters] = React.useState(selectedFilters || {});
7073
7073
  const [initFilters, setInitFilters] = React.useState(selectedFilters || {});
7074
+
7075
+ // Sync internal state with selectedFilters prop when it changes
7076
+ React.useEffect(() => {
7077
+ setFilters(selectedFilters || {});
7078
+ setInitFilters(selectedFilters || {});
7079
+ }, [selectedFilters]);
7074
7080
  const getClearLabel = () => {
7075
7081
  switch (type) {
7076
7082
  case 'small':
@@ -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
- return current;
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: 0 !important;
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
- fetchData();
7544
- }, [JSON.stringify(config)]);
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
- // In BaseGraph.jsx, replace the useEffect with:
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
- // Use setTimeout instead of requestAnimationFrame to ensure nodes are rendered
12498
- const timer = setTimeout(() => {
12499
- fitView({
12500
- padding: 0.4,
12501
- nodes: [...nodesToFit],
12502
- // duration: withDuration ? 300 : undefined,
12503
- maxZoom: 0.9
12504
- });
12505
- }, 100); // Small delay to ensure nodes are rendered
12506
-
12507
- return () => clearTimeout(timer);
12508
- }, [nodesToFit.length, nodesToFit.map(n => `${n.id}-${n.width}-${n.height}`).join(','), withDuration]);
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, {
@@ -23204,11 +23212,15 @@ function DataLink$1({
23204
23212
  getToken
23205
23213
  });
23206
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
+ }), {});
23207
23219
  const _formData = isSingle ? formData && !Array.isArray(formData) ? [{
23208
- ...form?.meta?.prefilledValues,
23220
+ ...filteredPrefilledValues,
23209
23221
  ...formData
23210
23222
  }] : [] : (Array.isArray(formData) ? formData : []).map(f => ({
23211
- ...form?.meta?.prefilledValues,
23223
+ ...filteredPrefilledValues,
23212
23224
  ...f
23213
23225
  }));
23214
23226
  return (_formData || []).map((f, i) => {
@@ -25602,11 +25614,15 @@ function DataLinkFlat$1({
25602
25614
  }
25603
25615
  }, [entity, values.linking]);
25604
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
+ }), {});
25605
25621
  const _formData = isSingle ? formData && !Array.isArray(formData) ? [{
25606
- ...form?.meta?.prefilledValues,
25622
+ ...filteredPrefilledValues,
25607
25623
  ...formData
25608
25624
  }] : [] : (Array.isArray(formData) ? formData : []).map(f => ({
25609
- ...form?.meta?.prefilledValues,
25625
+ ...filteredPrefilledValues,
25610
25626
  ...f
25611
25627
  }));
25612
25628
  return (_formData || []).map((f, i) => {
@@ -26502,10 +26518,10 @@ const BasicInput = ({
26502
26518
  case 'text':
26503
26519
  case 'phoneNumber':
26504
26520
  case 'textarea':
26505
- 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);
26506
26522
  case 'website':
26507
26523
  case 'link':
26508
- 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);
26509
26525
  if (isModal) {
26510
26526
  return /*#__PURE__*/jsxRuntime.jsx("div", {
26511
26527
  className: "flex flex-column ant-upload-list",
@@ -27133,7 +27149,7 @@ const Input = ({
27133
27149
  ajaxOptions: ajaxOptions,
27134
27150
  evaluationConfig: evaluationConfig
27135
27151
  }, key);
27136
- }), isRepeatable && Array.isArray(modalData) && !modalData.length ? /*#__PURE__*/jsxRuntime.jsx("span", {
27152
+ }), isRepeatable && Array.isArray(modalData) && !modalData.length || modalData === "" ? /*#__PURE__*/jsxRuntime.jsx("span", {
27137
27153
  className: "text-muted",
27138
27154
  children: t('Not answered')
27139
27155
  }) : null]
@@ -27168,7 +27184,7 @@ const Input = ({
27168
27184
  linkingData: linkingData,
27169
27185
  evaluationConfig: evaluationConfig
27170
27186
  }, key);
27171
- }), !modalData || Array.isArray(modalData) && !modalData.length ? /*#__PURE__*/jsxRuntime.jsx("span", {
27187
+ }), !modalData || Array.isArray(modalData) && !modalData.length || modalData === "" ? /*#__PURE__*/jsxRuntime.jsx("span", {
27172
27188
  className: "text-muted",
27173
27189
  children: t('Not answered')
27174
27190
  }) : (Array.isArray(modalData) ? modalData : [modalData]).map((item, itemId) => /*#__PURE__*/jsxRuntime.jsx("div", {
@@ -27254,7 +27270,7 @@ const Input = ({
27254
27270
  linkingData: linkingData,
27255
27271
  evaluationConfig: evaluationConfig
27256
27272
  }, key);
27257
- }), !formData || Array.isArray(formData) && !formData.length ? /*#__PURE__*/jsxRuntime.jsx("span", {
27273
+ }), !formData || Array.isArray(formData) && !formData.length || formData === "" ? /*#__PURE__*/jsxRuntime.jsx("span", {
27258
27274
  className: "text-muted",
27259
27275
  children: t('Not answered')
27260
27276
  }) : (Array.isArray(formData) ? formData : [formData])?.map((item, itemId) => /*#__PURE__*/jsxRuntime.jsxs(React__default["default"].Fragment, {
@@ -39741,7 +39757,7 @@ const getGrouContent = (form, values, i, formId, excludedKeys, getData, setValue
39741
39757
  });
39742
39758
  };
39743
39759
 
39744
- const useCombinedPrefilledValues = (combinedPrefilledValues, values, parentValues, setValues, MainForm) => {
39760
+ const useCombinedPrefilledValues = (combinedPrefilledValues, values, parentValues, setValues, MainForm, form) => {
39745
39761
  const combinedValuesRef = React.useRef({});
39746
39762
  React.useEffect(() => {
39747
39763
  if (!combinedPrefilledValues || Object.keys(combinedPrefilledValues).length === 0) {
@@ -39751,7 +39767,7 @@ const useCombinedPrefilledValues = (combinedPrefilledValues, values, parentValue
39751
39767
  let hasChanges = false;
39752
39768
  Object.keys(combinedPrefilledValues).forEach(fieldKey => {
39753
39769
  const template = combinedPrefilledValues[fieldKey];
39754
- const resolvedValue = resolveCombinedPrefilledValue(template, values, parentValues);
39770
+ const resolvedValue = resolveCombinedPrefilledValue(template, values, parentValues, form);
39755
39771
  if (resolvedValue === null) {
39756
39772
  return;
39757
39773
  }
@@ -39941,7 +39957,7 @@ function DynamicForm({
39941
39957
  }, [data, isCreate]);
39942
39958
 
39943
39959
  // Handle combined prefilled values (auto-fill based on templates)
39944
- useCombinedPrefilledValues(combinedPrefilledValues, values, parentValues, setValues, MainForm);
39960
+ useCombinedPrefilledValues(combinedPrefilledValues, values, parentValues, setValues, MainForm, form);
39945
39961
 
39946
39962
  // Initialize default values for hidden and disabled fields
39947
39963
  React.useEffect(() => {
@@ -46036,11 +46052,6 @@ const getKeyIndicatorConfig = ({
46036
46052
  label: t("Legal Form"),
46037
46053
  render: () => {
46038
46054
  const subCategory = findOptions(data?.subCategory, options?.subCategoriesOptions || options?.subCategory);
46039
- console.log({
46040
- subCategory,
46041
- initialSub: data?.subCategory,
46042
- options: options?.subCategoriesOptions || options?.subCategory
46043
- });
46044
46055
  if (subCategory?.length > 22) {
46045
46056
  const _subCategory = truncateString(subCategory, 22);
46046
46057
  return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
@@ -46551,6 +46562,9 @@ const getFilterConfig = ({
46551
46562
  t = () => {},
46552
46563
  APP
46553
46564
  }) => {
46565
+ console.log({
46566
+ operatorData
46567
+ });
46554
46568
  const productSet = new Set();
46555
46569
  const allTradeMineralOptions = [...(operatorData?.suppliers || []), ...(operatorData?.clients || []), ...(operatorData?.locationSuppliers || [])].flatMap(trade => (trade?.products || []).filter(product => !!product?.typeOfProduct && !productSet.has(product.typeOfProduct)).map(product => {
46556
46570
  productSet.add(product.typeOfProduct);
@@ -46563,17 +46577,22 @@ const getFilterConfig = ({
46563
46577
  const combinedMineralOptions = [...allTradeMineralOptions].filter((option, index, self) => {
46564
46578
  return option && index === self.findIndex(o => o.value === option.value);
46565
46579
  });
46566
- const value = filters.products ? {
46567
- value: filters.products
46580
+ filters?.products ? {
46581
+ value: filters?.products
46568
46582
  } : {};
46569
- return [{
46570
- label: t("Products"),
46571
- placeholder: t("Select"),
46572
- key: "products",
46573
- type: "select",
46574
- ...value,
46575
- options: combinedMineralOptions
46576
- }];
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
+ };
46577
46596
  };
46578
46597
  const getLeft = (data = {}, mapChildren = () => {}, supplierLocations = []) => {
46579
46598
  if (data?.suppliers?.length > 0) {
@@ -46618,6 +46637,8 @@ const mapItem = (data, options, goTo, getRedirectLink, operatorData = {}, APP) =
46618
46637
  const useTradeRelationship = ({
46619
46638
  id,
46620
46639
  selectedPartners,
46640
+ isProductsFilterReady,
46641
+ hasProducts,
46621
46642
  options,
46622
46643
  goTo,
46623
46644
  getRedirectLink,
@@ -46628,18 +46649,31 @@ const useTradeRelationship = ({
46628
46649
  const [graphData, setGraphData] = React.useState({});
46629
46650
  const [loading, setLoading] = React.useState(false);
46630
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);
46631
46662
  const config = React.useMemo(() => ({
46632
46663
  basepath: "analytics",
46633
46664
  url: `/widgets/trade-relationship-map`,
46634
46665
  filters: {
46635
46666
  datastakeId: id,
46636
- product: filters?.products,
46667
+ ...(product && {
46668
+ product: product
46669
+ }),
46637
46670
  sources: selectedPartners?.partners || []
46638
46671
  },
46639
- stop: !selectedPartners?.partners?.length || selectedPartners?.loading
46640
- }), [id, filters?.products, selectedPartners?.partners, selectedPartners?.loading]);
46672
+ stop: !selectedPartners?.partners?.length || selectedPartners?.loading || !isProductsFilterReady || isProductsFilterReady && hasProducts && !product
46673
+ }), [id, product, selectedPartners?.partners, selectedPartners?.loading, isProductsFilterReady, hasProducts]);
46641
46674
  const {
46642
- data
46675
+ data,
46676
+ loading: dataLoading
46643
46677
  } = useWidgetFetch({
46644
46678
  config: config
46645
46679
  });
@@ -46647,7 +46681,7 @@ const useTradeRelationship = ({
46647
46681
  return mapItem(data, options, goTo, getRedirectLink, operatorData, APP);
46648
46682
  };
46649
46683
  React.useEffect(() => {
46650
- if (id && selectedPartners?.partners?.length > 0 && fetchedProducts) {
46684
+ if (id && selectedPartners?.partners?.length > 0) {
46651
46685
  const _fetch = async () => {
46652
46686
  setLoading(true);
46653
46687
  try {
@@ -46734,7 +46768,8 @@ const useTradeRelationship = ({
46734
46768
  setFetchedProducts,
46735
46769
  setGraphData,
46736
46770
  setLoading,
46737
- data
46771
+ data,
46772
+ dataLoading
46738
46773
  };
46739
46774
  };
46740
46775
 
@@ -46749,8 +46784,7 @@ function TradeRelationship({
46749
46784
  filtersConfig,
46750
46785
  onFilterChange = () => {},
46751
46786
  renderTooltipItems = () => [],
46752
- getTotal = () => 0,
46753
- onRenderComplete = () => {}
46787
+ getTotal = () => 0
46754
46788
  }) {
46755
46789
  const reactFlowWrapper = React.useRef(null);
46756
46790
  const [nodes, setNodes] = react.useNodesState([]);
@@ -46763,27 +46797,6 @@ function TradeRelationship({
46763
46797
  const [activeNode, setActiveNode] = React.useState(null);
46764
46798
  // const [initCenter, setInitCenter] = useState(true);
46765
46799
  const [associatedNodes, setAssociatedNodes] = React.useState(null);
46766
- const isFullyRenderedRef = React.useRef(false);
46767
- const [isFullyRendered, setIsFullyRendered] = React.useState(false);
46768
- React.useEffect(() => {
46769
- isFullyRenderedRef.current = false;
46770
- setIsFullyRendered(false);
46771
- setActiveNode(null);
46772
- }, [data]);
46773
- React.useEffect(() => {
46774
- if (nodes.length > 0 && edges.length > 0 && !isFullyRenderedRef.current) {
46775
- const timeoutId = setTimeout(() => {
46776
- isFullyRenderedRef.current = true;
46777
- setIsFullyRendered(true);
46778
- onRenderComplete(true);
46779
- }, 200);
46780
- return () => clearTimeout(timeoutId);
46781
- }
46782
- if (nodes.length === 0 || edges.length === 0) {
46783
- setIsFullyRendered(true);
46784
- onRenderComplete(true);
46785
- }
46786
- }, [nodes.length, edges.length, associatedNodes]);
46787
46800
  React.useEffect(() => {
46788
46801
  setActiveNode(null);
46789
46802
  }, [data]);
@@ -46969,7 +46982,7 @@ function TradeRelationship({
46969
46982
 
46970
46983
  // Cleanup to prevent memory leaks if component unmounts quickly
46971
46984
  return () => clearTimeout(timeoutId);
46972
- }, [data, activeNode]);
46985
+ }, [data]);
46973
46986
  React.useEffect(() => {
46974
46987
  if (activeNode) {
46975
46988
  let _associatedNodesRight = [activeNode];
@@ -47047,30 +47060,41 @@ const TradeRelationships = ({
47047
47060
  id,
47048
47061
  options = {},
47049
47062
  getRedirectLink = () => {},
47050
- APP
47063
+ APP,
47064
+ user = {}
47051
47065
  }) => {
47052
47066
  const [filters, setFilters] = React.useState({});
47053
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);
47054
47072
  const onFilterChange = filters => {
47055
- setFilters(p => ({
47056
- ...p,
47057
- ...filters
47058
- }));
47073
+ setFilters(filters);
47059
47074
  };
47060
47075
  const filterConfig = React.useMemo(() => {
47061
- return getFilterConfig({
47076
+ const filterConfig = Object.keys(operatorData).length > 0 ? getFilterConfig({
47062
47077
  operatorData,
47063
47078
  options,
47064
47079
  filters,
47065
47080
  t,
47066
47081
  APP
47067
- });
47082
+ }) : {};
47083
+ return filterConfig;
47068
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]);
47069
47092
  const {
47070
47093
  graphData,
47071
47094
  loading,
47072
47095
  fetchedProducts,
47073
- setFetchedProducts
47096
+ setFetchedProducts,
47097
+ dataLoading
47074
47098
  } = useTradeRelationship({
47075
47099
  id,
47076
47100
  selectedPartners,
@@ -47079,30 +47103,57 @@ const TradeRelationships = ({
47079
47103
  getRedirectLink,
47080
47104
  filters,
47081
47105
  operatorData,
47082
- APP
47083
- });
47084
- console.log({
47085
- graphData
47106
+ APP,
47107
+ isProductsFilterReady,
47108
+ hasProducts
47086
47109
  });
47110
+ const defaultProduct = React.useMemo(() => {
47111
+ if (filterConfig?.products?.options?.length) {
47112
+ return filterConfig?.products?.options?.[0]?.value || null;
47113
+ }
47114
+ }, [filterConfig]);
47087
47115
  React.useEffect(() => {
47088
- const defaultProduct = filterConfig?.[0]?.options?.[0]?.value;
47089
- if (!filters.products && defaultProduct) {
47090
- setFilters(prev => {
47091
- const data = {
47092
- ...prev,
47093
- products: defaultProduct
47094
- };
47095
- return data;
47116
+ if (defaultProduct) {
47117
+ setFilters({
47118
+ products: defaultProduct
47096
47119
  });
47097
47120
  }
47098
- if (!fetchedProducts) {
47099
- setFetchedProducts(true);
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);
47100
47140
  }
47101
- }, [filterConfig]);
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]);
47102
47152
  return /*#__PURE__*/jsxRuntime.jsx(Widget, {
47103
47153
  title: t("Trade Relationships"),
47104
47154
  className: "flex flex-1 with-border-header no-p-body",
47105
- loading: loading || isFullyRendered,
47155
+ loading: delayedLoading || delayedDataLoading,
47156
+ filtersConfig: _filtersConfig,
47106
47157
  children: /*#__PURE__*/jsxRuntime.jsx("div", {
47107
47158
  className: "flex flex-1 flex-column justify-content-center",
47108
47159
  children: /*#__PURE__*/jsxRuntime.jsx("div", {
@@ -47127,12 +47178,10 @@ const TradeRelationships = ({
47127
47178
  maxZoom: 1.2,
47128
47179
  minZoom: 0.4,
47129
47180
  tooltipTitle: "Trade",
47130
- filtersConfig: filterConfig,
47131
- onFilterChange: onFilterChange,
47132
47181
  onRenderComplete: data => {
47133
- console.log("onRenderComplete");
47134
47182
  setIsFullyRendered(!data);
47135
- }
47183
+ },
47184
+ filters: filters
47136
47185
  })
47137
47186
  })
47138
47187
  })
@@ -47849,7 +47898,8 @@ const OperatorSummary = ({
47849
47898
  goTo: goTo,
47850
47899
  getRedirectLink: getRedirectLink,
47851
47900
  operatorData: singleItemData,
47852
- APP: APP
47901
+ APP: APP,
47902
+ user: user
47853
47903
  })
47854
47904
  }), /*#__PURE__*/jsxRuntime.jsx("section", {
47855
47905
  children: /*#__PURE__*/jsxRuntime.jsx(Governance, {
@@ -62372,7 +62422,8 @@ const namespaceMap = {
62372
62422
  "armed-groups": "stakeholder",
62373
62423
  scl: "location",
62374
62424
  testimonials: 'event',
62375
- 'corrective-actions': 'event'
62425
+ 'corrective-actions': 'event',
62426
+ kyc: 'stakeholder'
62376
62427
  };
62377
62428
 
62378
62429
  const getColumns = ({
@@ -62632,7 +62683,10 @@ const LinkingTemplate = ({
62632
62683
  }), [conf]);
62633
62684
  const id = conf.allData.id;
62634
62685
  const dataSource = conf?.linkingTemplateContextData?.[id];
62635
- const _namespace = namespaceMap[namespace];
62686
+
62687
+ // Derive namespace from conf.allData.form if not provided
62688
+ const derivedNamespace = namespace || conf.allData?.form;
62689
+ const _namespace = namespaceMap[derivedNamespace] || derivedNamespace;
62636
62690
  const changeData = async () => {
62637
62691
  try {
62638
62692
  const _data = await LinkedSubjectsService$1.getLinkedSubjects({
@@ -62963,7 +63017,7 @@ const View = ({
62963
63017
  children: /*#__PURE__*/jsxRuntime.jsx(Multiselect, {
62964
63018
  options: [...sourceOptions],
62965
63019
  isAvatarGroup: true,
62966
- selectionType: "checkbox",
63020
+ selectionType: "radio",
62967
63021
  canUnselectLast: false,
62968
63022
  isSingle: true,
62969
63023
  onChange: selected => {
@@ -64226,6 +64280,9 @@ function IncidentsTimeline({
64226
64280
  if (selectedRange === "12") return baseMonths.map(m => m.label);
64227
64281
  return baseWeeks.map(w => w.label);
64228
64282
  }, [selectedRange, baseMonths, baseWeeks]);
64283
+ console.log({
64284
+ filtersConfig
64285
+ });
64229
64286
  const getTooltipContent = React.useCallback(({
64230
64287
  item
64231
64288
  }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.842",
3
+ "version": "0.6.844",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -1,7 +1,7 @@
1
1
  import { useRef, useEffect } from "react";
2
2
  import { resolveCombinedPrefilledValue } from "../../../../helpers/Forms";
3
3
 
4
- export const useCombinedPrefilledValues = (combinedPrefilledValues, values, parentValues, setValues, MainForm) => {
4
+ export const useCombinedPrefilledValues = (combinedPrefilledValues, values, parentValues, setValues, MainForm, form) => {
5
5
  const combinedValuesRef = useRef({});
6
6
 
7
7
  useEffect(() => {
@@ -14,7 +14,7 @@ export const useCombinedPrefilledValues = (combinedPrefilledValues, values, pare
14
14
 
15
15
  Object.keys(combinedPrefilledValues).forEach(fieldKey => {
16
16
  const template = combinedPrefilledValues[fieldKey];
17
- const resolvedValue = resolveCombinedPrefilledValue(template, values, parentValues);
17
+ const resolvedValue = resolveCombinedPrefilledValue(template, values, parentValues, form);
18
18
 
19
19
  if (resolvedValue === null) {
20
20
  return;
@@ -178,7 +178,7 @@ export default function DynamicForm({
178
178
  }, [data, isCreate]);
179
179
 
180
180
  // Handle combined prefilled values (auto-fill based on templates)
181
- useCombinedPrefilledValues(combinedPrefilledValues, values, parentValues, setValues, MainForm);
181
+ useCombinedPrefilledValues(combinedPrefilledValues, values, parentValues, setValues, MainForm, form);
182
182
 
183
183
  // Initialize default values for hidden and disabled fields
184
184
  useEffect(() => {