datastake-daf 0.6.825 → 0.6.827

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 (24) hide show
  1. package/dist/components/index.js +1188 -1112
  2. package/dist/pages/index.js +111 -79
  3. package/dist/services/index.js +1 -2
  4. package/dist/style/datastake/mapbox-gl.css +330 -0
  5. package/dist/utils/index.js +1 -1
  6. package/package.json +1 -1
  7. package/src/@daf/core/components/Screens/Admin/AdminTables/DocumentsTable/index.jsx +3 -13
  8. package/src/@daf/core/components/Screens/Admin/AdminTables/EventsTable/column.js +1 -1
  9. package/src/@daf/core/components/Screens/Admin/AdminTables/EventsTable/index.jsx +1 -7
  10. package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/index.jsx +1 -7
  11. package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/index.jsx +1 -7
  12. package/src/@daf/core/components/Screens/Admin/AdminTables/hook.js +16 -7
  13. package/src/@daf/pages/Events/Testimonials/config.js +1 -1
  14. package/src/@daf/pages/Locations/ConflictAreas/config.js +1 -1
  15. package/src/@daf/pages/Stakeholders/ArmedGroups/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/Template/components/LinkingTemplate/config.js +5 -0
  21. package/src/@daf/pages/View/hooks/useViewPermissions.js +25 -3
  22. package/src/@daf/pages/View/index.jsx +3 -6
  23. package/src/@daf/services/AdminService.js +1 -2
  24. package/src/constants/locales/sp/translation.js +1 -1
@@ -11601,7 +11601,7 @@ const sp = {
11601
11601
  "unlinkData": "¿Está seguro de que desea eliminar este enlace?",
11602
11602
  "Link": "Enlace",
11603
11603
  "riskMitigationMeasures": "Medidas de mitigación del riesgo",
11604
- "other": "Otros",
11604
+ "other": "Otro",
11605
11605
  "Reset": "Restablecer",
11606
11606
  "Lir Details": "Detalles LIR",
11607
11607
  "Locations": "Ubicaciones",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.825",
3
+ "version": "0.6.827",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -37,12 +37,6 @@ export default function DocumentsTable({
37
37
  const [selectedDocuments, setSelectedDocuments] = useState([]);
38
38
  const { token } = useToken();
39
39
 
40
- const transformedParams = useGetParams({location});
41
-
42
- const getDataWithStringPagination = async () => {
43
- return getData({ params: transformedParams });
44
- };
45
-
46
40
  const {
47
41
  filter,
48
42
  activeTab,
@@ -62,17 +56,13 @@ export default function DocumentsTable({
62
56
  defaultPageSize,
63
57
  filtersConfig,
64
58
  getRedirectLink,
65
- getData: getDataWithStringPagination,
59
+ getData: getData,
66
60
  refetchTrigger,
67
61
  });
68
62
 
69
63
  const selectOptions = useMemo(() => {
70
- return {
71
- category: config.options?.category,
72
- country: config.options?.countries,
73
- sources: [],
74
- };
75
- }, [config.options]);
64
+ return options;
65
+ }, [options]);
76
66
 
77
67
  const columns = useMemo(() => {
78
68
  return getColumns({
@@ -57,7 +57,7 @@ export const getColumns = ({
57
57
  label: typeof item.label === 'object' ? Object.values(item.label)[1] : item.label,
58
58
  }))
59
59
 
60
- const type = findOptions(value, options?.eventsType || []) || "-";
60
+ const type = (value === 'other' ? t(value) : findOptions(value, options?.eventsType || [])) || "-";
61
61
 
62
62
  return <Tooltip title={type}>{type}</Tooltip>;
63
63
  },
@@ -37,12 +37,6 @@ export default function EventsTable({
37
37
  const [selectedEvents, setSelectedEvents] = useState([]);
38
38
  const { token } = useToken();
39
39
 
40
- const transformedParams = useGetParams({location});
41
-
42
- const getDataWithStringPagination = async () => {
43
- return getData({ params: transformedParams });
44
- };
45
-
46
40
  const {
47
41
  filter,
48
42
  activeTab,
@@ -62,7 +56,7 @@ export default function EventsTable({
62
56
  defaultPageSize,
63
57
  filtersConfig,
64
58
  getRedirectLink,
65
- getData: getDataWithStringPagination,
59
+ getData: getData,
66
60
  refetchTrigger,
67
61
  });
68
62
 
@@ -42,12 +42,6 @@ export default function LocationTable({
42
42
  const { token } = useToken();
43
43
  const [isCombineModalOpen, setIsModalOpen] = useState(false);
44
44
 
45
- const transformedParams = useGetParams({location});
46
-
47
- const getDataWithStringPagination = async () => {
48
- return getData({ params: transformedParams });
49
- };
50
-
51
45
  const {
52
46
  filter,
53
47
  activeTab,
@@ -67,7 +61,7 @@ export default function LocationTable({
67
61
  defaultPageSize,
68
62
  filtersConfig,
69
63
  getRedirectLink,
70
- getData: getDataWithStringPagination,
64
+ getData: getData,
71
65
  refetchTrigger,
72
66
  });
73
67
 
@@ -39,12 +39,6 @@ export default function SubjectsTable({
39
39
  const [selectedSubjects, setSelectedSubjects] = useState([]);
40
40
  const { token } = useToken();
41
41
  const [isCombineModalOpen, setIsModalOpen] = useState(false);
42
- const transformedParams = useGetParams({location});
43
-
44
- const getDataWithStringPagination = async () => {
45
- return getData({ params: transformedParams });
46
- };
47
-
48
42
 
49
43
  const {
50
44
  filter,
@@ -65,7 +59,7 @@ export default function SubjectsTable({
65
59
  defaultPageSize,
66
60
  filtersConfig,
67
61
  getRedirectLink,
68
- getData: getDataWithStringPagination,
62
+ getData: getData,
69
63
  refetchTrigger,
70
64
  });
71
65
 
@@ -105,13 +105,21 @@ export const useGetParams = ({location}) => {
105
105
  Object.entries(searchParams).filter(([_, value]) => value != null && value !== '')
106
106
  );
107
107
 
108
- const hasPagination = paginationQuery.skip != null || paginationQuery.take != null;
108
+ const hasPagination = paginationQuery?.skip != null || paginationQuery?.take != null;
109
109
 
110
110
  const { activeTab, ...rest } = otherParams;
111
111
 
112
+ console.log({hasPagination})
113
+
112
114
  const params = useMemo(() => {
113
115
  if (!hasPagination) {
114
- return undefined;
116
+ return {
117
+ pagination: {
118
+ skip: 1,
119
+ take: 20,
120
+ },
121
+ tab: 'active'
122
+ };
115
123
  }
116
124
 
117
125
  return {
@@ -120,7 +128,7 @@ export const useGetParams = ({location}) => {
120
128
  ...(Object.keys(cleanSearchParams)?.length > 0 && { search: cleanSearchParams }),
121
129
  tab: activeTab,
122
130
  }
123
- }, [location.search, hasPagination, paginationQuery, rest, cleanSearchParams, activeTab]);
131
+ }, [location.search]);
124
132
 
125
133
  return params;
126
134
  }
@@ -141,7 +149,8 @@ export function useSubjectsAdminTable({
141
149
  const [initFetchDone, setInitFetchDone] = useState(false);
142
150
  const [loading, setLoading] = useState(false);
143
151
  const [data, setData] = useState([]);
144
-
152
+ const params = useGetParams({location});
153
+
145
154
  const filter = useFilters({
146
155
  goTo,
147
156
  location,
@@ -163,7 +172,7 @@ export function useSubjectsAdminTable({
163
172
  const fetchData = useCallback(async () => {
164
173
  try {
165
174
  setLoading(true);
166
- const { data } = await getData();
175
+ const { data } = await getData({ params });
167
176
  setData(data.data || data || []);
168
177
  filter.setPagination((prev) => ({ ...prev, total: data?.meta?.total || data?.length || 0 }));
169
178
  if (!initFetchDone) {
@@ -173,11 +182,11 @@ export function useSubjectsAdminTable({
173
182
  } catch (err) {
174
183
  console.log(err);
175
184
  }
176
- }, [filter.activeFilters, refetchTrigger]);
185
+ }, [params]);
177
186
 
178
187
  useEffect(() => {
179
188
  fetchData();
180
- }, [fetchData, refetchTrigger]);
189
+ }, [params, refetchTrigger]);
181
190
 
182
191
  return {
183
192
  filter,
@@ -165,7 +165,7 @@ export const getFilterOptions = (options, t) => {
165
165
  export const formConfig = {
166
166
  namespace: 'testimonials',
167
167
  view: 'testimonials',
168
- scope: 'create',
168
+ scope: 'createTestimonial',
169
169
  formType: 'testimonial',
170
170
  }
171
171
 
@@ -31,7 +31,7 @@ export const getFilterOptions = (options, t) => {
31
31
  export const formConfig = {
32
32
  namespace: 'conflict-areas',
33
33
  view: ['scoping', 'new'],
34
- scope: 'conflictAreaCreate',
34
+ scope: 'createConflictArea',
35
35
  formType: 'conflict-area',
36
36
  }
37
37
 
@@ -60,7 +60,7 @@ export const getFilterOptions = (options, t) => {
60
60
  export const formConfig = {
61
61
  namespace: 'armed-groups',
62
62
  view: ['scoping', 'new'],
63
- scope: 'global',
63
+ scope: 'createArmedGroup',
64
64
  formType: 'armed-group',
65
65
  }
66
66
 
@@ -20,21 +20,44 @@ const JobsTimeline = ({
20
20
  ? dayJobsTimeline
21
21
  : (dayJobsTimeline?.jobsTimeline || dayJobsTimeline?.jobs || dayJobsTimeline?.timeline || []);
22
22
 
23
+ // const jobsTimelineData = useMemo(() => {
24
+ // // Always process data, even if empty, to generate default date range for x-axis
25
+ // const dataToProcess = (!jobsData || !Array.isArray(jobsData) || jobsData.length === 0)
26
+ // ? []
27
+ // : jobsData;
28
+
29
+ // // Process data without cumulative calculation (for jobs timeline)
30
+ // // Try to find value in total, count, jobs, or value fields
31
+ // return processChartDateData({
32
+ // mainData: dataToProcess,
33
+ // isCumulative: false,
34
+ // valueField: 'total', // Will fallback to count/jobs/value if total doesn't exist
35
+ // });
36
+ // }, [jobsData, processChartDateData]);
37
+
23
38
  const jobsTimelineData = useMemo(() => {
24
- // Always process data, even if empty, to generate default date range for x-axis
25
- const dataToProcess = (!jobsData || !Array.isArray(jobsData) || jobsData.length === 0)
26
- ? []
39
+ // Prepare data first
40
+ const dataToProcess = (!jobsData || !Array.isArray(jobsData) || jobsData.length === 0)
41
+ ? []
27
42
  : jobsData;
28
-
29
- // Process data without cumulative calculation (for jobs timeline)
30
- // Try to find value in total, count, jobs, or value fields
31
- return processChartDateData({
43
+
44
+ // Process data without cumulative calculation
45
+ const processedData = processChartDateData({
32
46
  mainData: dataToProcess,
33
47
  isCumulative: false,
34
- valueField: 'total', // Will fallback to count/jobs/value if total doesn't exist
48
+ valueField: 'total', // fallback handled inside processChartDateData
35
49
  });
50
+
51
+ // Find last index with jobs > 0
52
+ let lastNonZeroIndex = processedData.length - 1;
53
+ while (lastNonZeroIndex >= 0 && (processedData[lastNonZeroIndex].jobs || 0) === 0) {
54
+ lastNonZeroIndex--;
55
+ }
56
+
57
+ // Slice up to last period with data
58
+ return processedData.slice(0, lastNonZeroIndex + 1);
36
59
  }, [jobsData, processChartDateData]);
37
-
60
+
38
61
  const maxYValue = useMemo(() => {
39
62
  if (!jobsTimelineData || jobsTimelineData.length === 0) {
40
63
  return 100;
@@ -1,3 +1,28 @@
1
+
2
+ // Custom tooltip labels per field/value
3
+ const FIELD_TOOLTIP_LABELS = {
4
+ aidKitAccessible: {
5
+ compliant: "Available",
6
+ notCompliant: "Not available",
7
+ empty: "No data",
8
+ },
9
+ hsTrainingConfirmation: {
10
+ compliant: "Training delivered",
11
+ notCompliant: "No training",
12
+ empty: "No data",
13
+ },
14
+ duosFormed: {
15
+ compliant: "Duos formed",
16
+ notCompliant: "Not implemented",
17
+ empty: "No data",
18
+ },
19
+ presenceOfChildren: {
20
+ compliant: "None reported",
21
+ notCompliant: "Children present",
22
+ empty: "No data",
23
+ },
24
+ };
25
+
1
26
  const HEALTH_SAFETY_COLORS = {
2
27
  compliant: '#016C6E',
3
28
  notCompliant: '#F97066',
@@ -11,11 +36,6 @@ const getIndicatorType = (value) => {
11
36
  return "empty";
12
37
  };
13
38
 
14
- /**
15
- * Gets health and safety distribution data from activity data
16
- * @param {Object} activityData - Activity data object
17
- * @returns {Object} Distribution object with compliant, notCompliant, and empty counts
18
- */
19
39
  export const getHealthAndSafetyDistributionData = (activityData) => {
20
40
  // Define health and safety indicator fields
21
41
  const indicators = [
@@ -42,23 +62,12 @@ export const getHealthAndSafetyDistributionData = (activityData) => {
42
62
  return distribution;
43
63
  };
44
64
 
45
- /**
46
- * Checks if the health and safety distribution data is empty
47
- * @param {Object} healthAndSafetyDistributionData - Distribution object
48
- * @returns {boolean} True if all values are 0 or empty
49
- */
50
65
  export const isHealthAndSafetyDistributionEmpty = (healthAndSafetyDistributionData) => {
51
66
  return Object.values(healthAndSafetyDistributionData).every(val => !val || val === 0);
52
67
  };
53
68
 
54
- /**
55
- * Calculates pie chart data from health and safety distribution
56
- * @param {Object} healthAndSafetyDistributionData - Distribution object
57
- * @param {Function} t - Translation function
58
- * @returns {Array} Array of pie chart data points with value, percent, color, label, and key
59
- */
60
- export const calculateHealthAndSafetyPieData = (healthAndSafetyDistributionData, t) => {
61
- const total = Object.values(healthAndSafetyDistributionData).reduce((all, val) => all + (val || 0), 0);
69
+ export const calculateHealthAndSafetyPieData = (data, t, selectedField) => {
70
+ const total = Object.values(data).reduce((a, v) => a + (v || 0), 0);
62
71
 
63
72
  const labels = {
64
73
  compliant: t("Available"),
@@ -66,31 +75,27 @@ export const calculateHealthAndSafetyPieData = (healthAndSafetyDistributionData,
66
75
  empty: t("Not answered"),
67
76
  };
68
77
 
69
- return Object.keys(healthAndSafetyDistributionData).map((key) => {
70
- const color = HEALTH_SAFETY_COLORS[key] || '#D9D9D9';
71
-
72
- return {
73
- value: healthAndSafetyDistributionData[key] || 0,
74
- percent: total > 0 ? (healthAndSafetyDistributionData[key] || 0) / total : 0,
75
- color: color,
76
- label: labels[key] || key,
77
- key: key,
78
- };
79
- });
78
+ return Object.keys(data).map((key) => ({
79
+ value: data[key] || 0,
80
+ percent: total > 0 ? (data[key] || 0) / total : 0,
81
+ color: HEALTH_SAFETY_COLORS[key] || '#D9D9D9',
82
+ label: labels[key] || key,
83
+ key,
84
+ keyOfField: selectedField, // <-- ADD THIS
85
+ }));
80
86
  };
81
87
 
82
- /**
83
- * Generates tooltip content for health and safety pie chart
84
- * Shows all statuses with their percentages
85
- * @param {Object} item - The pie chart item being hovered (not used, but kept for compatibility)
86
- * @param {boolean} isEmpty - Whether the distribution is empty
87
- * @param {Object} healthAndSafetyDistributionData - Distribution object
88
- * @param {Function} t - Translation function
89
- * @param {Function} renderTooltipJsx - Function to render tooltip JSX
90
- * @param {string} tooltipTitle - Title to display in the tooltip (defaults to "Health and Safety")
91
- * @returns {JSX.Element|null} Tooltip content or null
92
- */
93
- export const getHealthAndSafetyTooltipChildren = (item, isEmpty, healthAndSafetyDistributionData, t, renderTooltipJsx, tooltipTitle = "Health and Safety") => {
88
+
89
+ export const getHealthAndSafetyTooltipChildren = (
90
+ item,
91
+ isEmpty,
92
+ healthAndSafetyDistributionData,
93
+ t,
94
+ renderTooltipJsx,
95
+ tooltipTitle = "Health and Safety",
96
+ selectedField
97
+ ) => {
98
+
94
99
  // If empty or no data, return null to display nothing
95
100
  if (isEmpty || !Object.keys(healthAndSafetyDistributionData).length) {
96
101
  return null;
@@ -104,10 +109,10 @@ export const getHealthAndSafetyTooltipChildren = (item, isEmpty, healthAndSafety
104
109
  return null;
105
110
  }
106
111
 
107
- const labels = {
112
+ const labels = FIELD_TOOLTIP_LABELS[item?.keyOfField] || {
108
113
  compliant: t("Available"),
109
114
  notCompliant: t("Not available"),
110
- empty: t("Not answered"),
115
+ empty: t("No data"),
111
116
  };
112
117
 
113
118
  // Filter items with values > 0
@@ -54,7 +54,6 @@ const HealthAndSafety = ({
54
54
  getData: customGetData
55
55
  });
56
56
 
57
- // Process the fetched pie chart data
58
57
  // The API returns data in format: [{count: 1, [field]: "null"}, {count: 1, [field]: "no"}, {count: 1, [field]: "yes"}]
59
58
  const healthAndSafetyDistributionData = useMemo(() => {
60
59
  if (!pieChartData) return { compliant: 0, notCompliant: 0, empty: 0 };
@@ -90,7 +89,10 @@ const HealthAndSafety = ({
90
89
  }, [pieChartData, selectedField]);
91
90
 
92
91
  const isEmpty = useMemo(() => isHealthAndSafetyDistributionEmpty(healthAndSafetyDistributionData), [healthAndSafetyDistributionData]);
93
- const pieData = useMemo(() => calculateHealthAndSafetyPieData(healthAndSafetyDistributionData, t), [healthAndSafetyDistributionData, t]);
92
+ const pieData = useMemo(() =>
93
+ calculateHealthAndSafetyPieData(healthAndSafetyDistributionData, t, selectedField),
94
+ [healthAndSafetyDistributionData, t, selectedField]);
95
+
94
96
 
95
97
  // Get the label for the selected field to use as tooltip title
96
98
  const selectedFieldLabel = useMemo(() => {
@@ -99,7 +101,16 @@ const HealthAndSafety = ({
99
101
  }, [selectedField]);
100
102
 
101
103
  const getTooltipChildren = useCallback(
102
- (item) => getHealthAndSafetyTooltipChildren(item, isEmpty, healthAndSafetyDistributionData, t, renderTooltipJsx, selectedFieldLabel),
104
+ (item) =>
105
+ getHealthAndSafetyTooltipChildren(
106
+ item,
107
+ isEmpty,
108
+ healthAndSafetyDistributionData,
109
+ t,
110
+ renderTooltipJsx,
111
+ selectedFieldLabel,
112
+ selectedField
113
+ ),
103
114
  [t, isEmpty, healthAndSafetyDistributionData, selectedFieldLabel],
104
115
  );
105
116
 
@@ -110,8 +121,9 @@ const HealthAndSafety = ({
110
121
  return (
111
122
  <Widget
112
123
  loading={loading || pieChartLoading}
113
- title={<div>{t("Health and Safety")}</div>}
114
- className="with-border-header h-w-btn-header "
124
+ title={<div>{t("Operational Health & Safety")}</div>}
125
+ className="with-border-header h-w-btn-header"
126
+ description={t("Across all activities in this cycle.")}
115
127
  addedHeader={
116
128
  <>
117
129
  <div className="flex-1" />
@@ -15,21 +15,28 @@ const PlantingActivitiesTimeline = ({
15
15
  }) => {
16
16
  const { timeFilter, setTimeFilter, formatDateAxis, processChartDateData } = useTimeFilter({ defaultFilter: 'monthly' });
17
17
 
18
-
18
+
19
19
  const activitiesTimelineData = useMemo(() => {
20
20
  const dataToProcess = (!activitiesTimelineChart || !Array.isArray(activitiesTimelineChart) || activitiesTimelineChart.length === 0)
21
21
  ? []
22
22
  : activitiesTimelineChart;
23
-
23
+
24
24
  // Process data without cumulative calculation (for activities timeline)
25
- return processChartDateData({
25
+ const processedData = processChartDateData({
26
26
  mainData: dataToProcess,
27
27
  isCumulative: false,
28
28
  valueField: 'count',
29
29
  });
30
+
31
+ // Remove trailing periods with 0 jobs (optional: remove all zero if you prefer)
32
+ let lastNonZeroIndex = processedData.length - 1;
33
+ while (lastNonZeroIndex >= 0 && (processedData[lastNonZeroIndex].jobs || 0) === 0) {
34
+ lastNonZeroIndex--;
35
+ }
36
+
37
+ return processedData.slice(0, lastNonZeroIndex + 1);
30
38
  }, [activitiesTimelineChart, processChartDateData]);
31
-
32
- // Calculate max value for Y-axis (default to 100 if all values are 0 or very small)
39
+
33
40
  const maxActivitiesYValue = useMemo(() => {
34
41
  if (!activitiesTimelineData || activitiesTimelineData.length === 0) {
35
42
  return 100;
@@ -85,4 +85,9 @@ export const namespaceMap = {
85
85
  operators: "stakeholder",
86
86
  workers: "stakeholder",
87
87
  activities: "event",
88
+ "conflict-areas": "location",
89
+ "armed-groups": "stakeholder",
90
+ scl: "location",
91
+ testimonials: 'event',
92
+ 'corrective-actions': 'event',
88
93
  }
@@ -1,5 +1,26 @@
1
1
  import { useMemo, useEffect } from "react";
2
2
 
3
+ const evaluateRule = (rule, data) => {
4
+ if (typeof rule === "boolean") return rule;
5
+ if (typeof rule === "function") return rule();
6
+
7
+ if (typeof rule === "string") {
8
+ const parts = rule.split(" ");
9
+
10
+ // Expecting: "<field> <is|not> <value>"
11
+ if (parts.length === 3) {
12
+ const [field, condition, value] = parts;
13
+
14
+ if (condition === "is") return data?.[field] === value;
15
+ if (condition === "not") return data?.[field] !== value;
16
+ }
17
+ }
18
+
19
+ console.warn("Invalid rule:", rule);
20
+ return false;
21
+ };
22
+
23
+
3
24
  export const useViewPermissions = ({
4
25
  data,
5
26
  id,
@@ -17,7 +38,6 @@ export const useViewPermissions = ({
17
38
  viewConfig,
18
39
  }) => {
19
40
  const baseNamespaceKeys = Object.keys(namespaceConfig || {});
20
- console.log({namespaceConfig})
21
41
 
22
42
  const baseSupportedNamespaces = baseNamespaceKeys?.reduce((acc, key) => {
23
43
  acc[key] = () => true;
@@ -54,7 +74,8 @@ export const useViewPermissions = ({
54
74
  ...namespaceOverrides.canEdit,
55
75
  };
56
76
 
57
- return canEditAction[namespace] ? canEditAction[namespace]() : false;
77
+ const rule = canEditAction[namespace] ? canEditAction[namespace]() : false;
78
+ return evaluateRule(rule, data);
58
79
  }, [namespace, data, user]);
59
80
 
60
81
  const canDelete = useMemo(() => {
@@ -67,7 +88,8 @@ export const useViewPermissions = ({
67
88
  ...namespaceOverrides.canDelete,
68
89
  };
69
90
 
70
- return canDeleteAction[namespace] ? canDeleteAction[namespace]() : false;
91
+ const rule = canDeleteAction[namespace] ? canDeleteAction[namespace]() : false;
92
+ return evaluateRule(rule, data);
71
93
  }, [namespace, data, user, namespaceOverrides])
72
94
 
73
95
  useEffect(() => {
@@ -51,14 +51,10 @@ const View = ({
51
51
  options,
52
52
  getSubjectsDetails,
53
53
  namespaceOverrides,
54
- // ADD CALLBACK TO GET THE CURRENT NAMESPACE CONFIG
55
54
  }) => {
56
55
  const getNamespaceConfig = (namespace) => namespaceConfiguration?.[namespace] || {};
57
56
  const [openRecordsModal, setOpenRecordsModal] = useState(false);
58
-
59
- console.log({partners})
60
57
 
61
- // HANDLES THE URL PARAMS FOR THE VIEW PAGE
62
58
  const {
63
59
  namespace,
64
60
  id,
@@ -85,7 +81,6 @@ const View = ({
85
81
 
86
82
  const namespaceConfig = useMemo(() => getNamespaceConfig(namespace), [namespace]);
87
83
 
88
- // PREPARES THE FORM FOR THE VIEW PAGE
89
84
  const {
90
85
  form,
91
86
  data,
@@ -139,6 +134,8 @@ const View = ({
139
134
  const subjects = {
140
135
  "management-location": "location",
141
136
  "management-stakeholder": "stakeholder",
137
+ "management-event": "event",
138
+ "management-incident": "incident",
142
139
  }
143
140
 
144
141
 
@@ -149,7 +146,7 @@ const View = ({
149
146
  id: id,
150
147
  });
151
148
  message.success(t("Subject deleted successfully"));
152
- push(getRedirectLink(`/app/management/subject/${subjects[namespace]}`));
149
+ // push(getRedirectLink(`/app/management/subject/${subjects[namespace]}`));
153
150
  } catch (error) {
154
151
  handleError(error);
155
152
  message.error(t("Failed to delete subject"));
@@ -234,9 +234,8 @@ class AdminService extends BaseService {
234
234
  }
235
235
 
236
236
  deleteSubject({ subject, id }) {
237
- const type = subject === 'location' ? 'location' : 'stakeholder';
238
237
  return this.apiDelete({
239
- url: `/management/subject/${type}/${id}`,
238
+ url: `/management/subject/${subject}/${id}`,
240
239
  });
241
240
  }
242
241
 
@@ -467,7 +467,7 @@ const sp = {
467
467
  "unlinkData": "¿Está seguro de que desea eliminar este enlace?",
468
468
  "Link": "Enlace",
469
469
  "riskMitigationMeasures": "Medidas de mitigación del riesgo",
470
- "other": "Otros",
470
+ "other": "Otro",
471
471
  "Reset": "Restablecer",
472
472
  "Lir Details": "Detalles LIR",
473
473
  "Locations": "Ubicaciones",