datastake-daf 0.6.817 → 0.6.819

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 (35) hide show
  1. package/dist/components/index.js +1215 -1074
  2. package/dist/pages/index.js +264 -89
  3. package/dist/services/index.js +0 -5
  4. package/package.json +1 -1
  5. package/public/Vegetation/damage-from-insects-default.svg +1 -0
  6. package/public/Vegetation/dry-or-dead-default.svg +1 -0
  7. package/public/Vegetation/healthy-default.svg +1 -0
  8. package/public/Vegetation/yellowing.svg +1 -0
  9. package/src/@daf/core/components/Charts/RadarChart/index.jsx +53 -2
  10. package/src/@daf/core/components/Charts/style.js +1 -1
  11. package/src/@daf/core/components/Dashboard/Widget/VegetationWidget/index.jsx +0 -4
  12. package/src/@daf/core/components/ViewForm/components/Records/config.js +1 -0
  13. package/src/@daf/core/components/ViewForm/components/Records/index.jsx +0 -1
  14. package/src/@daf/pages/Dashboards/SupplyChain/components/KeyIndicators/config.js +2 -2
  15. package/src/@daf/pages/Dashboards/SupplyChain/components/KeyIndicators/index.js +3 -2
  16. package/src/@daf/pages/Dashboards/SupplyChain/index.jsx +4 -1
  17. package/src/@daf/pages/Dashboards/UserDashboard/components/KeyIndicators/config.js +3 -3
  18. package/src/@daf/pages/Dashboards/UserDashboard/components/KeyIndicators/index.jsx +4 -2
  19. package/src/@daf/pages/Dashboards/UserDashboard/components/MineSites/config.js +2 -2
  20. package/src/@daf/pages/Dashboards/UserDashboard/config.js +2 -2
  21. package/src/@daf/pages/Dashboards/UserDashboard/index.jsx +1 -0
  22. package/src/@daf/pages/Dashboards/helper.js +2 -2
  23. package/src/@daf/pages/Events/config.js +1 -1
  24. package/src/@daf/pages/Locations/MineSite/columns.js +1 -1
  25. package/src/@daf/pages/Summary/Activities/MonitoringCampaign/components/BiodiversityHabitat/ObservedFauna.jsx +6 -11
  26. package/src/@daf/pages/Summary/Activities/MonitoringCampaign/components/BiodiversityHabitat/index.jsx +4 -2
  27. package/src/@daf/pages/Summary/Activities/MonitoringCampaign/components/MangroveGrowth/PlantedSpecies.jsx +25 -10
  28. package/src/@daf/pages/Summary/Activities/MonitoringCampaign/components/MangroveGrowth/SeedlingsHeight.jsx +10 -13
  29. package/src/@daf/pages/Summary/Activities/MonitoringCampaign/components/MangroveGrowth/VegetationHealth.jsx +19 -4
  30. package/src/@daf/pages/Summary/Activities/MonitoringCampaign/components/SoilWaterProfile/SoilType.jsx +22 -10
  31. package/src/@daf/pages/Summary/Activities/MonitoringCampaign/components/SoilWaterProfile/WaterQuality.jsx +26 -10
  32. package/src/@daf/pages/Summary/Activities/MonitoringCampaign/components/chartHelpers.js +74 -0
  33. package/src/@daf/pages/TablePage/create.jsx +3 -1
  34. package/src/@daf/pages/TablePage/hook.js +2 -0
  35. package/src/@daf/services/LinkedSubjects.js +1 -1
@@ -7523,14 +7523,15 @@ const getRowConfig$1 = ({
7523
7523
  data = {},
7524
7524
  goTo,
7525
7525
  getRedirectLink,
7526
- theme = {}
7526
+ theme = {},
7527
+ APP
7527
7528
  }) => [{
7528
7529
  label: /*#__PURE__*/jsxRuntime.jsx(KeyIndicatorNavigateLabel, {
7529
7530
  t: t,
7530
7531
  getRedirectLink: getRedirectLink,
7531
7532
  theme: theme,
7532
7533
  label: "Identified Mine Sites",
7533
- link: "/app/production-sites"
7534
+ link: APP === 'nashiriki' ? '/app/scl' : '/app/production-sites'
7534
7535
  }),
7535
7536
  render: () => {
7536
7537
  return /*#__PURE__*/jsxRuntime.jsx("span", {
@@ -8137,7 +8138,8 @@ function KeyIndicators$1({
8137
8138
  theme = {},
8138
8139
  getRedirectLink = () => {},
8139
8140
  t = () => {},
8140
- goTo = () => {}
8141
+ goTo = () => {},
8142
+ APP
8141
8143
  }) {
8142
8144
  const fetchConfig = React.useMemo(() => ({
8143
8145
  ...defaultFetchConfig$6,
@@ -8161,9 +8163,10 @@ function KeyIndicators$1({
8161
8163
  },
8162
8164
  goTo,
8163
8165
  getRedirectLink,
8164
- theme
8166
+ theme,
8167
+ APP
8165
8168
  });
8166
- }, [t, data, goTo, getRedirectLink, theme]);
8169
+ }, [t, data, goTo, getRedirectLink, theme, APP]);
8167
8170
  return /*#__PURE__*/jsxRuntime.jsx(KeyIndicatorsWidget, {
8168
8171
  t: t,
8169
8172
  config: config,
@@ -12732,7 +12735,7 @@ const mapDataForChainOfCustody = (data = {}, options = {}, goTo = () => {}) => {
12732
12735
  number: 0,
12733
12736
  name: item.name,
12734
12737
  sources: parentId ? [parentId] : [],
12735
- subTitle: findOptions(item?.category, options?.categoriesOptions),
12738
+ subTitle: findOptions(item?.category, options?.categoriesOptions || options?.category || []),
12736
12739
  leftIcon: type === "client" ? rightIcon : leftIcon,
12737
12740
  leftBackground: type === "client" ? rightBackground : leftBackground,
12738
12741
  topIcon: mapIcon(item.category),
@@ -12749,7 +12752,7 @@ const mapDataForChainOfCustody = (data = {}, options = {}, goTo = () => {}) => {
12749
12752
  id: data.id,
12750
12753
  number: 0,
12751
12754
  name: data.name,
12752
- subTitle: findOptions(data?.category, options?.categoriesOptions),
12755
+ subTitle: findOptions(data?.category, options?.categoriesOptions || options?.category || []),
12753
12756
  leftIcon: middleIcon,
12754
12757
  leftBackground: theme.colorPrimary10,
12755
12758
  topIcon: mapIcon(data.category),
@@ -12768,7 +12771,7 @@ const mapDataForChainOfCustody = (data = {}, options = {}, goTo = () => {}) => {
12768
12771
 
12769
12772
  const Container$1 = styled__default["default"].div`
12770
12773
  height: ${props => props.height || '300px'};
12771
- width: ${props => props.isPdf ? props.width ? props.width : '1000px' : 'calc(100% - 48px)'};
12774
+ width: ${props => props.isPdf ? props.width ? props.width : '1000px' : 'calc(100% - 48px)'};
12772
12775
  `;
12773
12776
 
12774
12777
  const useLegendConfig = ({
@@ -13907,7 +13910,9 @@ function SupplyChain({
13907
13910
  setSelectedPartners,
13908
13911
  informationSources,
13909
13912
  hardcodedData,
13910
- breadcrumbs = []
13913
+ breadcrumbs = [],
13914
+ supportText,
13915
+ APP
13911
13916
  }) {
13912
13917
  const sourceOptions = React.useMemo(() => {
13913
13918
  if (!partners?.length) return [];
@@ -13950,6 +13955,7 @@ function SupplyChain({
13950
13955
  defaultSelected: partners?.map(p => p.id) || []
13951
13956
  }, partners?.length)
13952
13957
  }),
13958
+ supportText: supportText,
13953
13959
  breadcrumbs: breadcrumbs
13954
13960
  }),
13955
13961
  children: [/*#__PURE__*/jsxRuntime.jsx("section", {
@@ -13958,7 +13964,8 @@ function SupplyChain({
13958
13964
  theme: theme,
13959
13965
  t: t,
13960
13966
  goTo: goTo,
13961
- getRedirectLink: getRedirectLink
13967
+ getRedirectLink: getRedirectLink,
13968
+ APP: APP
13962
13969
  })
13963
13970
  }), /*#__PURE__*/jsxRuntime.jsx("section", {
13964
13971
  children: /*#__PURE__*/jsxRuntime.jsx(SupplyChainMap, {
@@ -13995,11 +14002,11 @@ const getActionWidgetsConfig = ({
13995
14002
  }) => [{
13996
14003
  icon: "MineSite",
13997
14004
  title: t("Create Mine Site"),
13998
- onClick: () => goTo(getRedirectLink("/app/production-sites?create=true"))
14005
+ onClick: () => goTo(getRedirectLink(`/app/${APP === 'nashiriki' ? 'scl' : 'production-sites'}?create=true`))
13999
14006
  }, {
14000
14007
  icon: "FileEdit",
14001
14008
  title: "Report Activity",
14002
- onClick: () => goTo(getRedirectLink("/app/activities?create=true"))
14009
+ onClick: () => goTo(getRedirectLink(`/app/${APP === 'nashiriki' ? 'corrective-actions' : 'activities'}?create=true`))
14003
14010
  }, {
14004
14011
  icon: "ReportIncidents",
14005
14012
  title: "Report Incident",
@@ -14060,7 +14067,8 @@ const getRowConfig = ({
14060
14067
  data = {},
14061
14068
  goTo,
14062
14069
  getRedirectLink,
14063
- theme = {}
14070
+ theme = {},
14071
+ APP
14064
14072
  }) => [{
14065
14073
  label: /*#__PURE__*/jsxRuntime.jsx(KeyIndicatorNavigateLabel, {
14066
14074
  t: t,
@@ -14090,8 +14098,8 @@ const getRowConfig = ({
14090
14098
  t: t,
14091
14099
  getRedirectLink: getRedirectLink,
14092
14100
  theme: theme,
14093
- label: "Activities",
14094
- link: "/app/activities"
14101
+ label: APP === 'nashiriki' ? 'Corrective Actions' : 'Activities',
14102
+ link: APP === 'nashiriki' ? '/app/corrective-actions' : '/app/activities'
14095
14103
  }),
14096
14104
  render: () => {
14097
14105
  return /*#__PURE__*/jsxRuntime.jsx("span", {
@@ -14134,7 +14142,8 @@ function KeyIndicators({
14134
14142
  goTo = () => {},
14135
14143
  getRedirectLink = () => {},
14136
14144
  theme = {},
14137
- partners = []
14145
+ partners = [],
14146
+ APP
14138
14147
  }) {
14139
14148
  const fetchConfig = React.useMemo(() => ({
14140
14149
  ...defaultFetchConfig$5
@@ -14153,8 +14162,9 @@ function KeyIndicators({
14153
14162
  },
14154
14163
  goTo,
14155
14164
  getRedirectLink,
14156
- theme
14157
- }), [t, data, goTo, getRedirectLink, partners, theme]);
14165
+ theme,
14166
+ APP
14167
+ }), [t, data, goTo, getRedirectLink, partners, theme, APP]);
14158
14168
  return /*#__PURE__*/jsxRuntime.jsx(KeyIndicatorsWidget, {
14159
14169
  t: t,
14160
14170
  config: config,
@@ -14185,7 +14195,7 @@ const getFiltersConfig$e = ({
14185
14195
  const value = filters.type ? {
14186
14196
  value: filters.type
14187
14197
  } : {};
14188
- const eventCategoryOptions = (options?.eventCategoryOptions || [])?.map(item => ({
14198
+ const eventCategoryOptions = (options?.eventCategoryOptions || options?.categoryOptions || [])?.map(item => ({
14189
14199
  value: item.value,
14190
14200
  label: typeof item.label === 'object' ? Object.values(item.label)[1] : item.label
14191
14201
  }));
@@ -14196,7 +14206,7 @@ const getFiltersConfig$e = ({
14196
14206
  key: "category",
14197
14207
  type: "select",
14198
14208
  ...value,
14199
- options: options?.categoriesOptions ?? []
14209
+ options: options?.categoriesOptions || options?.category || []
14200
14210
  }];
14201
14211
  }
14202
14212
  if (activeTab === 'event') {
@@ -15487,7 +15497,8 @@ function UserDashboard({
15487
15497
  partners: informationSourcesCount,
15488
15498
  t: t,
15489
15499
  goTo: goTo,
15490
- getRedirectLink: getRedirectLink
15500
+ getRedirectLink: getRedirectLink,
15501
+ APP: APP
15491
15502
  })
15492
15503
  }), /*#__PURE__*/jsxRuntime.jsx("section", {
15493
15504
  children: /*#__PURE__*/jsxRuntime.jsx(MineSites, {
@@ -41038,6 +41049,10 @@ const Create = ({
41038
41049
  ...payloadData,
41039
41050
  form: formType
41040
41051
  };
41052
+ const {
41053
+ datastakeId,
41054
+ ...finalPayload
41055
+ } = newPayload;
41041
41056
  const callback = (type, m, data) => {
41042
41057
  if (setSelectedFormNext) {
41043
41058
  setSelectedFormNext();
@@ -41048,7 +41063,7 @@ const Create = ({
41048
41063
  antd.message.error(m);
41049
41064
  }
41050
41065
  };
41051
- saveData(!data && !data.id ? newPayload : Object.assign(newPayload, {
41066
+ saveData(!data && !data.id ? finalPayload : Object.assign(finalPayload, {
41052
41067
  id: data.id
41053
41068
  }), callback);
41054
41069
  },
@@ -42487,7 +42502,7 @@ const getFilterOptions$9 = (options, t) => {
42487
42502
  category,
42488
42503
  eventCategoryOptions
42489
42504
  } = options || {};
42490
- const catOptions = eventCategoryOptions?.map(item => ({
42505
+ const catOptions = (eventCategoryOptions || categoryOptions || [])?.map(item => ({
42491
42506
  value: item.value,
42492
42507
  label: typeof item.label === 'object' ? Object.values(item.label)[1] : item.label
42493
42508
  }));
@@ -44834,7 +44849,7 @@ const getColumns$6 = ({
44834
44849
  label: t("Summary"),
44835
44850
  value: "Summary",
44836
44851
  onClick: () => {
44837
- let link = `/app/${subject === 'scl' ? 'summary/scl' : 'mine-summary'}/${all.datastakeId}`;
44852
+ let link = `/app/mine-summary/${all.datastakeId}`;
44838
44853
  if (activeTab === "shared") {
44839
44854
  link += `?sourceId=${all?.authorId?.id}`;
44840
44855
  }
@@ -45464,6 +45479,9 @@ const useTablePage = ({
45464
45479
  t,
45465
45480
  subject
45466
45481
  }), [t, subject, getFiltersConfig$1]);
45482
+ console.log({
45483
+ options
45484
+ });
45467
45485
  React.useEffect(() => {
45468
45486
  setSelectOptions(prev => ({
45469
45487
  ...prev,
@@ -49812,17 +49830,10 @@ function VegetationWidget({
49812
49830
  ...props
49813
49831
  }) {
49814
49832
  let vegetationConfig = getVegetationConfig();
49815
-
49816
- // Get all VEGETATION_KEYS values before filtering (needed for mapping check)
49817
49833
  const allVegetationKeys = vegetationConfig.map(item => item.key);
49818
-
49819
- // Filter to show only specific keys if filterKeys is provided
49820
49834
  if (filterKeys && Array.isArray(filterKeys)) {
49821
49835
  vegetationConfig = vegetationConfig.filter(item => filterKeys.includes(item.key));
49822
49836
  }
49823
-
49824
- // Map growthObservations to VEGETATION_KEYS
49825
- // Handle both formats: growthObservations keys (e.g., "yellowing_leaves") and VEGETATION_KEYS (e.g., "yellowing")
49826
49837
  const mappedGrowthObservations = Array.isArray(growthObservations) ? growthObservations.map(obs => {
49827
49838
  // First try to map from growthObservations format
49828
49839
  const mapped = GROWTH_OBSERVATIONS_TO_VEGETATION_KEYS[obs];
@@ -50919,6 +50930,7 @@ const getSourcesType = subject => {
50919
50930
  locations: "location",
50920
50931
  location: "location",
50921
50932
  "production-sites": "location",
50933
+ scl: "location",
50922
50934
  stakeholders: "stakeholder",
50923
50935
  stakeholder: "stakeholder",
50924
50936
  workers: "stakeholder",
@@ -50976,9 +50988,6 @@ const Records = ({
50976
50988
  source: selectedSource
50977
50989
  }
50978
50990
  });
50979
- console.log({
50980
- data
50981
- });
50982
50991
  setVersions(data);
50983
50992
  } catch (error) {
50984
50993
  console.error('Error fetching versions:', error);
@@ -52300,6 +52309,44 @@ const RadarChart = ({
52300
52309
  legendConfig,
52301
52310
  isPdf
52302
52311
  });
52312
+
52313
+ // Helper function to wrap long text labels to multiple lines
52314
+ // Ensures text is never hidden - wraps to multiple lines if needed
52315
+ const wrapLabel = React.useCallback((text, maxLength = 10) => {
52316
+ if (!text) {
52317
+ return '';
52318
+ }
52319
+ const formattedText = formattedXAxis(text);
52320
+
52321
+ // If text is short enough, return as is
52322
+ if (formattedText.length <= maxLength) {
52323
+ return formattedText;
52324
+ }
52325
+
52326
+ // Split by spaces to find word boundaries
52327
+ const words = formattedText.split(' ');
52328
+ const lines = [];
52329
+ let currentLine = '';
52330
+ words.forEach((word, index) => {
52331
+ // If adding this word would exceed maxLength, start a new line
52332
+ if (currentLine && (currentLine + ' ' + word).length > maxLength) {
52333
+ if (currentLine) {
52334
+ lines.push(currentLine);
52335
+ }
52336
+ currentLine = word;
52337
+ } else {
52338
+ currentLine = currentLine ? currentLine + ' ' + word : word;
52339
+ }
52340
+
52341
+ // If it's the last word, add it to lines
52342
+ if (index === words.length - 1 && currentLine) {
52343
+ lines.push(currentLine);
52344
+ }
52345
+ });
52346
+
52347
+ // Ensure we always return something - never empty
52348
+ return lines.length > 0 ? lines.join('\n') : formattedText;
52349
+ }, [formattedXAxis]);
52303
52350
  React.useEffect(() => {
52304
52351
  if (!containerRef.current) {
52305
52352
  return;
@@ -52320,9 +52367,21 @@ const RadarChart = ({
52320
52367
  ...tooltipConfig
52321
52368
  },
52322
52369
  color: color || token.colorPrimary7,
52370
+ // Increased padding to ensure labels are never clipped
52371
+ padding: [50, 50, 50, 50],
52323
52372
  xAxis: {
52324
52373
  label: {
52325
- formatter: formattedXAxis
52374
+ formatter: text => wrapLabel(text, 10),
52375
+ offset: 15,
52376
+ autoRotate: false,
52377
+ autoHide: false,
52378
+ // Never hide labels
52379
+ autoEllipsis: false,
52380
+ // Never truncate with ellipsis
52381
+ style: {
52382
+ fontSize: 12,
52383
+ fill: '#666'
52384
+ }
52326
52385
  },
52327
52386
  line: null,
52328
52387
  tickLine: null,
@@ -52380,7 +52439,7 @@ const RadarChart = ({
52380
52439
  } else {
52381
52440
  chartRef.current.update(chartConfig);
52382
52441
  }
52383
- }, [data, xFieldKey, yFieldKey, seriesField, renderTooltipContent, tooltipConfig, animated, color, formattedYAxis, formattedXAxis, score, token.colorPrimary7, rest]);
52442
+ }, [data, xFieldKey, yFieldKey, seriesField, renderTooltipContent, tooltipConfig, animated, color, formattedYAxis, formattedXAxis, score, token.colorPrimary7, wrapLabel, rest]);
52384
52443
  React.useEffect(() => {
52385
52444
  return () => {
52386
52445
  if (chartRef.current) {
@@ -57706,7 +57765,20 @@ const MonitoringScopeAndFindings = ({
57706
57765
  });
57707
57766
  };
57708
57767
 
57709
- const COLORS$3 = ['#016C6E', '#F5C2AC', '#F0A888', '#DF571E', '#C04B19', '#9B3D14', '#7A2F0F'];
57768
+ const VEGETATION_HEALTH_COLORS = {
57769
+ healthy_leaves: '#6AD99E',
57770
+ white_spots: '#E8F0F0',
57771
+ yellowing_leaves: '#CDC14F',
57772
+ black_spots: '#2E3131',
57773
+ reddish_spots: '#CB2525',
57774
+ leaf_mosaic: '#B59E76',
57775
+ spider_webs: '#F8F6EF',
57776
+ damage_from_insects: '#DE8954',
57777
+ dry_dead_leaves: '#767870',
57778
+ no_leaves: '#F97066',
57779
+ other: '#BDBDBD'
57780
+ };
57781
+ const DEFAULT_COLOR$3 = '#9E9E9E';
57710
57782
  const VegetationHealth = ({
57711
57783
  vegetationHealthChart,
57712
57784
  t = s => s,
@@ -57727,7 +57799,7 @@ const VegetationHealth = ({
57727
57799
  return data.map((item, index) => ({
57728
57800
  value: Number(item?.count) || 0,
57729
57801
  percent: total > 0 ? (Number(item?.count) || 0) / total : 0,
57730
- color: COLORS$3[index % COLORS$3.length],
57802
+ color: VEGETATION_HEALTH_COLORS[item?.name] || DEFAULT_COLOR$3,
57731
57803
  label: optionsMap[item?.name] || item?.name || '',
57732
57804
  key: item?.name || `item-${index}`
57733
57805
  }));
@@ -57825,6 +57897,80 @@ const calculateNiceAxisConfig = (data, valueField = 'value', multiplier = 1.2, d
57825
57897
  };
57826
57898
  };
57827
57899
 
57900
+ /**
57901
+ * Calculate y-axis configuration with natural numbers (integers) only
57902
+ * Always starts from 0 and extends slightly above max for better visualization
57903
+ * @param {number} maxValue - Maximum value from the data
57904
+ * @param {Object} options - Optional configuration
57905
+ * @param {number} options.minTicks - Minimum number of ticks to show (default: 4)
57906
+ * @param {number} options.maxTicks - Maximum number of ticks to show (default: 6)
57907
+ * @returns {Object} Axis configuration with min, max, and tickMethod
57908
+ */
57909
+ const calculateNaturalAxisConfig = (maxValue, options = {}) => {
57910
+ const {
57911
+ minTicks = 4,
57912
+ maxTicks = 6
57913
+ } = options;
57914
+ if (maxValue <= 0) {
57915
+ return {
57916
+ min: 0,
57917
+ max: 4,
57918
+ tickMethod: () => [0, 1, 2, 3, 4]
57919
+ };
57920
+ }
57921
+
57922
+ // For very small values (max <= 1), always show 0, 1, 2, 3, 4
57923
+ if (maxValue <= 1) {
57924
+ return {
57925
+ min: 0,
57926
+ max: 4,
57927
+ tickMethod: () => [0, 1, 2, 3, 4]
57928
+ };
57929
+ }
57930
+
57931
+ // Calculate appropriate step size based on max value
57932
+ let step = 1;
57933
+ let displayMax = maxValue;
57934
+ if (maxValue <= 5) {
57935
+ // For small values, use step of 1 and extend a bit above
57936
+ step = 1;
57937
+ displayMax = Math.max(5, Math.ceil(maxValue * 1.5));
57938
+ } else if (maxValue <= 10) {
57939
+ // For medium-small values, use step of 2
57940
+ step = 2;
57941
+ displayMax = Math.ceil(maxValue * 1.2 / step) * step;
57942
+ } else if (maxValue <= 20) {
57943
+ // For medium values, use step of 5
57944
+ step = 5;
57945
+ displayMax = Math.ceil(maxValue * 1.2 / step) * step;
57946
+ } else if (maxValue <= 50) {
57947
+ // For larger values, use step of 10
57948
+ step = 10;
57949
+ displayMax = Math.ceil(maxValue * 1.2 / step) * step;
57950
+ } else {
57951
+ // For very large values, calculate step to get 4-6 ticks
57952
+ const targetTicks = Math.min(maxTicks, Math.max(minTicks, Math.ceil(maxValue / 20)));
57953
+ step = Math.ceil(maxValue / targetTicks / 10) * 10; // Round to nearest 10
57954
+ displayMax = Math.ceil(maxValue * 1.2 / step) * step;
57955
+ }
57956
+
57957
+ // Generate ticks from 0 to displayMax
57958
+ const ticks = [];
57959
+ for (let i = 0; i <= displayMax; i += step) {
57960
+ ticks.push(i);
57961
+ }
57962
+
57963
+ // Ensure max value is included if it's close
57964
+ if (ticks[ticks.length - 1] < maxValue && maxValue - ticks[ticks.length - 1] <= step / 2) {
57965
+ ticks.push(maxValue);
57966
+ }
57967
+ return {
57968
+ min: 0,
57969
+ max: displayMax,
57970
+ tickMethod: () => ticks
57971
+ };
57972
+ };
57973
+
57828
57974
  /**
57829
57975
  * Merge default categories with backend data
57830
57976
  * Ensures all categories are displayed even if they have no data
@@ -57880,13 +58026,11 @@ const SeedlingsHeight$1 = ({
57880
58026
  return mergeDefaultCategories(seedlingsHeightChart, DEFAULT_HEIGHT_RANGES, 'range', 'count', 'label', 'value');
57881
58027
  }, [seedlingsHeightChart]);
57882
58028
  const yAxisConfig = React.useMemo(() => {
57883
- return calculateNiceAxisConfig(chartData, 'value', 2,
57884
- // multiplier: double the max value
57885
- {
57886
- min: 0,
57887
- max: 20,
57888
- tickMethod: () => [0, 5, 10, 15, 20]
57889
- });
58029
+ // Calculate max value from data
58030
+ const maxValue = chartData && chartData.length > 0 ? Math.max(...chartData.map(item => Number(item?.value) || 0)) : 0;
58031
+
58032
+ // Use the helper function to calculate natural number axis configuration
58033
+ return calculateNaturalAxisConfig(maxValue);
57890
58034
  }, [chartData]);
57891
58035
  return /*#__PURE__*/jsxRuntime.jsx(Widget, {
57892
58036
  title: t("Seedlings Height"),
@@ -57908,9 +58052,9 @@ const SeedlingsHeight$1 = ({
57908
58052
  const item = data[0]?.data || data[0];
57909
58053
  return {
57910
58054
  title: t("Seedlings Height"),
57911
- subTitle: title,
57912
58055
  items: [{
57913
- label: t("Count"),
58056
+ color: "#016C6E",
58057
+ label: title,
57914
58058
  value: item?.value || 0
57915
58059
  }]
57916
58060
  };
@@ -57921,7 +58065,12 @@ const SeedlingsHeight$1 = ({
57921
58065
  });
57922
58066
  };
57923
58067
 
57924
- const COLORS$2 = ['#6AD99E', '#F5C2AC', '#F0A888', '#DF571E', '#C04B19', '#9B3D14', '#7A2F0F'];
58068
+ const PLANTED_SPECIES_COLORS = {
58069
+ rhyzophora_mangle: '#016C6E',
58070
+ rhyzophora: '#00AEB1',
58071
+ rhyzophora_sp: '#A0EBEC'
58072
+ };
58073
+ const DEFAULT_COLOR$2 = '#9E9E9E';
57925
58074
  const PlantedSpecies$1 = ({
57926
58075
  plantedSpeciesChart,
57927
58076
  t = s => s,
@@ -57942,7 +58091,7 @@ const PlantedSpecies$1 = ({
57942
58091
  return data.map((item, index) => ({
57943
58092
  value: Number(item?.count) || 0,
57944
58093
  percent: total > 0 ? (Number(item?.count) || 0) / total : 0,
57945
- color: COLORS$2[index % COLORS$2.length],
58094
+ color: PLANTED_SPECIES_COLORS[item?.name] || DEFAULT_COLOR$2,
57946
58095
  label: optionsMap[item?.name] || item?.name || '',
57947
58096
  key: item?.name || `item-${index}`
57948
58097
  }));
@@ -57954,15 +58103,22 @@ const PlantedSpecies$1 = ({
57954
58103
  if (isEmpty) {
57955
58104
  return null;
57956
58105
  }
58106
+
58107
+ // Calculate total from all items
58108
+ const total = pieData.reduce((sum, dataItem) => sum + (dataItem.value || 0), 0);
58109
+
58110
+ // Show all items in the tooltip, sorted by value (descending)
58111
+ const allItems = pieData.filter(dataItem => dataItem.value > 0).sort((a, b) => b.value - a.value).map(dataItem => ({
58112
+ color: dataItem.color,
58113
+ label: dataItem.label || '',
58114
+ value: dataItem.value || 0
58115
+ }));
57957
58116
  return renderTooltipJsx({
57958
58117
  title: t("Planted Species"),
57959
- items: [{
57960
- color: item.color,
57961
- label: item.label || '',
57962
- value: item.value || 0
57963
- }]
58118
+ subTitle: total.toLocaleString(),
58119
+ items: allItems
57964
58120
  });
57965
- }, [t, isEmpty]);
58121
+ }, [t, isEmpty, pieData]);
57966
58122
  return /*#__PURE__*/jsxRuntime.jsx(Widget, {
57967
58123
  title: t("Planted Species"),
57968
58124
  className: "with-border-header h-w-btn-header",
@@ -58227,13 +58383,8 @@ const ObservedFauna = ({
58227
58383
  }));
58228
58384
  }, [observedFaunaChart, options]);
58229
58385
  const xAxisConfig = React.useMemo(() => {
58230
- return calculateNiceAxisConfig(chartData, 'value', 1.2,
58231
- // multiplier: 20% padding
58232
- {
58233
- min: 0,
58234
- max: 10,
58235
- tickMethod: () => [0, 2, 4, 6, 8, 10]
58236
- });
58386
+ const maxValue = chartData && chartData.length > 0 ? Math.max(...chartData.map(item => Number(item?.value) || 0)) : 0;
58387
+ return calculateNaturalAxisConfig(maxValue);
58237
58388
  }, [chartData]);
58238
58389
  return /*#__PURE__*/jsxRuntime.jsx(Widget, {
58239
58390
  title: t("Observed Fauna"),
@@ -58416,21 +58567,29 @@ const BiodiversityHabitat = ({
58416
58567
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
58417
58568
  style: {
58418
58569
  display: "flex",
58419
- gap: "24px"
58570
+ gap: "24px",
58571
+ flexWrap: "wrap"
58420
58572
  },
58421
58573
  children: [/*#__PURE__*/jsxRuntime.jsx("section", {
58422
58574
  style: {
58423
- flex: 1
58575
+ flex: 1,
58576
+ minWidth: "300px"
58424
58577
  },
58425
58578
  children: /*#__PURE__*/jsxRuntime.jsx(ObservedFauna, {
58426
58579
  observedFaunaChart: observedFauna,
58427
58580
  t: t,
58428
58581
  options: options
58429
58582
  })
58430
- }), /*#__PURE__*/jsxRuntime.jsx(InvasiveSpecies, {
58431
- invasiveSpeciesChart: invasiveSpecies,
58432
- t: t,
58433
- options: options
58583
+ }), /*#__PURE__*/jsxRuntime.jsx("section", {
58584
+ style: {
58585
+ flex: 1,
58586
+ minWidth: "300px"
58587
+ },
58588
+ children: /*#__PURE__*/jsxRuntime.jsx(InvasiveSpecies, {
58589
+ invasiveSpeciesChart: invasiveSpecies,
58590
+ t: t,
58591
+ options: options
58592
+ })
58434
58593
  })]
58435
58594
  })]
58436
58595
  })
@@ -58503,7 +58662,13 @@ const Stats = ({
58503
58662
  });
58504
58663
  };
58505
58664
 
58506
- const COLORS$1 = ['#016C6E', '#4FB3A1', '#A8E6CF', '#FFD93D', '#F0A888', '#DF571E', '#C04B19'];
58665
+ const SOIL_TYPE_COLORS$1 = {
58666
+ sandy: '#00AEB1',
58667
+ mixed: '#016C6E',
58668
+ clay: '#A0EBEC',
58669
+ muddy: '#4FB3A1'
58670
+ };
58671
+ const DEFAULT_COLOR$1 = '#9E9E9E';
58507
58672
  const SoilType = ({
58508
58673
  soilTypeChart,
58509
58674
  t = s => s,
@@ -58524,7 +58689,7 @@ const SoilType = ({
58524
58689
  return data.map((item, index) => ({
58525
58690
  value: Number(item?.count) || 0,
58526
58691
  percent: total > 0 ? (Number(item?.count) || 0) / total : 0,
58527
- color: COLORS$1[index % COLORS$1.length],
58692
+ color: SOIL_TYPE_COLORS$1[item?.soilType] || DEFAULT_COLOR$1,
58528
58693
  label: optionsMap[item?.soilType] || item?.soilType || '',
58529
58694
  key: item?.soilType || `item-${index}`
58530
58695
  }));
@@ -58536,15 +58701,18 @@ const SoilType = ({
58536
58701
  if (isEmpty) {
58537
58702
  return null;
58538
58703
  }
58704
+
58705
+ // Show all items in the tooltip, sorted by percentage (descending)
58706
+ const allItems = pieData.filter(dataItem => dataItem.value > 0).sort((a, b) => b.percent - a.percent).map(dataItem => ({
58707
+ color: dataItem.color,
58708
+ label: dataItem.label || '',
58709
+ value: renderPercentage(Math.round(dataItem.percent * 100))
58710
+ }));
58539
58711
  return renderTooltipJsx({
58540
58712
  title: t("Soil Type"),
58541
- items: [{
58542
- color: item.color,
58543
- label: optionsMap[item.label] || item.label || '',
58544
- value: `${renderPercentage(item.percent.toFixed(2) * 100)}`
58545
- }]
58713
+ items: allItems
58546
58714
  });
58547
- }, [t, isEmpty, optionsMap]);
58715
+ }, [t, isEmpty, pieData]);
58548
58716
  return /*#__PURE__*/jsxRuntime.jsx(Widget, {
58549
58717
  title: t("Soil Type"),
58550
58718
  className: "with-border-header h-w-btn-header",
@@ -58645,7 +58813,16 @@ const SalinityLevels = ({
58645
58813
  });
58646
58814
  };
58647
58815
 
58648
- const COLORS = ['#6AD99E', '#FFD93D', '#F0A888', '#DF571E', '#B0B0B0', '#016C6E', '#4FB3A1'];
58816
+ const WATER_QUALITY_COLORS = {
58817
+ fairly_clear: '#32D583',
58818
+ turbid: '#FFA940',
58819
+ polluted: '#F97066',
58820
+ oil_traces: '#2B3644',
58821
+ no_water: '#DAD6CE',
58822
+ clear: '#6AD99E',
58823
+ other: '#9E9E9E'
58824
+ };
58825
+ const DEFAULT_COLOR = '#9E9E9E';
58649
58826
  const WaterQuality = ({
58650
58827
  waterQualityChart,
58651
58828
  t = s => s,
@@ -58666,7 +58843,7 @@ const WaterQuality = ({
58666
58843
  return data.map((item, index) => ({
58667
58844
  value: Number(item?.count) || 0,
58668
58845
  percent: total > 0 ? (Number(item?.count) || 0) / total : 0,
58669
- color: COLORS[index % COLORS.length],
58846
+ color: WATER_QUALITY_COLORS[item?.waterQuality] || DEFAULT_COLOR,
58670
58847
  label: optionsMap[item?.waterQuality] || item?.waterQuality || '',
58671
58848
  key: item?.waterQuality || `item-${index}`
58672
58849
  }));
@@ -58678,15 +58855,18 @@ const WaterQuality = ({
58678
58855
  if (isEmpty) {
58679
58856
  return null;
58680
58857
  }
58858
+
58859
+ // Show all items in the tooltip, sorted by percentage (descending)
58860
+ const allItems = pieData.filter(dataItem => dataItem.value > 0).sort((a, b) => b.percent - a.percent).map(dataItem => ({
58861
+ color: dataItem.color,
58862
+ label: dataItem.label || '',
58863
+ value: renderPercentage(Math.round(dataItem.percent * 100))
58864
+ }));
58681
58865
  return renderTooltipJsx({
58682
58866
  title: t("Water Quality"),
58683
- items: [{
58684
- color: item.color,
58685
- label: item.label || '',
58686
- value: `${Math.round(item.percent * 100)}%`
58687
- }]
58867
+ items: allItems
58688
58868
  });
58689
- }, [t, isEmpty]);
58869
+ }, [t, isEmpty, pieData]);
58690
58870
  return /*#__PURE__*/jsxRuntime.jsx(Widget, {
58691
58871
  title: t("Water Quality"),
58692
58872
  className: "with-border-header h-w-btn-header",
@@ -61365,11 +61545,6 @@ class LinkedSubjectsService extends BaseService {
61365
61545
  getForm({
61366
61546
  namespace
61367
61547
  }, language = "en", scope) {
61368
- console.log({
61369
- namespace,
61370
- language,
61371
- scope
61372
- });
61373
61548
  return this.apiGet({
61374
61549
  url: `forms/${namespace === "documents" ? namespace : getNamespace(namespace)}`,
61375
61550
  isApp: true,