datastake-daf 0.6.826 → 0.6.828

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 (22) hide show
  1. package/dist/components/index.js +1126 -1239
  2. package/dist/hooks/index.js +14 -12
  3. package/dist/pages/index.js +108 -77
  4. package/dist/services/index.js +5 -1
  5. package/package.json +1 -1
  6. package/src/@daf/core/components/Screens/Admin/AdminTables/EventsTable/helper.js +17 -21
  7. package/src/@daf/core/components/Screens/Admin/AdminTables/EventsTable/index.jsx +5 -3
  8. package/src/@daf/core/components/Screens/Admin/AdminTables/hook.js +0 -3
  9. package/src/@daf/core/components/Screens/Admin/AdminViews/index.jsx +2 -1
  10. package/src/@daf/hooks/useGetQueryParams.js +44 -25
  11. package/src/@daf/hooks/useWidgetFetch.js +1 -1
  12. package/src/@daf/pages/Dashboards/UserDashboard/components/MineSites/index.jsx +3 -1
  13. package/src/@daf/pages/Locations/MineSite/config.js +1 -1
  14. package/src/@daf/pages/Stakeholders/Operators/config.js +1 -1
  15. package/src/@daf/pages/Stakeholders/Workers/config.js +1 -1
  16. package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CommunityParticipation/JobsTimeline/index.jsx +32 -9
  17. package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleIndicators/HealthAndSafety/helper.js +48 -43
  18. package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleIndicators/HealthAndSafety/index.jsx +17 -5
  19. package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleOutcomes/PlantingActivitiesTimeline.jsx +12 -5
  20. package/src/@daf/pages/TablePage/hook.js +7 -2
  21. package/src/@daf/pages/View/index.jsx +1 -1
  22. package/src/@daf/services/LinkedSubjects.js +5 -1
@@ -2292,7 +2292,7 @@ const useWidgetFetch = ({
2292
2292
  };
2293
2293
  React.useEffect(() => {
2294
2294
  fetchData();
2295
- }, [config]);
2295
+ }, [JSON.stringify(rest?.filters)]);
2296
2296
  return {
2297
2297
  data,
2298
2298
  loading,
@@ -2399,6 +2399,16 @@ const useGetQueryParams = ({
2399
2399
  product,
2400
2400
  ...rest
2401
2401
  } = queryParams;
2402
+ const parsedSearchParams = safeJsonParse(rawSearchParams);
2403
+ const otherParams = {
2404
+ ...rest,
2405
+ ...(product ? {
2406
+ "products.typeOfProduct": product
2407
+ } : {}),
2408
+ ...(status ? {
2409
+ published: status === "submitted"
2410
+ } : {})
2411
+ };
2402
2412
  return {
2403
2413
  paginationQuery: {
2404
2414
  skip: page,
@@ -2406,21 +2416,13 @@ const useGetQueryParams = ({
2406
2416
  },
2407
2417
  searchParams: {
2408
2418
  qs: search,
2409
- fields: safeJsonParse(rawSearchParams)
2410
- },
2411
- otherParams: {
2412
- ...rest,
2413
- ...(product && {
2414
- "products.typeOfProduct": product
2415
- }),
2416
- ...(status && {
2417
- published: status === "submitted" ? true : false
2418
- })
2419
+ fields: parsedSearchParams
2419
2420
  },
2421
+ otherParams,
2420
2422
  sortBy,
2421
2423
  sortDir
2422
2424
  };
2423
- }, [queryParams]);
2425
+ }, [JSON.stringify(queryParams)]);
2424
2426
  return params;
2425
2427
  };
2426
2428
 
@@ -7491,7 +7491,7 @@ const useWidgetFetch = ({
7491
7491
  };
7492
7492
  React.useEffect(() => {
7493
7493
  fetchData();
7494
- }, [config]);
7494
+ }, [JSON.stringify(rest?.filters)]);
7495
7495
  return {
7496
7496
  data,
7497
7497
  loading,
@@ -14419,6 +14419,9 @@ function MineSites({
14419
14419
  defaultData: [],
14420
14420
  stop: selectedPartners?.loading
14421
14421
  }), [activeTab, selectedPartners, filters]);
14422
+ console.log({
14423
+ dataFetchConfig
14424
+ });
14422
14425
  const {
14423
14426
  data,
14424
14427
  loading,
@@ -40577,6 +40580,16 @@ const useGetQueryParams = ({
40577
40580
  product,
40578
40581
  ...rest
40579
40582
  } = queryParams;
40583
+ const parsedSearchParams = safeJsonParse(rawSearchParams);
40584
+ const otherParams = {
40585
+ ...rest,
40586
+ ...(product ? {
40587
+ "products.typeOfProduct": product
40588
+ } : {}),
40589
+ ...(status ? {
40590
+ published: status === "submitted"
40591
+ } : {})
40592
+ };
40580
40593
  return {
40581
40594
  paginationQuery: {
40582
40595
  skip: page,
@@ -40584,21 +40597,13 @@ const useGetQueryParams = ({
40584
40597
  },
40585
40598
  searchParams: {
40586
40599
  qs: search,
40587
- fields: safeJsonParse(rawSearchParams)
40588
- },
40589
- otherParams: {
40590
- ...rest,
40591
- ...(product && {
40592
- "products.typeOfProduct": product
40593
- }),
40594
- ...(status && {
40595
- published: status === "submitted" ? true : false
40596
- })
40600
+ fields: parsedSearchParams
40597
40601
  },
40602
+ otherParams,
40598
40603
  sortBy,
40599
40604
  sortDir
40600
40605
  };
40601
- }, [queryParams]);
40606
+ }, [JSON.stringify(queryParams)]);
40602
40607
  return params;
40603
40608
  };
40604
40609
 
@@ -41564,7 +41569,7 @@ const getFilterOptions$c = (options, t) => {
41564
41569
  const formConfig$a = {
41565
41570
  namespace: 'OPERATOR',
41566
41571
  view: ['scoping', 'new'],
41567
- scope: 'global',
41572
+ scope: 'createOperator',
41568
41573
  formType: 'operator'
41569
41574
  };
41570
41575
  const viewConfig$a = {
@@ -41991,7 +41996,7 @@ const getFilterOptions$b = (options, t) => {
41991
41996
  const formConfig$9 = {
41992
41997
  namespace: 'WORKERS',
41993
41998
  view: ['scoping', 'new'],
41994
- scope: 'global',
41999
+ scope: 'createWorker',
41995
42000
  formType: 'worker'
41996
42001
  };
41997
42002
  const viewConfig$9 = {
@@ -44636,7 +44641,7 @@ const getFilterOptions$4 = (options, t) => {
44636
44641
  const formConfig$2 = {
44637
44642
  namespace: 'PRODUCTION SITES',
44638
44643
  view: ['scoping', 'new'],
44639
- scope: 'global',
44644
+ scope: 'create',
44640
44645
  formType: 'production-sites'
44641
44646
  };
44642
44647
  const viewConfig$2 = {
@@ -45491,6 +45496,9 @@ const useFetchData = ({
45491
45496
  } = useGetQueryParams({
45492
45497
  location
45493
45498
  });
45499
+ const tab = React.useMemo(() => {
45500
+ return activeTab;
45501
+ }, [activeTab]);
45494
45502
  React.useEffect(() => {
45495
45503
  const cleanSearchParams = Object.fromEntries(Object.entries(searchParams).filter(([_, value]) => value != null && value !== ''));
45496
45504
  const hasPagination = paginationQuery.skip != null || paginationQuery.take != null;
@@ -45506,12 +45514,12 @@ const useFetchData = ({
45506
45514
  ...(Object.keys(cleanSearchParams).length > 0 && {
45507
45515
  search: cleanSearchParams
45508
45516
  }),
45509
- tab: activeTab,
45517
+ tab: tab,
45510
45518
  sortBy: {
45511
45519
  [sortBy || extendingSortKey || "updatedAt"]: sortDir ? sortDir === "ascend" ? 1 : -1 : extendingSortDir || -1
45512
45520
  }
45513
45521
  }, subject);
45514
- }, [location.search, activeTab, JSON.stringify(extendingFilters)]);
45522
+ }, [location.search, JSON.stringify(extendingFilters)]);
45515
45523
  };
45516
45524
  const useTablePage = ({
45517
45525
  subject,
@@ -55413,14 +55421,19 @@ const PlantingActivitiesTimeline = ({
55413
55421
  const dataToProcess = !activitiesTimelineChart || !Array.isArray(activitiesTimelineChart) || activitiesTimelineChart.length === 0 ? [] : activitiesTimelineChart;
55414
55422
 
55415
55423
  // Process data without cumulative calculation (for activities timeline)
55416
- return processChartDateData({
55424
+ const processedData = processChartDateData({
55417
55425
  mainData: dataToProcess,
55418
55426
  isCumulative: false,
55419
55427
  valueField: 'count'
55420
55428
  });
55421
- }, [activitiesTimelineChart, processChartDateData]);
55422
55429
 
55423
- // Calculate max value for Y-axis (default to 100 if all values are 0 or very small)
55430
+ // Remove trailing periods with 0 jobs (optional: remove all zero if you prefer)
55431
+ let lastNonZeroIndex = processedData.length - 1;
55432
+ while (lastNonZeroIndex >= 0 && (processedData[lastNonZeroIndex].jobs || 0) === 0) {
55433
+ lastNonZeroIndex--;
55434
+ }
55435
+ return processedData.slice(0, lastNonZeroIndex + 1);
55436
+ }, [activitiesTimelineChart, processChartDateData]);
55424
55437
  const maxActivitiesYValue = React.useMemo(() => {
55425
55438
  if (!activitiesTimelineData || activitiesTimelineData.length === 0) {
55426
55439
  return 100;
@@ -55765,6 +55778,29 @@ const CyclePartners = ({
55765
55778
  });
55766
55779
  };
55767
55780
 
55781
+ // Custom tooltip labels per field/value
55782
+ const FIELD_TOOLTIP_LABELS = {
55783
+ aidKitAccessible: {
55784
+ compliant: "Available",
55785
+ notCompliant: "Not available",
55786
+ empty: "No data"
55787
+ },
55788
+ hsTrainingConfirmation: {
55789
+ compliant: "Training delivered",
55790
+ notCompliant: "No training",
55791
+ empty: "No data"
55792
+ },
55793
+ duosFormed: {
55794
+ compliant: "Duos formed",
55795
+ notCompliant: "Not implemented",
55796
+ empty: "No data"
55797
+ },
55798
+ presenceOfChildren: {
55799
+ compliant: "None reported",
55800
+ notCompliant: "Children present",
55801
+ empty: "No data"
55802
+ }
55803
+ };
55768
55804
  const HEALTH_SAFETY_COLORS = {
55769
55805
  compliant: '#016C6E',
55770
55806
  notCompliant: '#F97066',
@@ -55776,12 +55812,6 @@ const getIndicatorType$1 = value => {
55776
55812
  if (value === null || value === undefined) return "empty";
55777
55813
  return "empty";
55778
55814
  };
55779
-
55780
- /**
55781
- * Gets health and safety distribution data from activity data
55782
- * @param {Object} activityData - Activity data object
55783
- * @returns {Object} Distribution object with compliant, notCompliant, and empty counts
55784
- */
55785
55815
  const getHealthAndSafetyDistributionData = activityData => {
55786
55816
  // Define health and safety indicator fields
55787
55817
  const indicators = [{
@@ -55817,53 +55847,26 @@ const getHealthAndSafetyDistributionData = activityData => {
55817
55847
  });
55818
55848
  return distribution;
55819
55849
  };
55820
-
55821
- /**
55822
- * Checks if the health and safety distribution data is empty
55823
- * @param {Object} healthAndSafetyDistributionData - Distribution object
55824
- * @returns {boolean} True if all values are 0 or empty
55825
- */
55826
55850
  const isHealthAndSafetyDistributionEmpty = healthAndSafetyDistributionData => {
55827
55851
  return Object.values(healthAndSafetyDistributionData).every(val => !val || val === 0);
55828
55852
  };
55829
-
55830
- /**
55831
- * Calculates pie chart data from health and safety distribution
55832
- * @param {Object} healthAndSafetyDistributionData - Distribution object
55833
- * @param {Function} t - Translation function
55834
- * @returns {Array} Array of pie chart data points with value, percent, color, label, and key
55835
- */
55836
- const calculateHealthAndSafetyPieData = (healthAndSafetyDistributionData, t) => {
55837
- const total = Object.values(healthAndSafetyDistributionData).reduce((all, val) => all + (val || 0), 0);
55853
+ const calculateHealthAndSafetyPieData = (data, t, selectedField) => {
55854
+ const total = Object.values(data).reduce((a, v) => a + (v || 0), 0);
55838
55855
  const labels = {
55839
55856
  compliant: t("Available"),
55840
55857
  notCompliant: t("Not available"),
55841
55858
  empty: t("Not answered")
55842
55859
  };
55843
- return Object.keys(healthAndSafetyDistributionData).map(key => {
55844
- const color = HEALTH_SAFETY_COLORS[key] || '#D9D9D9';
55845
- return {
55846
- value: healthAndSafetyDistributionData[key] || 0,
55847
- percent: total > 0 ? (healthAndSafetyDistributionData[key] || 0) / total : 0,
55848
- color: color,
55849
- label: labels[key] || key,
55850
- key: key
55851
- };
55852
- });
55860
+ return Object.keys(data).map(key => ({
55861
+ value: data[key] || 0,
55862
+ percent: total > 0 ? (data[key] || 0) / total : 0,
55863
+ color: HEALTH_SAFETY_COLORS[key] || '#D9D9D9',
55864
+ label: labels[key] || key,
55865
+ key,
55866
+ keyOfField: selectedField // <-- ADD THIS
55867
+ }));
55853
55868
  };
55854
-
55855
- /**
55856
- * Generates tooltip content for health and safety pie chart
55857
- * Shows all statuses with their percentages
55858
- * @param {Object} item - The pie chart item being hovered (not used, but kept for compatibility)
55859
- * @param {boolean} isEmpty - Whether the distribution is empty
55860
- * @param {Object} healthAndSafetyDistributionData - Distribution object
55861
- * @param {Function} t - Translation function
55862
- * @param {Function} renderTooltipJsx - Function to render tooltip JSX
55863
- * @param {string} tooltipTitle - Title to display in the tooltip (defaults to "Health and Safety")
55864
- * @returns {JSX.Element|null} Tooltip content or null
55865
- */
55866
- const getHealthAndSafetyTooltipChildren = (item, isEmpty, healthAndSafetyDistributionData, t, renderTooltipJsx, tooltipTitle = "Health and Safety") => {
55869
+ const getHealthAndSafetyTooltipChildren = (item, isEmpty, healthAndSafetyDistributionData, t, renderTooltipJsx, tooltipTitle = "Health and Safety", selectedField) => {
55867
55870
  // If empty or no data, return null to display nothing
55868
55871
  if (isEmpty || !Object.keys(healthAndSafetyDistributionData).length) {
55869
55872
  return null;
@@ -55876,10 +55879,10 @@ const getHealthAndSafetyTooltipChildren = (item, isEmpty, healthAndSafetyDistrib
55876
55879
  if (total === 0) {
55877
55880
  return null;
55878
55881
  }
55879
- const labels = {
55882
+ const labels = FIELD_TOOLTIP_LABELS[item?.keyOfField] || {
55880
55883
  compliant: t("Available"),
55881
55884
  notCompliant: t("Not available"),
55882
- empty: t("Not answered")
55885
+ empty: t("No data")
55883
55886
  };
55884
55887
 
55885
55888
  // Filter items with values > 0
@@ -55962,7 +55965,6 @@ const HealthAndSafety = ({
55962
55965
  getData: customGetData
55963
55966
  });
55964
55967
 
55965
- // Process the fetched pie chart data
55966
55968
  // The API returns data in format: [{count: 1, [field]: "null"}, {count: 1, [field]: "no"}, {count: 1, [field]: "yes"}]
55967
55969
  const healthAndSafetyDistributionData = React.useMemo(() => {
55968
55970
  if (!pieChartData) return {
@@ -56003,7 +56005,7 @@ const HealthAndSafety = ({
56003
56005
  return getHealthAndSafetyDistributionData(pieChartData);
56004
56006
  }, [pieChartData, selectedField]);
56005
56007
  const isEmpty = React.useMemo(() => isHealthAndSafetyDistributionEmpty(healthAndSafetyDistributionData), [healthAndSafetyDistributionData]);
56006
- const pieData = React.useMemo(() => calculateHealthAndSafetyPieData(healthAndSafetyDistributionData, t), [healthAndSafetyDistributionData, t]);
56008
+ const pieData = React.useMemo(() => calculateHealthAndSafetyPieData(healthAndSafetyDistributionData, t, selectedField), [healthAndSafetyDistributionData, t, selectedField]);
56007
56009
 
56008
56010
  // Get the label for the selected field to use as tooltip title
56009
56011
  const selectedFieldLabel = React.useMemo(() => {
@@ -56017,9 +56019,10 @@ const HealthAndSafety = ({
56017
56019
  return /*#__PURE__*/jsxRuntime.jsx(Widget, {
56018
56020
  loading: loading || pieChartLoading,
56019
56021
  title: /*#__PURE__*/jsxRuntime.jsx("div", {
56020
- children: t("Health and Safety")
56022
+ children: t("Operational Health & Safety")
56021
56023
  }),
56022
- className: "with-border-header h-w-btn-header ",
56024
+ className: "with-border-header h-w-btn-header",
56025
+ description: t("Across all activities in this cycle."),
56023
56026
  addedHeader: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
56024
56027
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
56025
56028
  className: "flex-1"
@@ -56338,17 +56341,41 @@ const JobsTimeline = ({
56338
56341
  defaultFilter: 'monthly'
56339
56342
  });
56340
56343
  const jobsData = Array.isArray(dayJobsTimeline) ? dayJobsTimeline : dayJobsTimeline?.jobsTimeline || dayJobsTimeline?.jobs || dayJobsTimeline?.timeline || [];
56344
+
56345
+ // const jobsTimelineData = useMemo(() => {
56346
+ // // Always process data, even if empty, to generate default date range for x-axis
56347
+ // const dataToProcess = (!jobsData || !Array.isArray(jobsData) || jobsData.length === 0)
56348
+ // ? []
56349
+ // : jobsData;
56350
+
56351
+ // // Process data without cumulative calculation (for jobs timeline)
56352
+ // // Try to find value in total, count, jobs, or value fields
56353
+ // return processChartDateData({
56354
+ // mainData: dataToProcess,
56355
+ // isCumulative: false,
56356
+ // valueField: 'total', // Will fallback to count/jobs/value if total doesn't exist
56357
+ // });
56358
+ // }, [jobsData, processChartDateData]);
56359
+
56341
56360
  const jobsTimelineData = React.useMemo(() => {
56342
- // Always process data, even if empty, to generate default date range for x-axis
56361
+ // Prepare data first
56343
56362
  const dataToProcess = !jobsData || !Array.isArray(jobsData) || jobsData.length === 0 ? [] : jobsData;
56344
56363
 
56345
- // Process data without cumulative calculation (for jobs timeline)
56346
- // Try to find value in total, count, jobs, or value fields
56347
- return processChartDateData({
56364
+ // Process data without cumulative calculation
56365
+ const processedData = processChartDateData({
56348
56366
  mainData: dataToProcess,
56349
56367
  isCumulative: false,
56350
- valueField: 'total' // Will fallback to count/jobs/value if total doesn't exist
56368
+ valueField: 'total' // fallback handled inside processChartDateData
56351
56369
  });
56370
+
56371
+ // Find last index with jobs > 0
56372
+ let lastNonZeroIndex = processedData.length - 1;
56373
+ while (lastNonZeroIndex >= 0 && (processedData[lastNonZeroIndex].jobs || 0) === 0) {
56374
+ lastNonZeroIndex--;
56375
+ }
56376
+
56377
+ // Slice up to last period with data
56378
+ return processedData.slice(0, lastNonZeroIndex + 1);
56352
56379
  }, [jobsData, processChartDateData]);
56353
56380
  const maxYValue = React.useMemo(() => {
56354
56381
  if (!jobsTimelineData || jobsTimelineData.length === 0) {
@@ -61746,14 +61773,18 @@ const getNamespace = namespace => {
61746
61773
  let _namespace = namespace;
61747
61774
  switch (namespace) {
61748
61775
  case "locations":
61776
+ case "location":
61749
61777
  _namespace = "location";
61750
61778
  break;
61751
61779
  case "stakeholders":
61780
+ case "stakeholder":
61752
61781
  _namespace = "stakeholder";
61753
61782
  break;
61754
61783
  case "documents":
61784
+ case "document":
61755
61785
  _namespace = "document";
61756
61786
  break;
61787
+ case "event":
61757
61788
  case "nashirikiEvent":
61758
61789
  case "events":
61759
61790
  _namespace = "event";
@@ -61796,7 +61827,7 @@ class LinkedSubjectsService extends BaseService {
61796
61827
  version
61797
61828
  }) {
61798
61829
  return this.apiGet({
61799
- url: `/${namespace === "nashirikiEvent" ? "event" : namespace}/${id}`,
61830
+ url: `/${getNamespace(namespace)}/${id}`,
61800
61831
  isApp: true,
61801
61832
  signal,
61802
61833
  params: {
@@ -62112,7 +62143,7 @@ const View = ({
62112
62143
  "management-location": "location",
62113
62144
  "management-stakeholder": "stakeholder",
62114
62145
  "management-event": "event",
62115
- "management-incident": "incident"
62146
+ "management-document": "document"
62116
62147
  };
62117
62148
  const handleDeleteSubject = React.useCallback(async () => {
62118
62149
  try {
@@ -1535,14 +1535,18 @@ const getNamespace = namespace => {
1535
1535
  let _namespace = namespace;
1536
1536
  switch (namespace) {
1537
1537
  case "locations":
1538
+ case "location":
1538
1539
  _namespace = "location";
1539
1540
  break;
1540
1541
  case "stakeholders":
1542
+ case "stakeholder":
1541
1543
  _namespace = "stakeholder";
1542
1544
  break;
1543
1545
  case "documents":
1546
+ case "document":
1544
1547
  _namespace = "document";
1545
1548
  break;
1549
+ case "event":
1546
1550
  case "nashirikiEvent":
1547
1551
  case "events":
1548
1552
  _namespace = "event";
@@ -1585,7 +1589,7 @@ class LinkedSubjectsService extends BaseService {
1585
1589
  version
1586
1590
  }) {
1587
1591
  return this.apiGet({
1588
- url: `/${namespace === "nashirikiEvent" ? "event" : namespace}/${id}`,
1592
+ url: `/${getNamespace(namespace)}/${id}`,
1589
1593
  isApp: true,
1590
1594
  signal,
1591
1595
  params: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.826",
3
+ "version": "0.6.828",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -16,28 +16,10 @@ export const getTabs = ({ t }) => {
16
16
  };
17
17
 
18
18
  export const selectFiltersConfig = {
19
- category: {
19
+ eventsType: {
20
20
  type: "select",
21
- label: "Category",
22
- placeholder: (t) => t("Category"),
23
- style: { flex: 1 },
24
- labelStyle: { flex: 1 },
25
- getLabel: (option) => option.label,
26
- getValue: (option) => option.value,
27
- },
28
- country: {
29
- type: "select",
30
- label: "Country",
31
- placeholder: (t) => t("Country"),
32
- style: { flex: 1 },
33
- labelStyle: { flex: 1 },
34
- getLabel: (option) => option.label,
35
- getValue: (option) => option.value,
36
- },
37
- sources: {
38
- type: "select",
39
- label: "Sources",
40
- placeholder: (t) => t("Sources"),
21
+ label: "type",
22
+ placeholder: (t) => t("type"),
41
23
  style: { flex: 1 },
42
24
  labelStyle: { flex: 1 },
43
25
  getLabel: (option) => option.label,
@@ -45,6 +27,20 @@ export const selectFiltersConfig = {
45
27
  },
46
28
  };
47
29
 
30
+ export const getSelectFiltersConfig = ({t}) => {
31
+ return {
32
+ eventsType: {
33
+ type: "select",
34
+ label: "type",
35
+ placeholder: t("type"),
36
+ style: { flex: 1 },
37
+ labelStyle: { flex: 1 },
38
+ getLabel: (option) => option.label,
39
+ getValue: (option) => option.value,
40
+ },
41
+ }
42
+ };
43
+
48
44
  export const filtersConfig = {
49
45
  name: "",
50
46
  datastakeId: "",
@@ -5,10 +5,10 @@ import DAFTable from "../../../../Table/index.jsx";
5
5
  import { theme, Tag, message } from "antd";
6
6
  import CustomIcon from "../../../../Icon/CustomIcon.jsx";
7
7
  import {
8
- selectFiltersConfig,
9
8
  filtersConfig,
10
9
  defaultUrlParams,
11
10
  checkboxConfig,
11
+ getSelectFiltersConfig,
12
12
  } from "./helper.js";
13
13
  import { getColumns } from "./column.js";
14
14
  import { getTabs } from "../helper.js";
@@ -37,6 +37,10 @@ export default function EventsTable({
37
37
  const [selectedEvents, setSelectedEvents] = useState([]);
38
38
  const { token } = useToken();
39
39
 
40
+ const selectFiltersConfig = useMemo(() => {
41
+ return getSelectFiltersConfig({t});
42
+ }, [t]);
43
+
40
44
  const {
41
45
  filter,
42
46
  activeTab,
@@ -64,8 +68,6 @@ export default function EventsTable({
64
68
  return options;
65
69
  }, [options]);
66
70
 
67
-
68
-
69
71
  const columns = useMemo(() => {
70
72
  return getColumns({
71
73
  t,
@@ -67,7 +67,6 @@ export function useAdminTable({
67
67
  const params = filterParams({
68
68
  activeFilters: filter.activeFilters,
69
69
  });
70
- console.log(params, "params");
71
70
  const { data } = await getData({ params });
72
71
  setData(data.data || data);
73
72
  filter.setPagination((prev) => ({ ...prev, total: data?.meta?.total || data?.length || 0 }));
@@ -109,8 +108,6 @@ export const useGetParams = ({location}) => {
109
108
 
110
109
  const { activeTab, ...rest } = otherParams;
111
110
 
112
- console.log({hasPagination})
113
-
114
111
  const params = useMemo(() => {
115
112
  if (!hasPagination) {
116
113
  return {
@@ -153,7 +153,8 @@ function AdminView({
153
153
  };
154
154
 
155
155
  try {
156
- await updateAccount({ id: editData.id, data: newData });
156
+ const { data} = await updateAccount({ id: editData.id, data: newData });
157
+ console.log({data})
157
158
 
158
159
  console.log('Checking for pending users...', {
159
160
  hasPendingUsers: pendingUsers.length > 0,
@@ -1,30 +1,49 @@
1
1
  import { useMemo } from "react";
2
2
  import { safeJsonParse } from "../../helpers/StringHelper.js";
3
3
 
4
- export const useGetQueryParams = ({location}) => {
5
- const queryParams = useMemo(() => {
6
- const params = new URLSearchParams(location?.search);
7
- return Object.fromEntries(params.entries());
8
- }, [location.search]);
4
+ export const useGetQueryParams = ({ location }) => {
5
+ const queryParams = useMemo(() => {
6
+ const params = new URLSearchParams(location?.search);
7
+ return Object.fromEntries(params.entries());
8
+ }, [location.search]);
9
9
 
10
- const params = useMemo(() => {
11
- const { page, pageSize, search, searchParams: rawSearchParams, sortBy, sortDir, status, product, ...rest } = queryParams;
12
-
13
- return {
14
- paginationQuery: { skip: page, take: pageSize },
15
- searchParams: {
16
- qs: search,
17
- fields: safeJsonParse(rawSearchParams),
18
- },
19
- otherParams: {
20
- ...rest,
21
- ...(product && { "products.typeOfProduct": product }),
22
- ...(status && { published: status === "submitted" ? true : false }),
23
- },
24
- sortBy,
25
- sortDir,
26
- };
27
- }, [queryParams]);
10
+ const params = useMemo(() => {
11
+ const {
12
+ page,
13
+ pageSize,
14
+ search,
15
+ searchParams: rawSearchParams,
16
+ sortBy,
17
+ sortDir,
18
+ status,
19
+ product,
20
+ ...rest
21
+ } = queryParams;
28
22
 
29
- return params;
30
- }
23
+ const parsedSearchParams = safeJsonParse(rawSearchParams);
24
+
25
+ const otherParams = {
26
+ ...rest,
27
+ ...(product ? { "products.typeOfProduct": product } : {}),
28
+ ...(status ? { published: status === "submitted" } : {}),
29
+ };
30
+
31
+ return {
32
+ paginationQuery: {
33
+ skip: page,
34
+ take: pageSize,
35
+ },
36
+ searchParams: {
37
+ qs: search,
38
+ fields: parsedSearchParams,
39
+ },
40
+ otherParams,
41
+ sortBy,
42
+ sortDir,
43
+ };
44
+ }, [
45
+ JSON.stringify(queryParams),
46
+ ]);
47
+
48
+ return params;
49
+ };
@@ -35,7 +35,7 @@ export const useWidgetFetch = ({config, getData = DashboardService.getWidget, on
35
35
 
36
36
  useEffect(() => {
37
37
  fetchData();
38
- }, [config]);
38
+ }, [JSON.stringify(rest?.filters)]);
39
39
 
40
40
  return {
41
41
  data,
@@ -70,8 +70,10 @@ function MineSites({
70
70
  stop: selectedPartners?.loading,
71
71
  }),
72
72
  [activeTab, selectedPartners, filters],
73
+
73
74
  );
74
- const { data, loading, setData } = useWidgetFetch({config: dataFetchConfig});
75
+ console.log({dataFetchConfig})
76
+ const { data, loading, setData } = useWidgetFetch({config: dataFetchConfig});
75
77
 
76
78
  const tabs = useMemo(() => getTabs(t), [t]);
77
79
 
@@ -149,7 +149,7 @@ export const getFilterOptions = (options, t) => {
149
149
  export const formConfig = {
150
150
  namespace: 'PRODUCTION SITES',
151
151
  view: ['scoping', 'new'],
152
- scope: 'global',
152
+ scope: 'create',
153
153
  formType: 'production-sites',
154
154
  }
155
155