datastake-daf 0.6.763 → 0.6.765

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 (42) hide show
  1. package/dist/components/index.js +45 -19
  2. package/dist/hooks/index.js +1 -1
  3. package/dist/layouts/index.js +36 -11
  4. package/dist/pages/index.js +1974 -999
  5. package/dist/services/index.js +1 -21
  6. package/dist/style/datastake/mapbox-gl.css +330 -0
  7. package/package.json +1 -1
  8. package/src/@daf/core/components/Screens/TableScreen/TablePageWithTabs/index.jsx +9 -4
  9. package/src/@daf/core/components/Table/index.jsx +2 -2
  10. package/src/@daf/core/components/UI/KeyIndicatorNavigateLabel/index.jsx +29 -0
  11. package/src/@daf/hooks/useFilters.js +1 -1
  12. package/src/@daf/layouts/AppLayout/components/MobileDrawer/index.js +4 -2
  13. package/src/@daf/layouts/AppLayout/components/UserDropdown/index.js +23 -2
  14. package/src/@daf/layouts/AppLayout/index.jsx +2 -0
  15. package/src/@daf/pages/Dashboards/SupplyChain/components/ChartsContainer/components/GenderDistribution/config.js +7 -6
  16. package/src/@daf/pages/Dashboards/SupplyChain/components/ChartsContainer/components/GenderDistribution/index.js +2 -1
  17. package/src/@daf/pages/Dashboards/SupplyChain/components/KeyIndicators/config.js +29 -53
  18. package/src/@daf/pages/Dashboards/SupplyChain/index.jsx +2 -2
  19. package/src/@daf/pages/Dashboards/UserDashboard/components/KeyIndicators/config.js +36 -70
  20. package/src/@daf/pages/Documents/index.jsx +9 -13
  21. package/src/@daf/pages/Events/Activities/index.jsx +8 -21
  22. package/src/@daf/pages/Events/Incidents/index.jsx +8 -21
  23. package/src/@daf/pages/Events/index.jsx +8 -20
  24. package/src/@daf/pages/Locations/MineSite/index.jsx +8 -21
  25. package/src/@daf/pages/Locations/index.jsx +9 -12
  26. package/src/@daf/pages/Partners/columns.js +421 -0
  27. package/src/@daf/pages/Partners/config.js +32 -0
  28. package/src/@daf/pages/Partners/create.jsx +145 -0
  29. package/src/@daf/pages/Partners/edit.jsx +98 -0
  30. package/src/@daf/pages/Partners/hook.js +153 -0
  31. package/src/@daf/pages/Partners/index.jsx +233 -8
  32. package/src/@daf/pages/Stakeholders/Operators/index.jsx +8 -22
  33. package/src/@daf/pages/Stakeholders/Workers/index.jsx +8 -21
  34. package/src/@daf/pages/Stakeholders/index.jsx +9 -10
  35. package/src/@daf/pages/Summary/Activities/PlantingCycle/config.js +40 -0
  36. package/src/@daf/pages/Summary/Activities/PlantingCycle/helper.js +122 -0
  37. package/src/@daf/pages/Summary/Activities/PlantingCycle/index.jsx +46 -0
  38. package/src/@daf/pages/Summary/Activities/Restoration/config.js +1 -1
  39. package/src/@daf/pages/hook.js +34 -0
  40. package/src/@daf/services/PartnerService.js +1 -16
  41. package/src/index.js +1 -1
  42. package/src/pages.js +2 -0
@@ -0,0 +1,421 @@
1
+ import React from "react";
2
+ import { Modal, Popover, Tag, message } from "antd";
3
+ import MoreMenu from '../../core/components/Table/MoreMenu/index.jsx';
4
+ import TooltipIcon from '../../core/components/Icon/TooltipIcon.jsx';
5
+ import { findOptions, camelCaseToTitle } from '../../../helpers/StringHelper.js';
6
+ import { copyToClipboard } from '../../../helpers/copyToClipboard.js';
7
+ import { partnershipTypes, partnerTypes } from './config.js';
8
+
9
+ export const getColumns = ({
10
+ t,
11
+ accept,
12
+ decline,
13
+ suspend,
14
+ selectOptions = {},
15
+ resendInvite,
16
+ activate,
17
+ activeTab,
18
+ setOpen,
19
+ block,
20
+ }) => [
21
+ {
22
+ title: t("ID"),
23
+ dataIndex: "datastakeId",
24
+ key: "datastakeId",
25
+ ellipsis: true,
26
+ render: (v, all) => {
27
+ if (all.empty) {
28
+ return <div className="daf-default-cell" />;
29
+ }
30
+ // THE FALLBACK WAS DEPENDS BEFORE
31
+ return v || "-";
32
+ },
33
+ },
34
+ {
35
+ title: (
36
+ <div className="flex-row">
37
+ {t("Partner Type")}
38
+ <Popover
39
+ title={t("Partner Type")}
40
+ content={
41
+ <div className="max-w-250">
42
+ {t("Source: This partner shares information with your organisation.")}{" "}
43
+ <br />
44
+ <br />
45
+ {t("Client: This partner receives information from your organisation.")}
46
+ <br />
47
+ <br />
48
+ {t("Exchange: You share information with each other.")}
49
+ </div>
50
+ }
51
+ >
52
+ <div className="ml-2 flex flex-column justify-content-center">
53
+ <TooltipIcon fontSize={12} />
54
+ </div>
55
+ </Popover>
56
+ </div>
57
+ ),
58
+ dataIndex: "partnershipType",
59
+ key: "partnershipType",
60
+ ellipsis: true,
61
+ render: (val, all) => {
62
+ if (all.empty) {
63
+ return <div className="daf-default-cell" />;
64
+ }
65
+
66
+ return partnershipTypes.find((v) => v.value === val)?.label || val || "-";
67
+ },
68
+ },
69
+ {
70
+ title: <div className="flex-row">{t("Entity Type")}</div>,
71
+ dataIndex: "partnerType",
72
+ key: "partnerType",
73
+ ellipsis: true,
74
+ render: (val, all) => {
75
+ if (all.empty) {
76
+ return <div className="daf-default-cell" />;
77
+ }
78
+
79
+ return partnerTypes.find((v) => v.value === val)?.label || val || "-";
80
+ },
81
+ },
82
+ {
83
+ title: t("Name"),
84
+ dataIndex: "nickName",
85
+ key: "nickName",
86
+ ellipsis: true,
87
+ render: (v, all) => {
88
+ if (all.empty) {
89
+ return <div className="daf-default-cell" />;
90
+ }
91
+
92
+ return v || "-";
93
+ },
94
+ },
95
+ {
96
+ title: t("Email"),
97
+ dataIndex: "email",
98
+ key: "email",
99
+ ellipsis: true,
100
+ render: (v, all) => {
101
+ if (all.empty) {
102
+ return <div className="daf-default-cell" />;
103
+ }
104
+
105
+ return v || "-";
106
+ },
107
+ },
108
+ {
109
+ title: t("Category"),
110
+ dataIndex: "category",
111
+ key: "category",
112
+ ellipsis: true,
113
+ render: (v, all) => {
114
+ if (all.empty) {
115
+ return <div className="daf-default-cell" />;
116
+ }
117
+ return v ? findOptions(v, selectOptions?.category || []) : "-";
118
+ },
119
+ },
120
+ {
121
+ title: (
122
+ <div className="flex-row">
123
+ {t("Settings")}
124
+ <Popover
125
+ title={t("Settings")}
126
+ content={
127
+ <div className="max-w-250">
128
+ {t(
129
+ "Standard: information is licensed with citation and available without restriction.",
130
+ )}
131
+ <br />
132
+ <br />
133
+ {t(
134
+ "Custom: Information sharing settings have been adjusted by the Source as reflected in the corresponding Channel.",
135
+ )}
136
+ </div>
137
+ }
138
+ >
139
+ <div className="ml-2 flex flex-column justify-content-center">
140
+ <TooltipIcon fontSize={12} />
141
+ </div>
142
+ </Popover>
143
+ </div>
144
+ ),
145
+ dataIndex: "settings",
146
+ key: "settings",
147
+ ellipsis: true,
148
+ render: (v, all) => {
149
+ if (all.empty) {
150
+ return <div className="daf-default-cell" />;
151
+ }
152
+
153
+ return v ? t(camelCaseToTitle(v)) : "-";
154
+ },
155
+ },
156
+ {
157
+ title: (
158
+ <div className="flex-row">
159
+ {t("Status")}
160
+ <Popover
161
+ title={t("Status")}
162
+ content={
163
+ <div className="max-w-250">
164
+ {t(
165
+ "Information is shared in accordance with settings for partners designated as Active.",
166
+ )}
167
+ <br />
168
+ <br />
169
+ {t(
170
+ "Information sharing is suspended for partners designated as Inactive.",
171
+ )}
172
+ </div>
173
+ }
174
+ >
175
+ <div className="ml-2 flex flex-column justify-content-center">
176
+ <TooltipIcon fontSize={12} />
177
+ </div>
178
+ </Popover>
179
+ </div>
180
+ ),
181
+ dataIndex: "status",
182
+ key: "status",
183
+ // ellipsis: true,
184
+ // width: 150,
185
+ render: (val, all) => {
186
+ if (all.empty) {
187
+ return <div className="daf-default-cell" />;
188
+ }
189
+
190
+ switch (val) {
191
+ case "active":
192
+ return (
193
+ <Tag
194
+ color="green"
195
+ style={{
196
+ width: 100,
197
+ textAlign: "center",
198
+ }}
199
+ >
200
+ {t("Active")}
201
+ </Tag>
202
+ );
203
+ case "declined":
204
+ return (
205
+ <Tag
206
+ color="red"
207
+ style={{
208
+ width: 100,
209
+ textAlign: "center",
210
+ }}
211
+ >
212
+ {t("Declined")}
213
+ </Tag>
214
+ );
215
+ case "pending":
216
+ return (
217
+ <Tag
218
+ color="orange"
219
+ style={{
220
+ width: 100,
221
+ textAlign: "center",
222
+ }}
223
+ >
224
+ {t("Pending")}
225
+ </Tag>
226
+ );
227
+ case "blocked":
228
+ return (
229
+ <Tag
230
+ color="red-inverse"
231
+ style={{
232
+ width: 100,
233
+ textAlign: "center",
234
+ }}
235
+ >
236
+ {t("Blocked")}
237
+ </Tag>
238
+ );
239
+ case "suspended":
240
+ return (
241
+ <Tag
242
+ style={{
243
+ width: 100,
244
+ textAlign: "center",
245
+ }}
246
+ >
247
+ {t("Suspended")}
248
+ </Tag>
249
+ );
250
+ default:
251
+ return "-";
252
+ }
253
+ },
254
+ },
255
+ {
256
+ title: "",
257
+ dataIndex: "actions",
258
+ width: 60,
259
+ show: true,
260
+ key: "actions",
261
+ render: (_, val) => {
262
+ if (val.empty) {
263
+ return <div className="daf-default-cell" />;
264
+ }
265
+
266
+ let items = [];
267
+
268
+ if (activeTab === "requests") {
269
+ switch (val.status) {
270
+ case "declined":
271
+ items.push({
272
+ label: t("Block User"),
273
+ key: "block",
274
+ onClick: () =>
275
+ Modal.confirm({
276
+ title: t("Are you sure you want to block this user?"),
277
+ onOk: () => block(val.id),
278
+ cancelText: t("No"),
279
+ okText: t("Yes"),
280
+ closable: true,
281
+ }),
282
+ });
283
+ break;
284
+ case "pending":
285
+ items.push(
286
+ ...[
287
+ {
288
+ label: t("Approve"),
289
+ key: "approve",
290
+ onClick: () =>
291
+ Modal.confirm({
292
+ content: t(
293
+ "Are you sure you want to approve this request?",
294
+ ),
295
+ title: t("Approve"),
296
+ onOk: () => accept(val.id),
297
+ cancelText: t("No"),
298
+ okText: t("Yes"),
299
+ closable: true,
300
+ }),
301
+ },
302
+ {
303
+ label: t("Decline"),
304
+ key: "decline",
305
+ onClick: () =>
306
+ Modal.confirm({
307
+ title: t("Decline"),
308
+ content: t(
309
+ "Are you sure you want to decline this request?",
310
+ ),
311
+ onOk: () => decline(val.id),
312
+ cancelText: t("No"),
313
+ okText: t("Yes"),
314
+ closable: true,
315
+ }),
316
+ },
317
+ ],
318
+ );
319
+ break;
320
+ default:
321
+ }
322
+ } else {
323
+ switch (val.status) {
324
+ case "pending":
325
+ items.push({
326
+ label: t("Details"),
327
+ key: "edit",
328
+ onClick: () => setOpen(val),
329
+ });
330
+ items.push({
331
+ label: t("Suspend Partner"),
332
+ key: "suspend",
333
+ onClick: () =>
334
+ Modal.confirm({
335
+ title: t("Suspend Partner"),
336
+ content: t("Are you sure you want to suspend this partner?"),
337
+ onOk: () => suspend(val.id),
338
+ cancelText: t("No"),
339
+ okText: t("Yes"),
340
+ closable: true,
341
+ }),
342
+ });
343
+ items.push({
344
+ label: t("Copy Invitation Link"),
345
+ key: "copyInvitationLink",
346
+ disabled: !val.code,
347
+ onClick: () => {
348
+ const copyText = document.getElementById("myInput");
349
+ copyText.value = val.datastakeId
350
+ ? `${window.location.origin}/app-invitation?code=${val.code}`
351
+ : `${window.location.origin}/register?code=${val.code}`;
352
+ copyToClipboard("myInput");
353
+ message.info(t("Invitation link copied!"));
354
+ },
355
+ });
356
+ items.push({
357
+ label: t("Resend Invite"),
358
+ key: "resendInvite",
359
+ onClick: () =>
360
+ Modal.confirm({
361
+ title: t("Resend Invitation"),
362
+ content: t(
363
+ "Are you sure you want to invite this user again? This user will receive a new notification",
364
+ ),
365
+ onOk: () => resendInvite(val.id),
366
+ cancelText: t("No"),
367
+ okText: t("Yes"),
368
+ closable: true,
369
+ }),
370
+ });
371
+ break;
372
+ case "suspended":
373
+ items.push({
374
+ label: t("Details"),
375
+ key: "details",
376
+ onClick: () => setOpen(val),
377
+ });
378
+ items.push({
379
+ label: t("Activate Partner"),
380
+ key: "activate",
381
+ onClick: () =>
382
+ Modal.confirm({
383
+ title: t("Re-activate Partnership"),
384
+ content: t(
385
+ "Are you sure you want to re-activate this collaboration?",
386
+ ),
387
+ onOk: () => activate(val.id),
388
+ cancelText: t("No"),
389
+ okText: t("Yes"),
390
+ closable: true,
391
+ }),
392
+ });
393
+ break;
394
+ case "active":
395
+ items.push({
396
+ label: t("Details"),
397
+ key: "edit",
398
+ onClick: () => setOpen(val),
399
+ });
400
+ items.push({
401
+ label: t("Suspend Partner"),
402
+ key: "suspend",
403
+ onClick: () =>
404
+ Modal.confirm({
405
+ title: t("Suspend Partner"),
406
+ content: t("Are you sure you want to suspend this partner?"),
407
+ onOk: () => suspend(val.id),
408
+ cancelText: t("No"),
409
+ okText: t("Yes"),
410
+ closable: true,
411
+ }),
412
+ });
413
+ break;
414
+ default:
415
+ }
416
+ }
417
+
418
+ return <MoreMenu items={items} />;
419
+ },
420
+ },
421
+ ];
@@ -0,0 +1,32 @@
1
+ export const filtersConfig = {
2
+ name: "",
3
+ datastakeId: "",
4
+ };
5
+
6
+ export const selectFiltersConfig = {
7
+ category: {
8
+ type: "select",
9
+ label: "Category",
10
+ placeholder: (t) => `${t("Filter by")} ${t("Category").toLowerCase()}`,
11
+ style: { flex: 1 },
12
+ labelStyle: { flex: 1 },
13
+ getLabel: (option) => option.label,
14
+ getValue: (option) => option.value,
15
+ },
16
+ };
17
+
18
+ export const checkboxConfig = {
19
+ name: "Name",
20
+ datastakeId: "ID",
21
+ };
22
+
23
+ export const partnerTypes = [
24
+ { label: "Individual", value: "individual" },
25
+ { label: "Organisation", value: "organisation" },
26
+ ];
27
+
28
+ export const partnershipTypes = [
29
+ { label: "Source", value: "source" },
30
+ { label: "Client", value: "client" },
31
+ { label: "Exchange", value: "exchange" },
32
+ ];
@@ -0,0 +1,145 @@
1
+ import React, { useMemo } from 'react'
2
+ import { message } from 'antd';
3
+ import PartnerService from '../../services/PartnerService.js';
4
+ import DynamicForm from '../../core/components/DynamicForm/index.jsx';
5
+ import { partnershipTypes, partnerTypes } from './config.js';
6
+
7
+ const data = {};
8
+
9
+ const Create = ({
10
+ query,
11
+ goTo = () => {},
12
+ user,
13
+ t = () => {},
14
+ ajaxForms,
15
+ changeAjaxForms = () => {},
16
+ ajaxOptions,
17
+ changeAjaxOptions = () => {},
18
+ onClose = () => {},
19
+ fetchData = () => {},
20
+ APP,
21
+ getAppHeader = () => {},
22
+ getApiBaseUrl = () => {},
23
+ }) => {
24
+
25
+ const form = useMemo(
26
+ () => ({
27
+ identification: {
28
+ partnershipType: {
29
+ label: t("Type of partnership"),
30
+ type: "select",
31
+ position: 1,
32
+ dataId: "partnershipType",
33
+ tooltip: (
34
+ <div style={{ maxWidth: 296 }}>
35
+ {t("Source: This partner will share information with you.")}
36
+ <br />
37
+ {t("Client: You will share information with this partner.")}
38
+ <br />
39
+ {t("Exchange: You will both share information with each other.")}
40
+ </div>
41
+ ),
42
+ options: partnershipTypes.map((o) => ({ ...o, label: t(o.label) })),
43
+ rules: [{ required: true, message: "errors::field is required" }],
44
+ },
45
+ partnerType: {
46
+ label: t("Type of partner"),
47
+ type: "select",
48
+ position: 2,
49
+ dataId: "partnerType",
50
+ options: partnerTypes.map((o) => ({ ...o, label: t(o.label) })),
51
+ rules: [{ required: true, message: "errors::field is required" }],
52
+ },
53
+ nickName: {
54
+ label: {
55
+ "partnerType is individual": t("Person name"),
56
+ "partnerType is organisation": t("Organisation name"),
57
+ },
58
+ type: "text",
59
+ position: 3,
60
+ showIf: "partnerType notEmpty true",
61
+ dataId: "nickName",
62
+ rules: [{ required: true, message: "errors::field is required" }],
63
+ },
64
+ invitationType: {
65
+ label: t("Invitation type"),
66
+ type: "select",
67
+ position: 3,
68
+ dataId: "invitationType",
69
+ options: [
70
+ { label: "Email", value: "email" },
71
+ { label: "Application ID", value: "id" },
72
+ ],
73
+ rules: [{ required: true, message: "errors::field is required" }],
74
+ },
75
+ email: {
76
+ label: t("Email"),
77
+ type: "text",
78
+ position: 4,
79
+ showIf: "invitationType is email",
80
+ dataId: "email",
81
+ rules: [
82
+ { required: true, message: "errors::field is required" },
83
+ { type: "email", message: "errors::field must be email" },
84
+ ],
85
+ },
86
+ datastakeId: {
87
+ label: t("Application ID"),
88
+ type: "text",
89
+ position: 4,
90
+ showIf: "invitationType is id",
91
+ dataId: "datastakeId",
92
+ rules: [{ required: true, message: "errors::field is required" }],
93
+ },
94
+ partnerMessage: {
95
+ type: "message",
96
+ position: 4,
97
+ label: t(
98
+ "If the user you are inviting is part of an existing organisation, the invitation will be shared with the account administrator of that organisation.",
99
+ ),
100
+ showIf: "partnerType is individual",
101
+ dataId: "partnerMessage",
102
+ },
103
+ },
104
+ }),
105
+ [t],
106
+ );
107
+
108
+ const submit = async (data) => {
109
+ try {
110
+ const { form, ...rest } = data;
111
+ await PartnerService.create(rest);
112
+ fetchData();
113
+ onClose();
114
+ } catch (err) {
115
+ onClose();
116
+ message.error(t(err?.response?.data?.message || "Error occured"));
117
+ console.log(err);
118
+ }
119
+ };
120
+
121
+ return (
122
+ <DynamicForm
123
+ form={form}
124
+ data={data}
125
+ showSaveAndNext={false}
126
+ module={APP}
127
+ t={t}
128
+ isCreate
129
+ user={user}
130
+ ajaxForms={ajaxForms}
131
+ ajaxOptions={ajaxOptions}
132
+ getAppHeader={getAppHeader}
133
+ getApiBaseUrl={getApiBaseUrl}
134
+ changeAjaxOptions={changeAjaxOptions}
135
+ app={APP}
136
+ query={query}
137
+ goTo={() => {}}
138
+ changeAjaxForms={changeAjaxForms}
139
+ onCancel={onClose}
140
+ submit={submit}
141
+ />
142
+ )
143
+ }
144
+
145
+ export default Create
@@ -0,0 +1,98 @@
1
+ import React, { useState, useEffect } from 'react'
2
+ import { Form, Input, Select } from "antd";
3
+ import PartnerService from '../../services/PartnerService.js';
4
+ import Loading from '../../core/components/Loading/index.jsx';
5
+ import ProjectVisualisationFooter from '../../core/components/ProjectVisualisation/Footer.js';
6
+ import { partnershipTypes } from './config.js';
7
+ import { licensingOptions } from '../../core/components/DataStore/components/Settings/config.js';
8
+
9
+ const Edit = ({
10
+ partner,
11
+ onClose = () => { },
12
+ fetchData = () => { },
13
+ t = () => { },
14
+ }) => {
15
+ const [MainForm] = Form.useForm();
16
+ const [loading, setLoading] = useState(false);
17
+
18
+ useEffect(() => {
19
+ MainForm.setFieldsValue({ ...partner, licensing: 'no_citation' });
20
+ }, [partner]);
21
+
22
+ const onSubmit = async () => {
23
+ setLoading(true);
24
+
25
+ try {
26
+ const val = await MainForm.validateFields();
27
+ await PartnerService.update(partner.id, val);
28
+ onClose();
29
+ fetchData();
30
+ } catch (err) {
31
+ console.log(err);
32
+ }
33
+
34
+ setLoading(false);
35
+ };
36
+
37
+ return (
38
+ <div>
39
+ {loading ? <Loading /> : null}
40
+ <Form form={MainForm} layout="vertical">
41
+ <Form.Item
42
+ required
43
+ name="nickName"
44
+ rules={[{ required: true }]}
45
+ label={t('Name')}
46
+ >
47
+ <Input name="name" />
48
+ </Form.Item>
49
+
50
+ <Form.Item
51
+ required
52
+ name="partnershipType"
53
+ label={t('Partner Type')}
54
+ >
55
+ <Select>
56
+ {partnershipTypes.map((type) => (
57
+ <Select.Option key={type.value} value={type.value}>
58
+ {type.label}
59
+ </Select.Option>
60
+ ))}
61
+ </Select>
62
+ </Form.Item>
63
+
64
+ <Form.Item
65
+ required
66
+ name="email"
67
+ label={t('Email address')}
68
+ rules={[{ type: 'email', required: true }]}
69
+ >
70
+ <Input disabled />
71
+ </Form.Item>
72
+
73
+ <Form.Item
74
+ required
75
+ name="licensing"
76
+ label={t('Licensing')}
77
+ >
78
+ <Select disabled>
79
+ {licensingOptions.map((option) => (
80
+ <Select.Option key={option.value} value={option.value}>
81
+ {t(option.label)}
82
+ </Select.Option>
83
+ ))}
84
+ </Select>
85
+ </Form.Item>
86
+ </Form>
87
+
88
+ <ProjectVisualisationFooter
89
+ t={t}
90
+ loading={loading}
91
+ onClose={onClose}
92
+ onSubmit={onSubmit}
93
+ />
94
+ </div>
95
+ )
96
+ }
97
+
98
+ export default Edit