datastake-daf 0.6.774 → 0.6.776

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 (27) hide show
  1. package/dist/components/index.js +2583 -2504
  2. package/dist/hooks/index.js +0 -72
  3. package/dist/pages/index.js +1769 -835
  4. package/dist/style/datastake/mapbox-gl.css +330 -0
  5. package/dist/utils/index.js +0 -13
  6. package/package.json +1 -1
  7. package/src/@daf/core/components/Dashboard/Map/ChainIcon/Markers/StakeholderMarker.js +76 -8
  8. package/src/@daf/core/components/Dashboard/Map/ChainIcon/index.js +8 -116
  9. package/src/@daf/core/components/Dashboard/Map/ChainIcon/utils.js +17 -73
  10. package/src/@daf/core/components/Dashboard/Map/helper.js +0 -1
  11. package/src/@daf/core/components/Dashboard/Map/hook.js +29 -53
  12. package/src/@daf/core/components/Dashboard/Map/style.js +5 -20
  13. package/src/@daf/hooks/useTimeFilter.js +56 -0
  14. package/src/@daf/pages/Summary/Activities/PlantingCycle/components/AssociatedInformation/config.js +548 -0
  15. package/src/@daf/pages/Summary/Activities/PlantingCycle/components/AssociatedInformation/index.jsx +137 -24
  16. package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CommunityParticipation/JobsTimeline/index.jsx +33 -102
  17. package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleIndicators/HealthAndSafety/helper.js +8 -6
  18. package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleIndicators/HealthAndSafety/index.jsx +73 -4
  19. package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleIndicators/index.jsx +1 -1
  20. package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleOutcomes/PlantingActivitiesTimeline.jsx +148 -0
  21. package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleOutcomes/RestoredArea.jsx +150 -0
  22. package/src/@daf/pages/Summary/Activities/PlantingCycle/components/CycleOutcomes/index.jsx +11 -390
  23. package/src/@daf/pages/Summary/Activities/PlantingCycle/index.jsx +3 -4
  24. package/src/@daf/utils/object.js +1 -3
  25. package/src/@daf/utils/timeFilterUtils.js +226 -0
  26. package/src/hooks.js +1 -2
  27. package/src/utils.js +1 -1
@@ -0,0 +1,548 @@
1
+ import { Tooltip } from "antd";
2
+ import { MoreMenu , CustomIcon} from "../../../../../../../index";
3
+ import { renderDateFormatted } from "../../../../../../../helpers/Forms";
4
+ import { Avatar, Tag } from "antd";
5
+ import { convertDMS } from "../../../../../../../helpers/Map";
6
+ import { findOptions, capitalize } from "../../../../../../../helpers/StringHelper.js";
7
+ const ACTIVITIES_TAB = 'activities';
8
+ const PARTNERS_TAB = 'partners';
9
+ const INCIDENTS_TAB = 'incidents';
10
+
11
+ export const getColumns = ({
12
+ projectId,
13
+ t,
14
+ show = 'show',
15
+ navigate,
16
+ selectOptions,
17
+ view,
18
+ getRedirectLink,
19
+ activeTab = ACTIVITIES_TAB,
20
+
21
+ }) => {
22
+ const renderActions = (record, viewType = 'activities') => {
23
+ if (record.empty) {
24
+ return <div className="daf-default-cell" />;
25
+ }
26
+
27
+ if (!navigate || !getRedirectLink) {
28
+ return null;
29
+ }
30
+
31
+ const onClick = () => {
32
+ const link = `/app/view/${viewType}/${record.datastakeId}`;
33
+ navigate(getRedirectLink(link));
34
+ };
35
+
36
+ const menuItems = [
37
+ {
38
+ label: t("Details"),
39
+ key: "details",
40
+ onClick: onClick
41
+ }
42
+ ];
43
+
44
+ if (viewType === 'activities') {
45
+ menuItems.push({
46
+ label: t("Summary"),
47
+ key: "summary",
48
+ onClick: () => {
49
+ const link = `/app/projects/${record.projectId}/planting-cycles/summary/${record.datastakeId}`;
50
+ navigate(getRedirectLink(link));
51
+ }
52
+ });
53
+ }
54
+
55
+ return <MoreMenu items={menuItems} />;
56
+ };
57
+
58
+ if (activeTab === ACTIVITIES_TAB) {
59
+ return [
60
+ {
61
+ title: "",
62
+ dataIndex: 'image',
63
+ key: 'image',
64
+ active: true,
65
+ width: 80,
66
+ pending: true,
67
+ suspended: true,
68
+ ellipsis: true,
69
+ render: (v, all) => {
70
+ if (all.empty) {
71
+ return <div className="daf-default-cell" />;
72
+ }
73
+
74
+ const firstGroupPhoto = all?.groupPhotos?.[0];
75
+ const pictures = firstGroupPhoto?.pictures;
76
+ const firstPicture = Array.isArray(pictures) && pictures.length > 0 ? pictures[0] : null;
77
+ let imageUrl = firstPicture?.url;
78
+
79
+ const normalizeUrl = (url) => url?.endsWith(':') ? url.slice(0, -1) : url;
80
+ let normalizedUrl = imageUrl ? normalizeUrl(imageUrl.trim()) : null;
81
+
82
+ if (normalizedUrl && !normalizedUrl.startsWith('http://') && !normalizedUrl.startsWith('https://') && !normalizedUrl.startsWith('//')) {
83
+ if (normalizedUrl.startsWith('cdn.') || (normalizedUrl.includes('.') && !normalizedUrl.startsWith('/'))) {
84
+ normalizedUrl = `https://${normalizedUrl}`;
85
+ }
86
+ }
87
+
88
+ return (
89
+ <div className="daf-default-cell" style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
90
+ <div
91
+ style={{
92
+ width: 32,
93
+ height: 32,
94
+ borderWidth: '1px',
95
+ borderStyle: 'solid',
96
+ borderColor: '#E5E7EB',
97
+ borderRadius: '6px',
98
+ background: '#F9FAFB',
99
+ display: 'flex',
100
+ alignItems: 'center',
101
+ justifyContent: 'center',
102
+ overflow: 'hidden',
103
+ position: 'relative',
104
+ }}
105
+ >
106
+ {normalizedUrl && (
107
+ <img
108
+ src={normalizedUrl}
109
+ alt={all.name || 'Activity image'}
110
+ style={{
111
+ width: '100%',
112
+ height: '100%',
113
+ objectFit: 'cover',
114
+ borderRadius: '6px',
115
+ }}
116
+ onError={(e) => {
117
+ e.target.style.display = 'none';
118
+ }}
119
+ />
120
+ )}
121
+ </div>
122
+ </div>
123
+ );
124
+ }
125
+ },
126
+ {
127
+ title: t('ID'),
128
+ dataIndex: 'datastakeId',
129
+ key: 'datastakeId',
130
+ active: true,
131
+ pending: true,
132
+ suspended: true,
133
+ ellipsis: true,
134
+ render: (v, all) => {
135
+ if (all.empty) {
136
+ return <div className="daf-default-cell" />;
137
+ }
138
+ return (
139
+ <div className="daf-default-cell">
140
+ {all.datastakeId}
141
+ </div>
142
+ );
143
+ }
144
+ },
145
+ {
146
+ title: t("Title"),
147
+ dataIndex: "name",
148
+ key: "name",
149
+ ellipsis: true,
150
+ active: true,
151
+ pending: true,
152
+ suspended: true,
153
+ render: (value) => <Tooltip title={value}>{value}</Tooltip>,
154
+ },
155
+ {
156
+ title: t("Type"),
157
+ dataIndex: "type",
158
+ key: "type",
159
+ ellipsis: true,
160
+ active: true,
161
+ pending: true,
162
+ suspended: true,
163
+ render: (value, all) => {
164
+ if (all.empty) {
165
+ return <div className="daf-default-cell" />;
166
+ }
167
+ return <Tooltip title={value}>{capitalize(value) || '-'}</Tooltip>;
168
+ },
169
+ },
170
+ {
171
+ title: t("Location"),
172
+ dataIndex: "location",
173
+ key: "location",
174
+ ellipsis: true,
175
+ active: true,
176
+ pending: true,
177
+ width: 220,
178
+ suspended: true,
179
+ show: true,
180
+ render: (value, all) => {
181
+ if (all.empty) {
182
+ return <div className="daf-default-cell" />;
183
+ }
184
+
185
+ const location = all.location || value;
186
+ if (location && typeof location === 'object' && typeof location.latitude === 'number' && typeof location.longitude === 'number') {
187
+ const coordinates = convertDMS(location.latitude, location.longitude);
188
+ const iconColor = "#016C6E";
189
+
190
+ return (
191
+ <div style={{ display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'nowrap' }}>
192
+ <div style={{ display: 'flex', alignItems: 'center', gap: '4px' }}>
193
+ <CustomIcon
194
+ name="SpacingHeight"
195
+ width={14}
196
+ height={14}
197
+ fill={iconColor}
198
+ />
199
+ <span>{coordinates[0]}</span>
200
+ </div>
201
+
202
+ <div style={{ display: 'flex', alignItems: 'center', gap: '4px' }}>
203
+ <CustomIcon
204
+ name="SpacingWidth"
205
+ width={14}
206
+ height={14}
207
+ fill={iconColor}
208
+ />
209
+ <span>{coordinates[1]}</span>
210
+ </div>
211
+ </div>
212
+ );
213
+ }
214
+
215
+ let locationDisplay = '-';
216
+ if (all.project?.name || all.project?.title) {
217
+ locationDisplay = all.project?.name || all.project?.title;
218
+ } else if (location?.name) {
219
+ locationDisplay = location.name;
220
+ } else if (value && typeof value === 'string') {
221
+ locationDisplay = value;
222
+ }
223
+ return <Tooltip title={locationDisplay}>{locationDisplay}</Tooltip>
224
+ },
225
+ },
226
+ {
227
+ title: t("Implementer"),
228
+ dataIndex: "technicalPartner",
229
+ key: "implementer",
230
+ ellipsis: true,
231
+ show: true,
232
+ render: (value, all) => {
233
+ if (all.empty) {
234
+ return <div className="daf-default-cell" />;
235
+ }
236
+ const implementerName = all.technicalPartner || all.implementer?.name || all.implementer?.title || value || '-';
237
+ return <Tooltip title={implementerName}>{implementerName}</Tooltip>;
238
+ }
239
+ },
240
+ {
241
+ title: t("Status"),
242
+ dataIndex: "published",
243
+ key: "published",
244
+ ellipsis: false,
245
+ show: true,
246
+ render: (value, all) => {
247
+ if (all.empty) {
248
+ return <div className="daf-default-cell" />;
249
+ }
250
+ let statusDisplay = '-';
251
+ let color = 'default';
252
+ if (value !== undefined) {
253
+ statusDisplay = value ? t('Published') : t('Unpublished');
254
+ color = value ? 'green' : 'default';
255
+ }
256
+ return <Tag color={color} style={{ width: 100 }} className="text-center">
257
+ {t(statusDisplay)}
258
+ </Tag>
259
+ }
260
+ },
261
+ {
262
+ title: t("Date"),
263
+ dataIndex: "lastUpdated",
264
+ key: "lastUpdated",
265
+ ellipsis: true,
266
+ active: true,
267
+ pending: false,
268
+ suspended: true,
269
+ show: true,
270
+ render: (val, all) => {
271
+ if (all.empty) {
272
+ return <div className="daf-default-cell" />;
273
+ }
274
+ const title = renderDateFormatted(all.updatedAt || all.date, "DD MMM YYYY");
275
+ return <Tooltip title={title}>{title}</Tooltip>;
276
+ },
277
+ },
278
+ {
279
+ title: "",
280
+ dataIndex: "actions",
281
+ key: "actions",
282
+ width: 60,
283
+ render: (_, val) => {
284
+ if (val.empty) {
285
+ return <div className="daf-default-cell" />;
286
+ }
287
+
288
+ const items = [
289
+ {
290
+ key: "viewSummary",
291
+ label: t("Summary"),
292
+ onClick: () => {
293
+ const link = `/app/projects/${projectId}/restoration/summary/${val.datastakeId}`;
294
+ navigate(getRedirectLink(link));
295
+ }
296
+ },
297
+ {
298
+ key: "viewDetails",
299
+ label: t("Details"),
300
+ onClick: () => {
301
+ const link = `/app/projects/${projectId}/restoration/view/general/${val.datastakeId}/identification`;
302
+ navigate(getRedirectLink(link));
303
+ }
304
+ },
305
+ ];
306
+
307
+ return <MoreMenu items={items} />;
308
+ },
309
+ ellipsis: true,
310
+ },
311
+ ];
312
+ }
313
+
314
+ if (activeTab === PARTNERS_TAB) {
315
+ return [
316
+ {
317
+ title: t('ID'),
318
+ dataIndex: 'datastakeId',
319
+ key: 'datastakeId',
320
+ ellipsis: true,
321
+ width: 160,
322
+ render: (v, all) => {
323
+ if (all.empty) {
324
+ return <div className="daf-default-cell" />;
325
+ }
326
+ return <Tooltip title={v}>{v || '-'}</Tooltip>;
327
+ }
328
+ },
329
+ {
330
+ title: t("Name"),
331
+ dataIndex: "name",
332
+ key: "name",
333
+ ellipsis: true,
334
+ render: (value, all) => {
335
+ if (all.empty) {
336
+ return <div className="daf-default-cell" />;
337
+ }
338
+ const name = value || all.nickName || '-';
339
+ return <Tooltip title={name}>{name}</Tooltip>;
340
+ },
341
+ },
342
+ {
343
+ title: t("Category"),
344
+ dataIndex: "category",
345
+ key: "category",
346
+ ellipsis: true,
347
+ render: (value, all) => {
348
+ if (all.empty) {
349
+ return <div className="daf-default-cell" />;
350
+ }
351
+ return <Tooltip title={value}>{value || '-'}</Tooltip>;
352
+ },
353
+ },
354
+ {
355
+ title: t("Subcategory"),
356
+ dataIndex: "subcategory",
357
+ key: "subcategory",
358
+ ellipsis: true,
359
+ render: (value, all) => {
360
+ if (all.empty) {
361
+ return <div className="daf-default-cell" />;
362
+ }
363
+ return <Tooltip title={value}>{value || '-'}</Tooltip>;
364
+ },
365
+ },
366
+ {
367
+ title: t("Country"),
368
+ dataIndex: "country",
369
+ key: "country",
370
+ ellipsis: true,
371
+ render: (value, all) => {
372
+ if (all.empty) {
373
+ return <div className="daf-default-cell" />;
374
+ }
375
+
376
+ const title = findOptions(value, selectOptions?.country || []) || '-';
377
+
378
+ return <Tooltip title={title}>{title}</Tooltip>
379
+ },
380
+ },
381
+ {
382
+ title: t("Last Update"),
383
+ dataIndex: "lastUpdated",
384
+ key: "lastUpdated",
385
+ ellipsis: true,
386
+ render: (val, all) => {
387
+ if (all.empty) {
388
+ return <div className="daf-default-cell" />;
389
+ }
390
+ const title = renderDateFormatted(all.updatedAt || all.lastUpdated, "DD MMM YYYY");
391
+ return <Tooltip title={title}>{title}</Tooltip>;
392
+ },
393
+ },
394
+ {
395
+ title: t(''),
396
+ dataIndex: 'actions',
397
+ key: 'actions',
398
+ width: 60,
399
+ render: (_, record) => {
400
+ const onClick = () => {
401
+ const id = record.id;
402
+ const link = `/app/projects/${projectId}/implementation-partners/view/general/${record?.datastakeId}/identification`;
403
+ navigate(getRedirectLink(link));
404
+ }
405
+ return !record.empty ? (
406
+ <div className="cursor-pointer" onClick={onClick}>
407
+ <CustomIcon name="Link" width={16} height={16} color="#6C737F" />
408
+ </div>
409
+ ) : null;
410
+ },
411
+ active: true,
412
+ pending: true,
413
+ suspended: true,
414
+ },
415
+ ];
416
+ }
417
+
418
+ if (activeTab === INCIDENTS_TAB) {
419
+ return [
420
+ {
421
+ title: t('ID'),
422
+ dataIndex: 'datastakeId',
423
+ key: 'datastakeId',
424
+ ellipsis: true,
425
+ width: 160,
426
+ render: (v, all) => {
427
+ if (all.empty) {
428
+ return <div className="daf-default-cell" />;
429
+ }
430
+ return <Tooltip title={v}>{v}</Tooltip>;
431
+ }
432
+ },
433
+ {
434
+ title: t("Title"),
435
+ dataIndex: "name",
436
+ key: "name",
437
+ ellipsis: true,
438
+ render: (value) => <Tooltip title={value}>{value}</Tooltip>,
439
+ },
440
+ {
441
+ title: t("Date"),
442
+ dataIndex: "date",
443
+ key: "date",
444
+ ellipsis: true,
445
+ render: (val, all) => {
446
+ if (all.empty) {
447
+ return <div className="daf-default-cell" />;
448
+ }
449
+ const title = renderDateFormatted(all.date || all.updatedAt, "DD MMM YYYY");
450
+ return <Tooltip title={title}>{title}</Tooltip>;
451
+ },
452
+ },
453
+ {
454
+ title: t("Location"),
455
+ dataIndex: "location",
456
+ key: "location",
457
+ ellipsis: true,
458
+ render: (value, all) => {
459
+ if (all.empty) {
460
+ return <div className="daf-default-cell" />;
461
+ }
462
+ let locationDisplay = '-';
463
+ if (all.location?.name) {
464
+ locationDisplay = all.location.name;
465
+ } else if (all.mineSite?.name) {
466
+ locationDisplay = all.mineSite.name;
467
+ } else if (all.location && typeof all.location === 'object' && all.location.latitude && all.location.longitude) {
468
+ locationDisplay = `${all.location.latitude.toFixed(6)}, ${all.location.longitude.toFixed(6)}`;
469
+ } else if (value && typeof value === 'string') {
470
+ locationDisplay = value;
471
+ }
472
+ return <Tooltip title={locationDisplay}>{locationDisplay}</Tooltip>;
473
+ },
474
+ },
475
+ {
476
+ title: t("Province"),
477
+ dataIndex: "province",
478
+ key: "province",
479
+ ellipsis: true,
480
+ render: (value, all) => {
481
+ if (all.empty) {
482
+ return <div className="daf-default-cell" />;
483
+ }
484
+ let province = '-';
485
+ if (all.province) {
486
+ province = all.province;
487
+ } else if (all.location && typeof all.location === 'object' && all.location.administrativeLevel1) {
488
+ province = all.location.administrativeLevel1;
489
+ }
490
+ return <Tooltip title={province}>{province}</Tooltip>;
491
+ },
492
+ },
493
+ {
494
+ title: t("Territory"),
495
+ dataIndex: "territory",
496
+ key: "territory",
497
+ ellipsis: true,
498
+ render: (value, all) => {
499
+ if (all.empty) {
500
+ return <div className="daf-default-cell" />;
501
+ }
502
+ let territory = '-';
503
+ if (all.territory) {
504
+ territory = all.territory;
505
+ } else if (all.location && typeof all.location === 'object' && all.location.administrativeLevel2) {
506
+ territory = all.location.administrativeLevel2;
507
+ }
508
+ return <Tooltip title={territory}>{territory}</Tooltip>;
509
+ },
510
+ },
511
+ {
512
+ title: t("Category"),
513
+ dataIndex: "category",
514
+ key: "category",
515
+ ellipsis: true,
516
+ render: (value, all) => {
517
+ if (all.empty) {
518
+ return <div className="daf-default-cell" />;
519
+ }
520
+ const category = all.eventCategory || all.category || value || '-';
521
+ return <Tooltip title={category}>{category}</Tooltip>;
522
+ },
523
+ },
524
+ {
525
+ title: t(''),
526
+ dataIndex: 'actions',
527
+ key: 'actions',
528
+ width: 60,
529
+ render: (_, record) => {
530
+ const onClick = () => {
531
+ const link = `/app/projects/${projectId}/implementation-partners/view/general/${record.datastakeId}/identification`;
532
+ getRedirectLink(link);
533
+ }
534
+ return !record.empty ? (
535
+ <div className="cursor-pointer" onClick={onClick}>
536
+ <CustomIcon name="Link" width={16} height={16} color="#6C737F" />
537
+ </div>
538
+ ) : null;
539
+ },
540
+ active: true,
541
+ pending: true,
542
+ suspended: true,
543
+ },
544
+ ];
545
+ }
546
+
547
+ return [];
548
+ }