datastake-daf 0.6.846 → 0.6.847

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 (34) hide show
  1. package/build/favicon.ico +0 -0
  2. package/build/logo192.png +0 -0
  3. package/build/logo512.png +0 -0
  4. package/build/manifest.json +25 -0
  5. package/build/robots.txt +3 -0
  6. package/dist/components/index.js +58 -16
  7. package/dist/hooks/index.js +10 -12
  8. package/dist/pages/index.js +4543 -4120
  9. package/dist/style/datastake/mapbox-gl.css +330 -0
  10. package/dist/utils/index.js +1 -9
  11. package/package.json +1 -1
  12. package/src/@daf/core/components/Screens/Admin/AdminModals/NewUser/index.jsx +1 -1
  13. package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/helper.js +77 -59
  14. package/src/@daf/core/components/Screens/Admin/AdminViews/index.jsx +8 -1
  15. package/src/@daf/hooks/useSources.js +4 -6
  16. package/src/@daf/hooks/useWidgetFetch.js +40 -34
  17. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/IncidentsTime/config.js +0 -3
  18. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/IncidentsTime/hook.js +4 -69
  19. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/IncidentsTime/index.js +92 -29
  20. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/ProblemSolver/hook.js +34 -59
  21. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/ProblemSolver/index.js +69 -36
  22. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/TerritorialDistribution/index.js +75 -50
  23. package/src/@daf/pages/Dashboards/ConflictManagement/index.js +11 -11
  24. package/src/@daf/pages/Dashboards/SupplyChain/components/ChartsContainer/components/GenderDistribution/index.js +51 -46
  25. package/src/@daf/pages/Dashboards/SupplyChain/components/ChartsContainer/components/Identification/hook.js +20 -20
  26. package/src/@daf/pages/Dashboards/SupplyChain/components/ChartsContainer/components/Identification/index.js +2 -26
  27. package/src/@daf/pages/Dashboards/SupplyChain/index.jsx +1 -0
  28. package/src/@daf/pages/Dashboards/UserDashboard/components/DataChainOfCustody/index.jsx +1 -2
  29. package/src/@daf/pages/Dashboards/UserDashboard/index.jsx +0 -1
  30. package/src/@daf/pages/Dashboards/helper.js +20 -25
  31. package/src/@daf/utils/timeFilterUtils.js +250 -233
  32. package/src/constants/locales/fr/translation.js +0 -9
  33. package/src/constants/locales/sp/translation.js +0 -1
  34. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/TerritorialDistribution/hook.js +0 -56
@@ -0,0 +1,330 @@
1
+ /* Isolated Mapbox GL CSS - Scoped to prevent Leaflet conflicts */
2
+
3
+ /* Mapbox GL Core Styles - Scoped with .mapbox-gl-scope */
4
+ .mapbox-gl-scope .mapboxgl-map {
5
+ font: 12px/20px Helvetica Neue, Arial, Helvetica, sans-serif;
6
+ overflow: hidden;
7
+ position: relative;
8
+ -webkit-tap-highlight-color: rgb(0 0 0/0);
9
+ }
10
+
11
+ .mapbox-gl-scope .mapboxgl-canvas {
12
+ left: 0;
13
+ position: absolute;
14
+ top: 0;
15
+ }
16
+
17
+ .mapbox-gl-scope .mapboxgl-map:-webkit-full-screen {
18
+ height: 100%;
19
+ width: 100%;
20
+ }
21
+
22
+ .mapbox-gl-scope .mapboxgl-canary {
23
+ background-color: salmon;
24
+ }
25
+
26
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-interactive,
27
+ .mapbox-gl-scope .mapboxgl-ctrl-group button.mapboxgl-ctrl-compass {
28
+ cursor: grab;
29
+ -webkit-user-select: none;
30
+ user-select: none;
31
+ }
32
+
33
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-interactive.mapboxgl-track-pointer {
34
+ cursor: pointer;
35
+ }
36
+
37
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-interactive:active,
38
+ .mapbox-gl-scope .mapboxgl-ctrl-group button.mapboxgl-ctrl-compass:active {
39
+ cursor: grabbing;
40
+ }
41
+
42
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate,
43
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate .mapboxgl-canvas {
44
+ touch-action: pan-x pan-y;
45
+ }
46
+
47
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-touch-drag-pan,
48
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-touch-drag-pan .mapboxgl-canvas {
49
+ touch-action: pinch-zoom;
50
+ }
51
+
52
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate.mapboxgl-touch-drag-pan,
53
+ .mapbox-gl-scope .mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate.mapboxgl-touch-drag-pan .mapboxgl-canvas {
54
+ touch-action: none;
55
+ }
56
+
57
+ /* Control positioning */
58
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom,
59
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom-left,
60
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom-right,
61
+ .mapbox-gl-scope .mapboxgl-ctrl-left,
62
+ .mapbox-gl-scope .mapboxgl-ctrl-right,
63
+ .mapbox-gl-scope .mapboxgl-ctrl-top,
64
+ .mapbox-gl-scope .mapboxgl-ctrl-top-left,
65
+ .mapbox-gl-scope .mapboxgl-ctrl-top-right {
66
+ pointer-events: none;
67
+ position: absolute;
68
+ z-index: 2;
69
+ }
70
+
71
+ .mapbox-gl-scope .mapboxgl-ctrl-top-left {
72
+ left: 0;
73
+ top: 0;
74
+ }
75
+
76
+ .mapbox-gl-scope .mapboxgl-ctrl-top {
77
+ left: 50%;
78
+ top: 0;
79
+ transform: translateX(-50%);
80
+ }
81
+
82
+ .mapbox-gl-scope .mapboxgl-ctrl-top-right {
83
+ right: 0;
84
+ top: 0;
85
+ }
86
+
87
+ .mapbox-gl-scope .mapboxgl-ctrl-right {
88
+ right: 0;
89
+ top: 50%;
90
+ transform: translateY(-50%);
91
+ }
92
+
93
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom-right {
94
+ bottom: 0;
95
+ right: 0;
96
+ }
97
+
98
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom {
99
+ bottom: 0;
100
+ left: 50%;
101
+ transform: translateX(-50%);
102
+ }
103
+
104
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom-left {
105
+ bottom: 0;
106
+ left: 0;
107
+ }
108
+
109
+ .mapbox-gl-scope .mapboxgl-ctrl-left {
110
+ left: 0;
111
+ top: 50%;
112
+ transform: translateY(-50%);
113
+ }
114
+
115
+ .mapbox-gl-scope .mapboxgl-ctrl {
116
+ clear: both;
117
+ pointer-events: auto;
118
+ transform: translate(0);
119
+ }
120
+
121
+ .mapbox-gl-scope .mapboxgl-ctrl-top-left .mapboxgl-ctrl {
122
+ float: left;
123
+ margin: 10px 0 0 10px;
124
+ }
125
+
126
+ .mapbox-gl-scope .mapboxgl-ctrl-top .mapboxgl-ctrl {
127
+ float: left;
128
+ margin: 10px 0;
129
+ }
130
+
131
+ .mapbox-gl-scope .mapboxgl-ctrl-top-right .mapboxgl-ctrl {
132
+ float: right;
133
+ margin: 10px 10px 0 0;
134
+ }
135
+
136
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom-right .mapboxgl-ctrl,
137
+ .mapbox-gl-scope .mapboxgl-ctrl-right .mapboxgl-ctrl {
138
+ float: right;
139
+ margin: 0 10px 10px 0;
140
+ }
141
+
142
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom .mapboxgl-ctrl {
143
+ float: left;
144
+ margin: 10px 0;
145
+ }
146
+
147
+ .mapbox-gl-scope .mapboxgl-ctrl-bottom-left .mapboxgl-ctrl,
148
+ .mapbox-gl-scope .mapboxgl-ctrl-left .mapboxgl-ctrl {
149
+ float: left;
150
+ margin: 0 0 10px 10px;
151
+ }
152
+
153
+ /* Control group styling */
154
+ .mapbox-gl-scope .mapboxgl-ctrl-group {
155
+ background: #fff;
156
+ border-radius: 4px;
157
+ }
158
+
159
+ .mapbox-gl-scope .mapboxgl-ctrl-group:not(:empty) {
160
+ box-shadow: 0 0 0 2px #0000001a;
161
+ }
162
+
163
+ .mapbox-gl-scope .mapboxgl-ctrl-group button {
164
+ background-color: initial;
165
+ border: 0;
166
+ box-sizing: border-box;
167
+ cursor: pointer;
168
+ display: block;
169
+ height: 29px;
170
+ outline: none;
171
+ overflow: hidden;
172
+ padding: 0;
173
+ width: 29px;
174
+ }
175
+
176
+ .mapbox-gl-scope .mapboxgl-ctrl-group button+button {
177
+ border-top: 1px solid #ddd;
178
+ }
179
+
180
+ .mapbox-gl-scope .mapboxgl-ctrl button .mapboxgl-ctrl-icon {
181
+ background-position: 50%;
182
+ background-repeat: no-repeat;
183
+ display: block;
184
+ height: 100%;
185
+ width: 100%;
186
+ }
187
+
188
+ .mapbox-gl-scope .mapboxgl-ctrl-attrib-button:focus,
189
+ .mapbox-gl-scope .mapboxgl-ctrl-group button:focus {
190
+ box-shadow: 0 0 2px 2px #0096ff;
191
+ }
192
+
193
+ .mapbox-gl-scope .mapboxgl-ctrl button:disabled {
194
+ cursor: not-allowed;
195
+ }
196
+
197
+ .mapbox-gl-scope .mapboxgl-ctrl button:disabled .mapboxgl-ctrl-icon {
198
+ opacity: .25;
199
+ }
200
+
201
+ .mapbox-gl-scope .mapboxgl-ctrl-group button:first-child {
202
+ border-radius: 4px 4px 0 0;
203
+ }
204
+
205
+ .mapbox-gl-scope .mapboxgl-ctrl-group button:last-child {
206
+ border-radius: 0 0 4px 4px;
207
+ }
208
+
209
+ .mapbox-gl-scope .mapboxgl-ctrl-group button:only-child {
210
+ border-radius: inherit;
211
+ }
212
+
213
+ .mapbox-gl-scope .mapboxgl-ctrl button:not(:disabled):hover {
214
+ background-color: #0000000d;
215
+ }
216
+
217
+ /* Marker styles */
218
+ .mapbox-gl-scope .mapboxgl-marker {
219
+ position: absolute;
220
+ z-index: 1;
221
+ }
222
+
223
+ .mapbox-gl-scope .mapboxgl-marker svg {
224
+ display: block;
225
+ }
226
+
227
+ /* Popup styles */
228
+ .mapbox-gl-scope .mapboxgl-popup {
229
+ position: absolute;
230
+ text-align: center;
231
+ margin-bottom: 20px;
232
+ }
233
+
234
+ .mapbox-gl-scope .mapboxgl-popup-content-wrapper {
235
+ padding: 1px;
236
+ text-align: left;
237
+ border-radius: 12px;
238
+ }
239
+
240
+ .mapbox-gl-scope .mapboxgl-popup-content {
241
+ margin: 13px 24px 13px 20px;
242
+ line-height: 1.3;
243
+ font-size: 13px;
244
+ min-height: 1px;
245
+ }
246
+
247
+ .mapbox-gl-scope .mapboxgl-popup-content p {
248
+ margin: 17px 0;
249
+ }
250
+
251
+ .mapbox-gl-scope .mapboxgl-popup-tip-container {
252
+ width: 40px;
253
+ height: 20px;
254
+ position: absolute;
255
+ left: 50%;
256
+ margin-top: -1px;
257
+ margin-left: -20px;
258
+ overflow: hidden;
259
+ pointer-events: none;
260
+ }
261
+
262
+ .mapbox-gl-scope .mapboxgl-popup-tip {
263
+ width: 17px;
264
+ height: 17px;
265
+ padding: 1px;
266
+ margin: -10px auto 0;
267
+ pointer-events: auto;
268
+ -webkit-transform: rotate(45deg);
269
+ -moz-transform: rotate(45deg);
270
+ -ms-transform: rotate(45deg);
271
+ transform: rotate(45deg);
272
+ }
273
+
274
+ .mapbox-gl-scope .mapboxgl-popup-content-wrapper,
275
+ .mapbox-gl-scope .mapboxgl-popup-tip {
276
+ background: white;
277
+ color: #333;
278
+ box-shadow: 0 3px 14px rgba(0, 0, 0, 0.4);
279
+ }
280
+
281
+ .mapbox-gl-scope .mapboxgl-popup-close-button {
282
+ position: absolute;
283
+ top: 0;
284
+ right: 0;
285
+ border: none;
286
+ text-align: center;
287
+ width: 24px;
288
+ height: 24px;
289
+ font: 16px/24px Tahoma, Verdana, sans-serif;
290
+ color: #757575;
291
+ text-decoration: none;
292
+ background: transparent;
293
+ }
294
+
295
+ .mapbox-gl-scope .mapboxgl-popup-close-button:hover,
296
+ .mapbox-gl-scope .mapboxgl-popup-close-button:focus {
297
+ color: #585858;
298
+ }
299
+
300
+ /* Attribution */
301
+ .mapbox-gl-scope .mapboxgl-ctrl-attribution {
302
+ background: #fff;
303
+ background: rgba(255, 255, 255, 0.8);
304
+ margin: 0;
305
+ }
306
+
307
+ .mapbox-gl-scope .mapboxgl-ctrl-attribution,
308
+ .mapbox-gl-scope .mapboxgl-ctrl-scale-line {
309
+ padding: 0 5px;
310
+ color: #333;
311
+ line-height: 1.4;
312
+ }
313
+
314
+ .mapbox-gl-scope .mapboxgl-ctrl-attribution a {
315
+ text-decoration: none;
316
+ }
317
+
318
+ .mapbox-gl-scope .mapboxgl-ctrl-attribution a:hover,
319
+ .mapbox-gl-scope .mapboxgl-ctrl-attribution a:focus {
320
+ text-decoration: underline;
321
+ }
322
+
323
+ /* Hide attribution by default */
324
+ .mapbox-gl-scope .mapboxgl-ctrl-attribution {
325
+ display: none !important;
326
+ }
327
+
328
+ .mapbox-gl-scope .mapboxgl-ctrl-logo {
329
+ display: none !important;
330
+ }
@@ -9386,9 +9386,6 @@ const fr = {
9386
9386
  "under-development": "Under development",
9387
9387
  "under-development-description": "Our team is actively building this feature. It will be available in an upcoming release.",
9388
9388
  "Confirm new subject": "Confirmer nouveau sujet",
9389
- "registration": "Enregistrement",
9390
- "scrutiny": "Contrôle",
9391
- "Organisation Policies": "Politiques Organisationnelles",
9392
9389
  affirmations: {
9393
9390
  "subject-created-successfully": "Sujet créé avec succès.",
9394
9391
  "information-saved-successfully": "Information sauvegardée avec succès.",
@@ -11160,12 +11157,7 @@ const fr = {
11160
11157
  "date-added": "Date de Création",
11161
11158
  "last-active": "Dernière Activité",
11162
11159
  "key-indicators": "Indicateurs Clés"
11163
- },
11164
- "Armed Groups": "Groupes Armés",
11165
- "Identified Armed Groups": "Groupes Armés Identifiés",
11166
- "Reported Incidents": "Incidents Signalés",
11167
- "Conflict Map": "Carte des Conflits",
11168
- "Conflict Management": "Gestion des Conflits"
11160
+ }
11169
11161
  };
11170
11162
 
11171
11163
  const sp = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.846",
3
+ "version": "0.6.847",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -62,7 +62,7 @@ export default function NewUser({
62
62
  const localUserData = {
63
63
  ...apiPayload,
64
64
  status: 'pending',
65
- id: apiPayload.email,
65
+ id: apiPayload.email, // Add a unique ID for the table key
66
66
  // apps: {
67
67
  // [module]: {
68
68
  // role: val.role,
@@ -1,5 +1,6 @@
1
+ import React from "react";
1
2
  import moment from "moment";
2
- import { Tag, Tooltip } from "antd";
3
+ import { Tag, Tooltip, Checkbox } from "antd";
3
4
  import { findOptions } from "../../../../../../../helpers/StringHelper.js";
4
5
  import CustomIcon from "../../../../Icon/CustomIcon.jsx";
5
6
  import MoreMenu from "../../../../Table/MoreMenu/index.jsx";
@@ -31,35 +32,57 @@ export const getColumns = ({
31
32
  onResendInvitation = () => {},
32
33
  onCanelVerification = () => {},
33
34
  setAddAccountVisible = () => {},
34
-
35
+ setSelectedAccounts = () => {},
36
+ selectedAccounts = [],
35
37
  }) => {
36
38
  const cols = [
37
-
39
+ {
40
+ title: "",
41
+ dataIndex: "select",
42
+ key: "select",
43
+ width: 50,
44
+ active: true,
45
+ pending: true,
46
+ suspended: true,
47
+ show: true,
48
+ render: (v, all) => {
49
+ if (all.empty) {
50
+ return <div className="daf-default-cell" />;
51
+ }
52
+ return (
53
+ <Checkbox
54
+ onChange={() =>
55
+ setSelectedAccounts((prev) => {
56
+ const isSelected = prev.some((p) => p.userId === all.userId);
57
+ if (isSelected) {
58
+ return prev.filter((p) => p.userId !== all.userId);
59
+ }
60
+ return [...prev, all];
61
+ })
62
+ }
63
+ checked={selectedAccounts.some((p) => p.userId === all.userId)}
64
+ disabled={selectedAccounts.length >= 3 && !selectedAccounts.some((p) => p.userId === all.userId)}
65
+ />
66
+ );
67
+ },
68
+ },
38
69
  {
39
70
  title: t("ID"),
71
+ dataIndex: "userId",
40
72
  key: "userId",
41
- ellipsis: true,
42
- width: 160,
43
73
  active: true,
44
74
  pending: true,
45
75
  suspended: true,
46
- render: (_, all) => {
47
- if (all.empty) {
48
- return <div className="daf-default-cell" />;
49
- }
50
-
51
- const id =
52
- all.status === "pending"
53
- ? all.users?.[0]?.userId ??
54
- all.invitedUser?.userId ??
55
- all.datastakeId ??
56
- "--"
57
- : all.userId ?? "--";
58
-
59
- return <div className="daf-default-cell">{id}</div>;
76
+ ellipsis: true,
77
+ width: 160,
78
+ render: (v, all) => {
79
+ if (all.empty) {
80
+ return <div className="daf-default-cell" />;
81
+ }
82
+
83
+ return <div className="daf-default-cell">{v || "--"}</div>;
60
84
  },
61
- },
62
-
85
+ },
63
86
  {
64
87
  title: t("Name"),
65
88
  dataIndex: "name",
@@ -71,28 +94,25 @@ export const getColumns = ({
71
94
  suspended: true,
72
95
  },
73
96
  {
74
- title: t("Type"),
75
- key: "type",
76
- render: (_, all) => {
77
- if (all.empty) {
78
- return <div className="daf-default-cell" />;
79
- }
80
-
81
- const typeValue =
82
- all.status === "pending"
83
- ? all.type ?? all.otherData?.interface
84
- : all.apps?.[0]?.interface;
85
-
86
- return renderTypeTag({
87
- value: typeValue,
88
- label: findOptions(typeValue, selectOptions.type),
89
- });
97
+ title: t("type"),
98
+ dataIndex: "apps",
99
+ key: "apps",
100
+ render: (apps, all) => {
101
+ if (all.empty) {
102
+ return <div className="daf-default-cell" />;
103
+ }
104
+
105
+ const sbg = all?.interface ? all : (apps || []).find((a) => a.app === module);
106
+
107
+ return renderTypeTag({
108
+ value: sbg?.interface,
109
+ label: findOptions(sbg?.interface, selectOptions.type),
110
+ });
90
111
  },
91
112
  active: true,
92
113
  pending: true,
93
114
  suspended: true,
94
- },
95
-
115
+ },
96
116
  {
97
117
  title: t("Email"),
98
118
  dataIndex: "admin",
@@ -145,28 +165,26 @@ export const getColumns = ({
145
165
  pending: true,
146
166
  suspended: false,
147
167
  },
148
- {
149
- title: t("Email Verified"),
150
- dataIndex: "emailVerified",
151
- key: "emailVerified",
152
- render: (verified, all) => {
153
- if (all.empty) {
154
- return <div className="daf-default-cell" />;
155
- }
156
-
157
- const isVerified = all.users?.[0]?.emailVerified ?? verified ?? all.emailVerfied;
168
+ {
169
+ title: t("Email Verified"),
170
+ dataIndex: "emailVerified",
171
+ key: "emailVerified",
172
+ render: (verified, all) => {
173
+ if (all.empty) {
174
+ return <div className="daf-default-cell" />;
175
+ }
158
176
 
159
- return isVerified ? (
160
- <Tag color="green">{t("Yes")}</Tag>
161
- ) : (
162
- <Tag color="red">{t("No")}</Tag>
163
- );
177
+ return verified ? (
178
+ <Tag color="green">{t("Yes")}</Tag>
179
+ ) : (
180
+ <Tag color="red">{t("No")}</Tag>
181
+ );
182
+ },
183
+ ellipsis: false,
184
+ active: false,
185
+ pending: true,
186
+ suspended: false,
164
187
  },
165
- ellipsis: false,
166
- active: false,
167
- pending: true,
168
- suspended: false,
169
- },
170
188
  {
171
189
  title: t("Date"),
172
190
  dataIndex: "createdAt",
@@ -154,14 +154,21 @@ function AdminView({
154
154
 
155
155
  try {
156
156
  const { data} = await updateAccount({ id: editData.id, data: newData });
157
+ console.log({data})
157
158
 
158
-
159
+ console.log('Checking for pending users...', {
160
+ hasPendingUsers: pendingUsers.length > 0,
161
+ hasInviteFunction: !!inviteCompanyAccount,
162
+ pendingUsers: pendingUsers
163
+ });
159
164
 
160
165
  if (pendingUsers.length > 0 && inviteCompanyAccount) {
161
166
  console.log('Inviting pending users:', pendingUsers.length);
162
167
  for (const user of pendingUsers) {
163
168
  try {
164
169
  const { pendingCompanyId, status, ...userDataToInvite } = user;
170
+ console.log('Sending invitation for:', user.email, userDataToInvite);
171
+ // Use the standalone invite function, don't mix it with updateAccount
165
172
  // await inviteCompanyAccount({
166
173
  // companyId: editData.id,
167
174
  // data: {
@@ -1,7 +1,7 @@
1
1
  import { useEffect, useState } from "react";
2
2
  import SourceService from "../services/SourceService.js";
3
3
 
4
- export default function useSource({ user = {}, t = () => {}, getData = () => {}, id, stop }) {
4
+ export default function useSource({ user = {}, t = () => {}, getData = () => {}, id }) {
5
5
  const [loading, setLoading] = useState(true);
6
6
  const [partners, setPartners] = useState([]);
7
7
  const [selectedPartners, setSelectedPartners] = useState({ loading: true });
@@ -59,10 +59,8 @@ export default function useSource({ user = {}, t = () => {}, getData = () => {},
59
59
  }
60
60
  }
61
61
 
62
- if(!stop) {
63
- fetchPartners();
64
- }
65
- }, [user.language, id, stop]);
62
+ fetchPartners();
63
+ }, [user.language, id]);
66
64
 
67
65
  function handleSelectedPartnersChange(selected) {
68
66
  setSelectedPartners((prev) => ({
@@ -84,6 +82,7 @@ export default function useSource({ user = {}, t = () => {}, getData = () => {},
84
82
 
85
83
  export const useSources = ({type, id, user, t = () => {}, stop}) => {
86
84
  function getData(params) {
85
+ if(stop) return Promise.resolve({ data: [] });
87
86
  if(id !== undefined && id !== null) {
88
87
  return SourceService.getSources({type, id});
89
88
  } else {
@@ -96,7 +95,6 @@ export const useSources = ({type, id, user, t = () => {}, stop}) => {
96
95
  t,
97
96
  getData: getData,
98
97
  id,
99
- stop,
100
98
  });
101
99
 
102
100
  const informationSources = partners?.length > 0 ? partners?.length - 1 : 0;
@@ -2,6 +2,7 @@ import { useState, useEffect, useRef } from "react";
2
2
  import DashboardService from "../services/DashboardService.js";
3
3
  import { isErrorResponse, getErrorMessage } from "../../helpers/errorHandling.js";
4
4
  import { message } from "antd";
5
+
5
6
  // config: {
6
7
  // stop: boolean,
7
8
  // defaultData: object,
@@ -9,37 +10,42 @@ import { message } from "antd";
9
10
  // url: string
10
11
  // basePath: string,
11
12
  // }
12
- export const useWidgetFetch = ({config, getData = DashboardService.getWidget, onFetch = () => {}}) => {
13
- const { stop, defaultData, ...rest} = config;
14
- const [ data, setData ] = useState(defaultData || {});
15
- const [ loading, setLoading ] = useState(false);
16
-
17
- const fetchData = async () => {
18
- setLoading(true);
19
- try {
20
- const { data } = await getData(rest);
21
- setData(data);
22
- if (isErrorResponse(data)) {
23
- const errorMessage = getErrorMessage(data);
24
- message.error(errorMessage);
25
- return;
26
- }
27
- onFetch();
28
- } catch (err) {
29
- console.log(err);
30
- }finally {
31
- setLoading(false);
32
- }
33
- };
34
- useEffect(() => {
35
- if(!stop) {
36
- console.log('fetching data');
37
- fetchData();
38
- }
39
- }, [JSON.stringify(config), stop]);
40
- return {
41
- data,
42
- loading,
43
- setData,
44
- }
45
- }
13
+
14
+ export const useWidgetFetch = ({ config, getData = DashboardService.getWidget, onFetch = () => { } }) => {
15
+ const { stop, defaultData, ...rest } = config;
16
+ const [data, setData] = useState(defaultData || {});
17
+ const [loading, setLoading] = useState(false);
18
+
19
+ const fetchData = async () => {
20
+
21
+ setLoading(true);
22
+
23
+ try {
24
+ const { data } = await getData(rest);
25
+ setData(data || defaultData);
26
+ if (isErrorResponse(data)) {
27
+ const errorMessage = getErrorMessage(data);
28
+ message.error(errorMessage);
29
+ return;
30
+ }
31
+ onFetch();
32
+ } catch (err) {
33
+ console.log(err);
34
+ }
35
+
36
+ setLoading(false);
37
+ };
38
+
39
+
40
+ useEffect(() => {
41
+ if (!stop) {
42
+ fetchData();
43
+ }
44
+ }, [JSON.stringify(config), stop]);
45
+
46
+ return {
47
+ data,
48
+ loading,
49
+ setData,
50
+ }
51
+ }
@@ -204,6 +204,3 @@ export function useTimelineBase({ language, selectedRange }) {
204
204
  }
205
205
 
206
206
  export default useTimelineBase;
207
-
208
-
209
-