datastake-daf 0.6.784 → 0.6.786

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 +71 -74
  2. package/dist/hooks/index.js +9 -1
  3. package/dist/pages/index.js +892 -103
  4. package/dist/utils/index.js +58 -0
  5. package/package.json +1 -1
  6. package/src/@daf/core/components/Dashboard/Map/hook.js +1 -1
  7. package/src/@daf/hooks/useGetQueryParams.js +3 -1
  8. package/src/@daf/pages/Events/Activities/columns.js +2 -2
  9. package/src/@daf/pages/Events/Activities/config.js +2 -2
  10. package/src/@daf/pages/Events/Incidents/columns.js +2 -2
  11. package/src/@daf/pages/Events/Incidents/config.js +2 -2
  12. package/src/@daf/pages/Locations/MineSite/columns.js +2 -2
  13. package/src/@daf/pages/Locations/columns.js +2 -2
  14. package/src/@daf/pages/Stakeholders/Operators/columns.js +2 -2
  15. package/src/@daf/pages/Summary/Activities/MonitoringCampaign/components/KeyInformation/index.jsx +48 -0
  16. package/src/@daf/pages/Summary/Activities/MonitoringCampaign/components/MangroveGrowth/PlantedSpecies.jsx +73 -0
  17. package/src/@daf/pages/Summary/Activities/MonitoringCampaign/components/MangroveGrowth/SeedlingsHeight.jsx +44 -0
  18. package/src/@daf/pages/Summary/Activities/MonitoringCampaign/components/MangroveGrowth/Stats.jsx +86 -0
  19. package/src/@daf/pages/Summary/Activities/MonitoringCampaign/components/MangroveGrowth/VegetationHealth.jsx +73 -0
  20. package/src/@daf/pages/Summary/Activities/MonitoringCampaign/components/MangroveGrowth/index.jsx +92 -0
  21. package/src/@daf/pages/Summary/Activities/MonitoringCampaign/components/MonitoringScopeAndFindings/index.jsx +348 -0
  22. package/src/@daf/pages/Summary/Activities/MonitoringCampaign/config.js +35 -0
  23. package/src/@daf/pages/Summary/Activities/MonitoringCampaign/index.jsx +30 -0
  24. package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CommunityParticipation/CommunityStats/helper.js +1 -1
  25. package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleIndicators/index.jsx +1 -1
  26. package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleOutcomes/index.jsx +1 -1
  27. package/src/@daf/pages/Summary/Activities/PlantingCycle/helper.js +0 -56
  28. package/src/@daf/utils/numbers.js +57 -0
  29. package/src/pages.js +1 -0
  30. package/src/utils.js +1 -1
@@ -8498,20 +8498,22 @@ const useHeader = _ref => {
8498
8498
  const {
8499
8499
  useToken: useToken$m
8500
8500
  } = antd.theme;
8501
- function BreadCrumbs({
8502
- breadcrumbs = [],
8503
- mainContWidth = 0
8504
- }) {
8501
+ function BreadCrumbs(_ref) {
8502
+ let {
8503
+ breadcrumbs = [],
8504
+ mainContWidth = 0
8505
+ } = _ref;
8505
8506
  const [splitIndex, setSplitIndex] = React.useState(0);
8506
8507
  const {
8507
8508
  token
8508
8509
  } = useToken$m();
8509
- const _renderBreadcrumb = (b, i, isLast, noOnClickLast = false) => {
8510
+ const _renderBreadcrumb = function (b, i, isLast) {
8511
+ let noOnClickLast = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
8510
8512
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
8511
8513
  className: "flex breadcrumb-item",
8512
- onClick: noOnClickLast && isLast ? undefined : b?.onClick,
8514
+ onClick: noOnClickLast && isLast ? undefined : b === null || b === void 0 ? void 0 : b.onClick,
8513
8515
  children: [/*#__PURE__*/jsxRuntime.jsx("span", {
8514
- children: b?.label
8516
+ children: b === null || b === void 0 ? void 0 : b.label
8515
8517
  }), !isLast && /*#__PURE__*/jsxRuntime.jsx("div", {
8516
8518
  className: "flex flex-column justify-content-center",
8517
8519
  children: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
@@ -8521,7 +8523,7 @@ function BreadCrumbs({
8521
8523
  color: token.baseGray50
8522
8524
  })
8523
8525
  })]
8524
- }, `breadcrumb-item-${i}`);
8526
+ }, "breadcrumb-item-".concat(i));
8525
8527
  };
8526
8528
  React.useEffect(() => {
8527
8529
  const _placeholderCont = document.getElementById("header-breadcrumbs");
@@ -8564,7 +8566,7 @@ function BreadCrumbs({
8564
8566
  placement: "bottomRight",
8565
8567
  menu: {
8566
8568
  items: groupedBreadCrumbs[2].map((it, i) => ({
8567
- key: `items-${i}`,
8569
+ key: "items-".concat(i),
8568
8570
  label: it.label,
8569
8571
  onClick: it.onClick
8570
8572
  }))
@@ -9969,44 +9971,44 @@ function useAjaxModal$2({
9969
9971
  }
9970
9972
 
9971
9973
  const mergeObject = obj => {
9972
- return Object.entries(obj || {}).reduce((acc, _ref) => {
9973
- let [key, value] = _ref;
9974
+ return Object.entries(obj || {}).reduce((acc, [key, value]) => {
9974
9975
  if (typeof value === "object" && !Array.isArray(value) && value !== null) {
9975
- return _objectSpread2(_objectSpread2({}, acc), value);
9976
+ return {
9977
+ ...acc,
9978
+ ...value
9979
+ };
9976
9980
  }
9977
- return _objectSpread2(_objectSpread2({}, acc), {}, {
9981
+ return {
9982
+ ...acc,
9978
9983
  [key]: value
9979
- });
9984
+ };
9980
9985
  }, {});
9981
9986
  };
9982
- const handleDataLinkGroupWithTableKeys = _ref2 => {
9983
- var _inputConfig$meta, _config$meta2, _inputConfig$meta3, _inputConfig$meta4, _inputConfig$meta5;
9984
- let {
9985
- config,
9986
- inputConfig,
9987
- inputKey,
9988
- value,
9989
- level,
9990
- t,
9991
- rootForm,
9992
- allData,
9993
- user,
9994
- getApiBaseUrl = () => {},
9995
- getAppHeader = () => {},
9996
- app,
9997
- TreeNodeComponent
9998
- } = _ref2;
9987
+ const handleDataLinkGroupWithTableKeys = ({
9988
+ config,
9989
+ inputConfig,
9990
+ inputKey,
9991
+ value,
9992
+ level,
9993
+ t,
9994
+ rootForm,
9995
+ allData,
9996
+ user,
9997
+ getApiBaseUrl = () => {},
9998
+ getAppHeader = () => {},
9999
+ app,
10000
+ TreeNodeComponent
10001
+ }) => {
9999
10002
  if (!(config.type === 'dataLinkGroup' || config.type === 'dataLink')) {
10000
10003
  return null;
10001
10004
  }
10002
- if ((inputConfig === null || inputConfig === void 0 ? void 0 : inputConfig.type) !== 'dataLink' || !(inputConfig !== null && inputConfig !== void 0 && (_inputConfig$meta = inputConfig.meta) !== null && _inputConfig$meta !== void 0 && _inputConfig$meta.tableKeys)) {
10005
+ if (inputConfig?.type !== 'dataLink' || !inputConfig?.meta?.tableKeys) {
10003
10006
  const parentInputKeys = Object.keys(config.inputs || {});
10004
10007
  const isHandledBySiblingDataLink = parentInputKeys.some(otherInputKey => {
10005
10008
  const otherConfig = config.inputs[otherInputKey];
10006
- if ((otherConfig === null || otherConfig === void 0 ? void 0 : otherConfig.type) === 'dataLink') {
10007
- var _otherConfig$meta, _config$meta;
10008
- const siblingTableKeys = (otherConfig === null || otherConfig === void 0 || (_otherConfig$meta = otherConfig.meta) === null || _otherConfig$meta === void 0 ? void 0 : _otherConfig$meta.tableKeys) || [];
10009
- const additionalTableKeys = ((_config$meta = config.meta) === null || _config$meta === void 0 ? void 0 : _config$meta.additionalTableKeys) || [];
10009
+ if (otherConfig?.type === 'dataLink') {
10010
+ const siblingTableKeys = otherConfig?.meta?.tableKeys || [];
10011
+ const additionalTableKeys = config.meta?.additionalTableKeys || [];
10010
10012
  const allSiblingKeys = [...siblingTableKeys, ...additionalTableKeys];
10011
10013
  return allSiblingKeys.includes(inputKey) && otherInputKey !== inputKey;
10012
10014
  }
@@ -10020,26 +10022,23 @@ const handleDataLinkGroupWithTableKeys = _ref2 => {
10020
10022
  return null;
10021
10023
  }
10022
10024
  const tableKeys = inputConfig.meta.tableKeys;
10023
- const additionalTableKeys = ((_config$meta2 = config.meta) === null || _config$meta2 === void 0 ? void 0 : _config$meta2.additionalTableKeys) || [];
10025
+ const additionalTableKeys = config.meta?.additionalTableKeys || [];
10024
10026
  const parentInputKeys = Object.keys(config.inputs || {});
10025
10027
  const siblingInputsMatchingTableKeys = parentInputKeys.filter(siblingKey => siblingKey !== inputKey).filter(siblingKey => tableKeys.includes(siblingKey) || additionalTableKeys.includes(siblingKey));
10026
10028
  [...new Set([...tableKeys, ...siblingInputsMatchingTableKeys])];
10027
- const isAjaxModal = React.useMemo(() => {
10028
- var _inputConfig$meta2;
10029
- return !!(inputConfig !== null && inputConfig !== void 0 && (_inputConfig$meta2 = inputConfig.meta) !== null && _inputConfig$meta2 !== void 0 && _inputConfig$meta2.namespace);
10030
- }, [inputConfig]);
10029
+ const isAjaxModal = React.useMemo(() => !!inputConfig?.meta?.namespace, [inputConfig]);
10031
10030
  const ajaxModalValues = useAjaxModal$2({
10032
10031
  name: inputKey,
10033
10032
  user,
10034
- namespace: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta3 = inputConfig.meta) === null || _inputConfig$meta3 === void 0 ? void 0 : _inputConfig$meta3.namespace,
10035
- skipFetch: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta4 = inputConfig.meta) === null || _inputConfig$meta4 === void 0 ? void 0 : _inputConfig$meta4.skipFetch,
10033
+ namespace: inputConfig?.meta?.namespace,
10034
+ skipFetch: inputConfig?.meta?.skipFetch,
10036
10035
  isAjaxModal,
10037
- formScope: inputConfig === null || inputConfig === void 0 || (_inputConfig$meta5 = inputConfig.meta) === null || _inputConfig$meta5 === void 0 ? void 0 : _inputConfig$meta5.formScope,
10036
+ formScope: inputConfig?.meta?.formScope,
10038
10037
  APP: app,
10039
10038
  apiBaseUrl: getApiBaseUrl(),
10040
10039
  _getAppHeader: getAppHeader
10041
10040
  });
10042
- const dataLinkForm = ajaxModalValues === null || ajaxModalValues === void 0 ? void 0 : ajaxModalValues.form;
10041
+ const dataLinkForm = ajaxModalValues?.form;
10043
10042
  const createInputsAndValues = item => {
10044
10043
  const inputs = {};
10045
10044
  const values = {};
@@ -10051,12 +10050,12 @@ const handleDataLinkGroupWithTableKeys = _ref2 => {
10051
10050
  'videos': 'Video'
10052
10051
  };
10053
10052
  tableKeys.filter(tableKey => tableKey !== 'datastakeId').forEach(tableKey => {
10054
- var _dataLinkForm$identif;
10055
- const formInputConfig = (dataLinkForm === null || dataLinkForm === void 0 ? void 0 : dataLinkForm[tableKey]) || (dataLinkForm === null || dataLinkForm === void 0 || (_dataLinkForm$identif = dataLinkForm['identification']) === null || _dataLinkForm$identif === void 0 ? void 0 : _dataLinkForm$identif[tableKey]);
10053
+ const formInputConfig = dataLinkForm?.[tableKey] || dataLinkForm?.['identification']?.[tableKey];
10056
10054
  if (formInputConfig) {
10057
- inputs[tableKey] = _objectSpread2(_objectSpread2({}, formInputConfig), {}, {
10055
+ inputs[tableKey] = {
10056
+ ...formInputConfig,
10058
10057
  label: uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : formInputConfig.label || formInputConfig.tableLabel || tableKey
10059
- });
10058
+ };
10060
10059
  if (formInputConfig.label && typeof formInputConfig.label === 'object') {
10061
10060
  const dynamicLabelKeys = Object.keys(formInputConfig.label);
10062
10061
  let resolvedLabel = null;
@@ -10064,7 +10063,7 @@ const handleDataLinkGroupWithTableKeys = _ref2 => {
10064
10063
  const parts = labelKey.split(' is ');
10065
10064
  if (parts.length === 2) {
10066
10065
  const [conditionKey, conditionValue] = parts;
10067
- if ((item === null || item === void 0 ? void 0 : item[conditionKey]) === conditionValue) {
10066
+ if (item?.[conditionKey] === conditionValue) {
10068
10067
  resolvedLabel = formInputConfig.label[labelKey];
10069
10068
  break;
10070
10069
  }
@@ -10072,37 +10071,37 @@ const handleDataLinkGroupWithTableKeys = _ref2 => {
10072
10071
  }
10073
10072
  inputs[tableKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] || (uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey);
10074
10073
  }
10075
- values[tableKey] = item === null || item === void 0 ? void 0 : item[tableKey];
10074
+ values[tableKey] = item?.[tableKey];
10076
10075
  } else {
10077
- var _item$linking;
10078
10076
  inputs[tableKey] = {
10079
10077
  label: uploadTypeFields.includes(tableKey) ? uploadTypeLabels[tableKey] : tableKey,
10080
- type: inputConfig === null || inputConfig === void 0 ? void 0 : inputConfig.type
10078
+ type: inputConfig?.type
10081
10079
  };
10082
- values[tableKey] = (item === null || item === void 0 || (_item$linking = item.linking) === null || _item$linking === void 0 || (_item$linking = _item$linking.SCL) === null || _item$linking === void 0 || (_item$linking = _item$linking[item === null || item === void 0 ? void 0 : item[tableKey]]) === null || _item$linking === void 0 ? void 0 : _item$linking.name) || (item === null || item === void 0 ? void 0 : item[tableKey]);
10080
+ values[tableKey] = item?.linking?.SCL?.[item?.[tableKey]]?.name || item?.[tableKey];
10083
10081
  }
10084
10082
  });
10085
10083
  siblingInputsMatchingTableKeys.forEach(siblingKey => {
10086
10084
  const siblingConfig = config.inputs[siblingKey];
10087
10085
  if (siblingConfig) {
10088
- inputs[siblingKey] = _objectSpread2(_objectSpread2({}, siblingConfig), {}, {
10086
+ inputs[siblingKey] = {
10087
+ ...siblingConfig,
10089
10088
  label: siblingConfig.label || siblingKey
10090
- });
10091
- values[siblingKey] = item === null || item === void 0 ? void 0 : item[siblingKey];
10089
+ };
10090
+ values[siblingKey] = item?.[siblingKey];
10092
10091
  }
10093
10092
  });
10094
- if (dataLinkForm !== null && dataLinkForm !== void 0 && dataLinkForm.identification && typeof dataLinkForm.identification === 'object') {
10093
+ if (dataLinkForm?.identification && typeof dataLinkForm.identification === 'object') {
10095
10094
  Object.keys(dataLinkForm.identification).filter(fieldKey => fieldKey !== 'datastakeId' && !tableKeys.includes(fieldKey)).filter(fieldKey => {
10096
10095
  const formInputConfig = dataLinkForm.identification[fieldKey];
10097
10096
  return formInputConfig && typeof formInputConfig === 'object' && !Array.isArray(formInputConfig);
10098
10097
  }).forEach(fieldKey => {
10099
- var _item$linking2;
10100
10098
  const formInputConfig = dataLinkForm.identification[fieldKey];
10101
- inputs[fieldKey] = _objectSpread2(_objectSpread2({}, formInputConfig), {}, {
10099
+ inputs[fieldKey] = {
10100
+ ...formInputConfig,
10102
10101
  label: uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : formInputConfig.label || formInputConfig.tableLabel || fieldKey
10103
- });
10104
- if (formInputConfig !== null && formInputConfig !== void 0 && formInputConfig.label && typeof (formInputConfig === null || formInputConfig === void 0 ? void 0 : formInputConfig.label) === 'object') {
10105
- const dynamicLabelKeys = Object.keys(formInputConfig === null || formInputConfig === void 0 ? void 0 : formInputConfig.label);
10102
+ };
10103
+ if (formInputConfig?.label && typeof formInputConfig?.label === 'object') {
10104
+ const dynamicLabelKeys = Object.keys(formInputConfig?.label);
10106
10105
  let resolvedLabel = null;
10107
10106
  for (const labelKey of dynamicLabelKeys) {
10108
10107
  const parts = labelKey.split(' is ');
@@ -10111,7 +10110,7 @@ const handleDataLinkGroupWithTableKeys = _ref2 => {
10111
10110
  const flattenedItem = Object.assign({}, item.location, {
10112
10111
  address: item.address
10113
10112
  });
10114
- if ((flattenedItem === null || flattenedItem === void 0 ? void 0 : flattenedItem[conditionKey]) === conditionValue) {
10113
+ if (flattenedItem?.[conditionKey] === conditionValue) {
10115
10114
  resolvedLabel = formInputConfig.label[labelKey];
10116
10115
  break;
10117
10116
  }
@@ -10119,7 +10118,7 @@ const handleDataLinkGroupWithTableKeys = _ref2 => {
10119
10118
  }
10120
10119
  inputs[fieldKey].label = resolvedLabel || Object.values(formInputConfig.label)[0] || (uploadTypeFields.includes(fieldKey) ? uploadTypeLabels[fieldKey] : fieldKey);
10121
10120
  }
10122
- values[fieldKey] = (item === null || item === void 0 || (_item$linking2 = item.linking) === null || _item$linking2 === void 0 || (_item$linking2 = _item$linking2.SCL) === null || _item$linking2 === void 0 || (_item$linking2 = _item$linking2[item === null || item === void 0 ? void 0 : item[fieldKey]]) === null || _item$linking2 === void 0 ? void 0 : _item$linking2.name) || (item === null || item === void 0 ? void 0 : item[fieldKey]);
10121
+ values[fieldKey] = item?.linking?.SCL?.[item?.[fieldKey]]?.name || item?.[fieldKey];
10123
10122
  });
10124
10123
  }
10125
10124
  return {
@@ -10129,17 +10128,16 @@ const handleDataLinkGroupWithTableKeys = _ref2 => {
10129
10128
  };
10130
10129
  if (Array.isArray(value)) {
10131
10130
  return value.map((item, itemIndex) => {
10132
- var _merged$inputKey;
10133
10131
  const merged = mergeObject(item);
10134
- const datastakeIdValue = (merged === null || merged === void 0 || (_merged$inputKey = merged[inputKey]) === null || _merged$inputKey === void 0 ? void 0 : _merged$inputKey.datastakeId) || (merged === null || merged === void 0 ? void 0 : merged.datastakeId);
10132
+ const datastakeIdValue = merged?.[inputKey]?.datastakeId || merged?.datastakeId;
10135
10133
  const {
10136
10134
  inputs,
10137
10135
  values
10138
10136
  } = createInputsAndValues(merged);
10139
10137
  return /*#__PURE__*/jsxRuntime.jsx(TreeNodeComponent, {
10140
- nodeKey: datastakeIdValue || t("No ID ".concat(itemIndex + 1)),
10138
+ nodeKey: datastakeIdValue || t(`No ID ${itemIndex + 1}`),
10141
10139
  config: {
10142
- label: datastakeIdValue || t("No ID ".concat(itemIndex + 1)),
10140
+ label: datastakeIdValue || t(`No ID ${itemIndex + 1}`),
10143
10141
  type: 'custom-datalink-group',
10144
10142
  inputs: inputs
10145
10143
  },
@@ -10153,12 +10151,11 @@ const handleDataLinkGroupWithTableKeys = _ref2 => {
10153
10151
  getApiBaseUrl: getApiBaseUrl,
10154
10152
  getAppHeader: getAppHeader,
10155
10153
  app: app
10156
- }, "".concat(inputKey, "-").concat(itemIndex));
10154
+ }, `${inputKey}-${itemIndex}`);
10157
10155
  });
10158
10156
  } else {
10159
- var _merged$inputKey2;
10160
10157
  const merged = mergeObject(value);
10161
- const datastakeIdValue = (merged === null || merged === void 0 || (_merged$inputKey2 = merged[inputKey]) === null || _merged$inputKey2 === void 0 ? void 0 : _merged$inputKey2.datastakeId) || (merged === null || merged === void 0 ? void 0 : merged.datastakeId);
10158
+ const datastakeIdValue = merged?.[inputKey]?.datastakeId || merged?.datastakeId;
10162
10159
  const {
10163
10160
  inputs,
10164
10161
  values
@@ -10180,7 +10177,7 @@ const handleDataLinkGroupWithTableKeys = _ref2 => {
10180
10177
  getApiBaseUrl: getApiBaseUrl,
10181
10178
  getAppHeader: getAppHeader,
10182
10179
  app: app
10183
- }, "".concat(inputKey, "-group"));
10180
+ }, `${inputKey}-group`);
10184
10181
  }
10185
10182
  };
10186
10183
 
@@ -14735,7 +14732,7 @@ const useMap$1 = ({
14735
14732
  });
14736
14733
  function handleSelectMarker(clickedMarker) {
14737
14734
  setSelectedMarkersId(prev => {
14738
- if (prev.includes(clickedMarker.datastakeId)) {
14735
+ if (openPopupIdRef.current === clickedMarker.datastakeId) {
14739
14736
  // Deselecting - clear polylines
14740
14737
  openPopupIdRef.current = null;
14741
14738
  setMarkerWithPopup(null);
@@ -2384,6 +2384,8 @@ const useGetQueryParams = ({
2384
2384
  searchParams: rawSearchParams,
2385
2385
  sortBy,
2386
2386
  sortDir,
2387
+ status,
2388
+ product,
2387
2389
  ...rest
2388
2390
  } = queryParams;
2389
2391
  return {
@@ -2396,7 +2398,13 @@ const useGetQueryParams = ({
2396
2398
  fields: safeJsonParse(rawSearchParams)
2397
2399
  },
2398
2400
  otherParams: {
2399
- ...rest
2401
+ ...rest,
2402
+ ...(product && {
2403
+ "products.typeOfProduct": product
2404
+ }),
2405
+ ...(status && {
2406
+ published: status === "submitted" ? true : false
2407
+ })
2400
2408
  },
2401
2409
  sortBy,
2402
2410
  sortDir