datastake-daf 0.6.844 → 0.6.846

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 (29) hide show
  1. package/dist/components/index.js +28 -67
  2. package/dist/hooks/index.js +12 -22
  3. package/dist/pages/index.js +4132 -4551
  4. package/dist/utils/index.js +9 -1
  5. package/package.json +1 -1
  6. package/src/@daf/core/components/EditForm/helper.js +14 -6
  7. package/src/@daf/core/components/Screens/Admin/AdminModals/NewUser/index.jsx +1 -1
  8. package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/helper.js +59 -77
  9. package/src/@daf/core/components/Screens/Admin/AdminViews/index.jsx +1 -8
  10. package/src/@daf/hooks/useSources.js +6 -4
  11. package/src/@daf/hooks/useWidgetFetch.js +3 -14
  12. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/IncidentsTime/config.js +3 -0
  13. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/IncidentsTime/hook.js +69 -4
  14. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/IncidentsTime/index.js +29 -92
  15. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/ProblemSolver/hook.js +59 -34
  16. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/ProblemSolver/index.js +36 -69
  17. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/TerritorialDistribution/hook.js +56 -0
  18. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/TerritorialDistribution/index.js +50 -75
  19. package/src/@daf/pages/Dashboards/ConflictManagement/index.js +11 -11
  20. package/src/@daf/pages/Dashboards/SupplyChain/components/ChartsContainer/components/GenderDistribution/index.js +46 -51
  21. package/src/@daf/pages/Dashboards/SupplyChain/components/ChartsContainer/components/Identification/hook.js +20 -20
  22. package/src/@daf/pages/Dashboards/SupplyChain/components/ChartsContainer/components/Identification/index.js +26 -2
  23. package/src/@daf/pages/Dashboards/SupplyChain/index.jsx +0 -1
  24. package/src/@daf/pages/Dashboards/UserDashboard/components/DataChainOfCustody/index.jsx +2 -1
  25. package/src/@daf/pages/Dashboards/UserDashboard/components/MineSites/config.js +10 -1
  26. package/src/@daf/pages/Dashboards/UserDashboard/index.jsx +1 -0
  27. package/src/@daf/pages/Dashboards/helper.js +25 -20
  28. package/src/constants/locales/fr/translation.js +9 -0
  29. package/src/constants/locales/sp/translation.js +1 -0
@@ -36595,10 +36595,14 @@ const inputTypeComponent$1 = {
36595
36595
  }
36596
36596
  return {
36597
36597
  label: o.label,
36598
- items: opts.filter(op => op.group === o.value)
36598
+ items: opts.filter(op => op?.filters?.[0]?.value.includes(o.value))
36599
36599
  };
36600
36600
  });
36601
- const notGrouped = opts.filter(op => !gKeys.includes(op.group));
36601
+ const notGrouped = opts.filter(op => {
36602
+ const filterValue = op?.filters?.[0]?.value;
36603
+ if (!filterValue) return true;
36604
+ return !gKeys.some(key => filterValue.includes(key));
36605
+ });
36602
36606
  if (notGrouped.length) {
36603
36607
  groupOptions.unshift(...notGrouped);
36604
36608
  }
@@ -36762,20 +36766,19 @@ const inputTypeComponent$1 = {
36762
36766
  }
36763
36767
  return {
36764
36768
  label: o.label,
36765
- items: opts.filter(op => op.group === o.value)
36769
+ items: opts.filter(op => op?.filters?.[0]?.value.includes(o.value))
36766
36770
  };
36767
36771
  });
36768
- const notGrouped = opts.filter(op => !gKeys.includes(op.group));
36772
+ const notGrouped = opts.filter(op => {
36773
+ const filterValue = op?.filters?.[0]?.value;
36774
+ if (!filterValue) return true;
36775
+ return !gKeys.some(key => filterValue.includes(key));
36776
+ });
36769
36777
  if (notGrouped.length) {
36770
36778
  groupOptions.unshift(...notGrouped);
36771
36779
  }
36772
36780
  opts = groupOptions;
36773
36781
  }
36774
- console.log({
36775
- maxWidth,
36776
- staticWidth,
36777
- fullWidth
36778
- });
36779
36782
  return /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
36780
36783
  size: "medium",
36781
36784
  allowClear: true,
@@ -42168,10 +42171,7 @@ const useCombinedPrefilledValues = (combinedPrefilledValues, values, parentValue
42168
42171
  }
42169
42172
  });
42170
42173
  if (hasChanges) {
42171
- setValues(prevValues => ({
42172
- ...prevValues,
42173
- ...resolvedValues
42174
- }));
42174
+ setValues(prevValues => _objectSpread2(_objectSpread2({}, prevValues), resolvedValues));
42175
42175
  MainForm.setFieldsValue(resolvedValues);
42176
42176
  }
42177
42177
  }, [values, parentValues, combinedPrefilledValues, setValues, MainForm]);
@@ -54422,55 +54422,26 @@ const getColumns$8 = ({
54422
54422
  onCopyInvitation = () => {},
54423
54423
  onResendInvitation = () => {},
54424
54424
  onCanelVerification = () => {},
54425
- setAddAccountVisible = () => {},
54426
- setSelectedAccounts = () => {},
54427
- selectedAccounts = []
54425
+ setAddAccountVisible = () => {}
54428
54426
  }) => {
54429
54427
  const cols = [{
54430
- title: "",
54431
- dataIndex: "select",
54432
- key: "select",
54433
- width: 50,
54434
- active: true,
54435
- pending: true,
54436
- suspended: true,
54437
- show: true,
54438
- render: (v, all) => {
54439
- if (all.empty) {
54440
- return /*#__PURE__*/jsxRuntime.jsx("div", {
54441
- className: "daf-default-cell"
54442
- });
54443
- }
54444
- return /*#__PURE__*/jsxRuntime.jsx(antd.Checkbox, {
54445
- onChange: () => setSelectedAccounts(prev => {
54446
- const isSelected = prev.some(p => p.userId === all.userId);
54447
- if (isSelected) {
54448
- return prev.filter(p => p.userId !== all.userId);
54449
- }
54450
- return [...prev, all];
54451
- }),
54452
- checked: selectedAccounts.some(p => p.userId === all.userId),
54453
- disabled: selectedAccounts.length >= 3 && !selectedAccounts.some(p => p.userId === all.userId)
54454
- });
54455
- }
54456
- }, {
54457
54428
  title: t("ID"),
54458
- dataIndex: "userId",
54459
54429
  key: "userId",
54430
+ ellipsis: true,
54431
+ width: 160,
54460
54432
  active: true,
54461
54433
  pending: true,
54462
54434
  suspended: true,
54463
- ellipsis: true,
54464
- width: 160,
54465
- render: (v, all) => {
54435
+ render: (_, all) => {
54466
54436
  if (all.empty) {
54467
54437
  return /*#__PURE__*/jsxRuntime.jsx("div", {
54468
54438
  className: "daf-default-cell"
54469
54439
  });
54470
54440
  }
54441
+ const id = all.status === "pending" ? all.users?.[0]?.userId ?? all.invitedUser?.userId ?? all.datastakeId ?? "--" : all.userId ?? "--";
54471
54442
  return /*#__PURE__*/jsxRuntime.jsx("div", {
54472
54443
  className: "daf-default-cell",
54473
- children: v || "--"
54444
+ children: id
54474
54445
  });
54475
54446
  }
54476
54447
  }, {
@@ -54486,19 +54457,18 @@ const getColumns$8 = ({
54486
54457
  pending: true,
54487
54458
  suspended: true
54488
54459
  }, {
54489
- title: t("type"),
54490
- dataIndex: "apps",
54491
- key: "apps",
54492
- render: (apps, all) => {
54460
+ title: t("Type"),
54461
+ key: "type",
54462
+ render: (_, all) => {
54493
54463
  if (all.empty) {
54494
54464
  return /*#__PURE__*/jsxRuntime.jsx("div", {
54495
54465
  className: "daf-default-cell"
54496
54466
  });
54497
54467
  }
54498
- const sbg = all?.interface ? all : (apps || []).find(a => a.app === module);
54468
+ const typeValue = all.status === "pending" ? all.type ?? all.otherData?.interface : all.apps?.[0]?.interface;
54499
54469
  return renderTypeTag({
54500
- value: sbg?.interface,
54501
- label: findOptions(sbg?.interface, selectOptions.type)
54470
+ value: typeValue,
54471
+ label: findOptions(typeValue, selectOptions.type)
54502
54472
  });
54503
54473
  },
54504
54474
  active: true,
@@ -54573,7 +54543,8 @@ const getColumns$8 = ({
54573
54543
  className: "daf-default-cell"
54574
54544
  });
54575
54545
  }
54576
- return verified ? /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
54546
+ const isVerified = all.users?.[0]?.emailVerified ?? verified ?? all.emailVerfied;
54547
+ return isVerified ? /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
54577
54548
  color: "green",
54578
54549
  children: t("Yes")
54579
54550
  }) : /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
@@ -56993,7 +56964,7 @@ function NewUser({
56993
56964
  const localUserData = {
56994
56965
  ...apiPayload,
56995
56966
  status: 'pending',
56996
- id: apiPayload.email // Add a unique ID for the table key
56967
+ id: apiPayload.email
56997
56968
  // apps: {
56998
56969
  // [module]: {
56999
56970
  // role: val.role,
@@ -58059,14 +58030,6 @@ function AdminView(_ref) {
58059
58030
  id: editData.id,
58060
58031
  data: newData
58061
58032
  });
58062
- console.log({
58063
- data
58064
- });
58065
- console.log('Checking for pending users...', {
58066
- hasPendingUsers: pendingUsers.length > 0,
58067
- hasInviteFunction: !!inviteCompanyAccount,
58068
- pendingUsers: pendingUsers
58069
- });
58070
58033
  if (pendingUsers.length > 0 && inviteCompanyAccount) {
58071
58034
  console.log('Inviting pending users:', pendingUsers.length);
58072
58035
  for (const user of pendingUsers) {
@@ -58076,8 +58039,6 @@ function AdminView(_ref) {
58076
58039
  status
58077
58040
  } = user,
58078
58041
  userDataToInvite = _objectWithoutProperties(user, _excluded2);
58079
- console.log('Sending invitation for:', user.email, userDataToInvite);
58080
- // Use the standalone invite function, don't mix it with updateAccount
58081
58042
  // await inviteCompanyAccount({
58082
58043
  // companyId: editData.id,
58083
58044
  // data: {
@@ -1732,7 +1732,8 @@ function useSource({
1732
1732
  user = {},
1733
1733
  t = () => {},
1734
1734
  getData = () => {},
1735
- id
1735
+ id,
1736
+ stop
1736
1737
  }) {
1737
1738
  const [loading, setLoading] = React.useState(true);
1738
1739
  const [partners, setPartners] = React.useState([]);
@@ -1786,8 +1787,10 @@ function useSource({
1786
1787
  console.error("Error fetching partners:", error);
1787
1788
  }
1788
1789
  }
1789
- fetchPartners();
1790
- }, [user.language, id]);
1790
+ if (!stop) {
1791
+ fetchPartners();
1792
+ }
1793
+ }, [user.language, id, stop]);
1791
1794
  function handleSelectedPartnersChange(selected) {
1792
1795
  setSelectedPartners(prev => ({
1793
1796
  ...prev,
@@ -1813,9 +1816,6 @@ const useSources = ({
1813
1816
  stop
1814
1817
  }) => {
1815
1818
  function getData(params) {
1816
- if (stop) return Promise.resolve({
1817
- data: []
1818
- });
1819
1819
  if (id !== undefined && id !== null) {
1820
1820
  return SourceService$1.getSources({
1821
1821
  type,
@@ -1834,7 +1834,8 @@ const useSources = ({
1834
1834
  user,
1835
1835
  t,
1836
1836
  getData: getData,
1837
- id
1837
+ id,
1838
+ stop
1838
1839
  });
1839
1840
  const informationSources = partners?.length > 0 ? partners?.length - 1 : 0;
1840
1841
  return {
@@ -2306,46 +2307,35 @@ const useWidgetFetch = ({
2306
2307
  } = config;
2307
2308
  const [data, setData] = React.useState(defaultData || {});
2308
2309
  const [loading, setLoading] = React.useState(false);
2309
- const [initFetchDone, setInitFetchDone] = React.useState(false);
2310
- const isMounted = React.useRef(true);
2311
2310
  const fetchData = async () => {
2312
2311
  setLoading(true);
2313
2312
  try {
2314
2313
  const {
2315
2314
  data
2316
2315
  } = await getData(rest);
2317
- if (!isMounted.current) return;
2318
- setData(data || defaultData);
2316
+ setData(data);
2319
2317
  if (isErrorResponse(data)) {
2320
2318
  const errorMessage = getErrorMessage(data);
2321
2319
  antd.message.error(errorMessage);
2322
2320
  return;
2323
2321
  }
2324
2322
  onFetch();
2325
- setInitFetchDone(true);
2326
2323
  } catch (err) {
2327
2324
  console.log(err);
2328
- }
2329
- if (isMounted.current) {
2325
+ } finally {
2330
2326
  setLoading(false);
2331
2327
  }
2332
2328
  };
2333
- React.useEffect(() => {
2334
- isMounted.current = true;
2335
- return () => {
2336
- isMounted.current = false;
2337
- };
2338
- }, []);
2339
2329
  React.useEffect(() => {
2340
2330
  if (!stop) {
2331
+ console.log('fetching data');
2341
2332
  fetchData();
2342
2333
  }
2343
2334
  }, [JSON.stringify(config), stop]);
2344
2335
  return {
2345
2336
  data,
2346
2337
  loading,
2347
- setData,
2348
- initFetchDone
2338
+ setData
2349
2339
  };
2350
2340
  };
2351
2341