datastake-daf 0.6.745 → 0.6.747

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 (91) 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 +71 -7
  7. package/dist/hooks/index.js +2 -2
  8. package/dist/pages/index.css +1 -0
  9. package/dist/pages/index.js +5924 -32
  10. package/dist/services/index.js +23 -1
  11. package/package.json +1 -1
  12. package/src/@daf/core/components/Dashboard/Widget/ImageCarousel/index.jsx +75 -54
  13. package/src/@daf/core/components/Dashboard/Widget/ImageCarousel/style.js +44 -0
  14. package/src/@daf/core/components/Screens/TableScreen/TablePageWithTabs/index.jsx +128 -0
  15. package/src/@daf/{pages/pages → core/components/TableScreen}/TablePageWithTabs/index.jsx +3 -3
  16. package/src/@daf/hooks/useSources.js +1 -1
  17. package/src/@daf/pages/Documents/index.jsx +1 -1
  18. package/src/@daf/pages/Events/Activities/index.jsx +1 -1
  19. package/src/@daf/pages/Events/Incidents/index.jsx +1 -1
  20. package/src/@daf/pages/Events/index.jsx +1 -1
  21. package/src/@daf/pages/Locations/MineSite/index.jsx +1 -1
  22. package/src/@daf/pages/Locations/index.jsx +1 -1
  23. package/src/@daf/pages/Stakeholders/Operators/index.jsx +1 -1
  24. package/src/@daf/pages/Stakeholders/Workers/index.jsx +1 -1
  25. package/src/@daf/pages/Stakeholders/index.jsx +1 -1
  26. package/src/@daf/pages/Summary/Activities/Restoration/config.js +36 -0
  27. package/src/@daf/pages/Summary/Activities/Restoration/helper.js +98 -0
  28. package/src/@daf/pages/Summary/Activities/Restoration/index.jsx +178 -0
  29. package/src/@daf/pages/Summary/Minesite/components/LocationMap/index.js +61 -0
  30. package/src/@daf/pages/Summary/Minesite/components/MineSiteDetails/config.js +77 -0
  31. package/src/@daf/pages/Summary/Minesite/components/MineSiteDetails/index.js +47 -0
  32. package/src/@daf/pages/Summary/Minesite/components/StakeholderMapping/config.js +26 -0
  33. package/src/@daf/pages/Summary/Minesite/components/StakeholderMapping/helper.js +64 -0
  34. package/src/@daf/pages/Summary/Minesite/components/StakeholderMapping/index.js +56 -0
  35. package/src/@daf/pages/Summary/Minesite/index.jsx +162 -0
  36. package/src/@daf/pages/Summary/Operator/components/Governance/config.js +26 -0
  37. package/src/@daf/pages/Summary/Operator/components/Governance/helper.js +61 -0
  38. package/src/@daf/pages/Summary/Operator/components/Governance/index.js +55 -0
  39. package/src/@daf/pages/Summary/Operator/components/KeyInformation/config.js +84 -0
  40. package/src/@daf/pages/Summary/Operator/components/KeyInformation/index.js +46 -0
  41. package/src/@daf/pages/Summary/Operator/components/TradeRelationships/config.js +40 -0
  42. package/src/@daf/pages/Summary/Operator/components/TradeRelationships/helper.js +98 -0
  43. package/src/@daf/pages/Summary/Operator/components/TradeRelationships/hook.js +160 -0
  44. package/src/@daf/pages/Summary/Operator/components/TradeRelationships/index.js +83 -0
  45. package/src/@daf/pages/Summary/Operator/hook.js +176 -0
  46. package/src/@daf/pages/Summary/Operator/index.jsx +170 -0
  47. package/src/@daf/pages/Summary/components/InformationAvailability/components/Contributions/index.js +36 -0
  48. package/src/@daf/pages/Summary/components/InformationAvailability/components/InformationCompleteness/index.js +58 -0
  49. package/src/@daf/pages/Summary/components/InformationAvailability/index.js +42 -0
  50. package/src/@daf/pages/Summary/hook.js +188 -0
  51. package/src/@daf/services/OperatorService.js +16 -0
  52. package/src/@daf/services/SourceService.js +1 -1
  53. package/src/helpers/StringHelper.js +7 -0
  54. package/src/pages.js +6 -4
  55. package/src/@daf/pages/Events/Incidents2/columns.js +0 -176
  56. package/src/@daf/pages/Events/Incidents2/config.js +0 -170
  57. package/src/@daf/pages/Events/Incidents2/create.jsx +0 -104
  58. package/src/@daf/pages/Events/Incidents2/index.jsx +0 -156
  59. /package/src/@daf/pages/{dashboards → Dashboards}/SupplyChain/components/ChartsContainer/components/GenderDistribution/config.js +0 -0
  60. /package/src/@daf/pages/{dashboards → Dashboards}/SupplyChain/components/ChartsContainer/components/GenderDistribution/index.js +0 -0
  61. /package/src/@daf/pages/{dashboards → Dashboards}/SupplyChain/components/ChartsContainer/components/Identification/hook.js +0 -0
  62. /package/src/@daf/pages/{dashboards → Dashboards}/SupplyChain/components/ChartsContainer/components/Identification/index.js +0 -0
  63. /package/src/@daf/pages/{dashboards → Dashboards}/SupplyChain/components/ChartsContainer/components/Locations/config.js +0 -0
  64. /package/src/@daf/pages/{dashboards → Dashboards}/SupplyChain/components/ChartsContainer/components/Locations/index.js +0 -0
  65. /package/src/@daf/pages/{dashboards → Dashboards}/SupplyChain/components/ChartsContainer/index.js +0 -0
  66. /package/src/@daf/pages/{dashboards → Dashboards}/SupplyChain/components/KeyIndicators/config.js +0 -0
  67. /package/src/@daf/pages/{dashboards → Dashboards}/SupplyChain/components/KeyIndicators/index.js +0 -0
  68. /package/src/@daf/pages/{dashboards → Dashboards}/SupplyChain/components/SupplyChainMap/index.js +0 -0
  69. /package/src/@daf/pages/{dashboards → Dashboards}/SupplyChain/components/TradeRelationships/index.js +0 -0
  70. /package/src/@daf/pages/{dashboards → Dashboards}/SupplyChain/config.js +0 -0
  71. /package/src/@daf/pages/{dashboards → Dashboards}/SupplyChain/index.jsx +0 -0
  72. /package/src/@daf/pages/{dashboards → Dashboards}/UserDashboard/components/AccumulationGraph/hook.js +0 -0
  73. /package/src/@daf/pages/{dashboards → Dashboards}/UserDashboard/components/AccumulationGraph/index.jsx +0 -0
  74. /package/src/@daf/pages/{dashboards → Dashboards}/UserDashboard/components/ContributionsGraph/helper.js +0 -0
  75. /package/src/@daf/pages/{dashboards → Dashboards}/UserDashboard/components/ContributionsGraph/hook.js +0 -0
  76. /package/src/@daf/pages/{dashboards → Dashboards}/UserDashboard/components/ContributionsGraph/index.jsx +0 -0
  77. /package/src/@daf/pages/{dashboards → Dashboards}/UserDashboard/components/CustomSegment/index.jsx +0 -0
  78. /package/src/@daf/pages/{dashboards → Dashboards}/UserDashboard/components/DataChainOfCustody/index.jsx +0 -0
  79. /package/src/@daf/pages/{dashboards → Dashboards}/UserDashboard/components/DataCompilation/index.jsx +0 -0
  80. /package/src/@daf/pages/{dashboards → Dashboards}/UserDashboard/components/DataConsilidation/index.jsx +0 -0
  81. /package/src/@daf/pages/{dashboards → Dashboards}/UserDashboard/components/KeyIndicators/config.js +0 -0
  82. /package/src/@daf/pages/{dashboards → Dashboards}/UserDashboard/components/KeyIndicators/index.jsx +0 -0
  83. /package/src/@daf/pages/{dashboards → Dashboards}/UserDashboard/components/MineSites/config.js +0 -0
  84. /package/src/@daf/pages/{dashboards → Dashboards}/UserDashboard/components/MineSites/helper.js +0 -0
  85. /package/src/@daf/pages/{dashboards → Dashboards}/UserDashboard/components/MineSites/index.jsx +0 -0
  86. /package/src/@daf/pages/{dashboards → Dashboards}/UserDashboard/components/Triangulation/config.js +0 -0
  87. /package/src/@daf/pages/{dashboards → Dashboards}/UserDashboard/components/Triangulation/hook.js +0 -0
  88. /package/src/@daf/pages/{dashboards → Dashboards}/UserDashboard/components/Triangulation/index.jsx +0 -0
  89. /package/src/@daf/pages/{dashboards → Dashboards}/UserDashboard/config.js +0 -0
  90. /package/src/@daf/pages/{dashboards → Dashboards}/UserDashboard/index.jsx +0 -0
  91. /package/src/@daf/pages/{dashboards → Dashboards}/helper.js +0 -0
@@ -190,4 +190,11 @@ export function formatToKebabCase(str) {
190
190
  return str
191
191
  .replace(/([a-z])([A-Z])/g, "$1-$2")
192
192
  .toLowerCase();
193
+ }
194
+
195
+ export const getLinkValue = (value, linkingObject) => {
196
+ if(linkingObject && linkingObject?.[value]) {
197
+ return linkingObject?.[value]?.name;
198
+ }
199
+ return null;
193
200
  }
package/src/pages.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Dashboards
2
- export { default as SupplyChainDashboard } from './@daf/pages/dashboards/SupplyChain/index.jsx';
3
- export { default as UserDashboard } from './@daf/pages/dashboards/UserDashboard/index.jsx';
2
+ export { default as SupplyChainDashboard } from './@daf/pages/Dashboards/SupplyChain/index.jsx';
3
+ export { default as UserDashboard } from './@daf/pages/Dashboards/UserDashboard/index.jsx';
4
4
  export { default as OperatorsTable } from './@daf/pages/Stakeholders/Operators/index.jsx';
5
5
  export { default as LocationsTable } from './@daf/pages/Locations/index.jsx';
6
6
  export { default as StakeholdersTable } from './@daf/pages/Stakeholders/index.jsx';
@@ -12,6 +12,8 @@ export { default as ActivitiesTable } from './@daf/pages/Events/Activities/index
12
12
  export { default as IncidentsTable } from './@daf/pages/Events/Incidents/index.jsx';
13
13
  export { default as ProductionSitesTable } from './@daf/pages/Locations/MineSite/index.jsx';
14
14
 
15
- // Pages
16
- export { default as TablePageWithTabs } from './@daf/pages/pages/TablePageWithTabs/index.jsx';
17
15
 
16
+ // Summary
17
+ export { default as OperatorSummary } from './@daf/pages/Summary/Operator/index.jsx';
18
+ export { default as RestorationActivitySummary } from './@daf/pages/Summary/Activities/Restoration/index.jsx';
19
+ export { default as MineSummary } from './@daf/pages/Summary/Minesite/index.jsx';
@@ -1,176 +0,0 @@
1
- import React from 'react';
2
- import { Tooltip } from 'antd';
3
- import { findOptions } from '../../../../helpers/StringHelper.js';
4
- import { renderDateFormatted } from '../../../../helpers/Forms.js';
5
- import CustomIcon from '../../../core/components/Icon/CustomIcon.jsx';
6
- import AvatarGroup from '../../../core/components/AvatarGroup/index.jsx';
7
-
8
- const getLinkValue = (value, linkingObject) => {
9
- if(linkingObject && linkingObject?.[value]) {
10
- return linkingObject?.[value]?.name;
11
- }
12
- return null;
13
- }
14
-
15
- export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink, theme, subject, data}) => [
16
- {
17
- dataIndex: 'datastakeId',
18
- title: t('ID'),
19
- ellipsis: true,
20
- show: true,
21
- render: (v, all) => {
22
- if (all.empty) {
23
- return <div className="daf-default-cell" />
24
- }
25
-
26
- return <Tooltip title={v}>{v}</Tooltip>;
27
- },
28
- },
29
- {
30
- dataIndex: 'title',
31
- title: t('Title'),
32
- ellipsis: true,
33
- show: true,
34
- render: (v, all) => {
35
- if (all.empty) {
36
- return <div className="daf-default-cell" />
37
- }
38
-
39
- return <Tooltip title={v}>{v}</Tooltip>;
40
- },
41
- },
42
- {
43
- title: t("Date"),
44
- dataIndex: "date",
45
- key: "date",
46
- width: 125,
47
- render: (date, all) => {
48
- if (all.empty) {
49
- return <div className="daf-default-cell" />;
50
- }
51
-
52
- const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
53
- return <Tooltip title={_date}>{_date}</Tooltip>;
54
- },
55
- ellipsis: true,
56
- },
57
-
58
- {
59
- dataIndex: 'location',
60
- title: t('Location'),
61
- ellipsis: true,
62
- show: true,
63
- render: (v, all) => {
64
- if (all.empty) {
65
- return <div className="daf-default-cell" />
66
- }
67
-
68
- const location = getLinkValue(all?.location, all?.linking);
69
-
70
- return location ? <Tooltip title={location}>{location}</Tooltip> : '-';
71
- },
72
- },
73
- {
74
- title: t("Province"),
75
- dataIndex: "province",
76
- key: "province",
77
- show: activeTab !== "own",
78
- render: (val, all) => {
79
- if (all.empty) {
80
- return <div className="daf-default-cell" />;
81
- }
82
-
83
- console.log({val, all})
84
-
85
- return <AvatarGroup items={val}></AvatarGroup>;
86
- },
87
- }
88
- , {
89
- dataIndex: 'territory',
90
- title: t('Territory'),
91
- ellipsis: true,
92
- show: true,
93
- render: (v, all) => {
94
- if (all.empty) {
95
- return <div className="daf-default-cell" />
96
- }
97
-
98
- const territory = getLinkValue(all?.territory, all?.linking);
99
-
100
- return territory ? <Tooltip title={territory}>{territory}</Tooltip> : '-';
101
- },
102
- },
103
- {
104
- title: t("Category"),
105
- dataIndex: 'category',
106
- ellipsis: true,
107
- show: activeTab !== "own",
108
- render: (v, all) => {
109
- if (all.empty) {
110
- return <div className="daf-default-cell" />
111
- }
112
- const category = findOptions(v, data?.options?.categoryOptions);
113
- return category ? <Tooltip title={category}>{category}</Tooltip> : '-';
114
- },
115
- },
116
- {
117
- title: t("Sources"),
118
- dataIndex: 'sources',
119
- ellipsis: true,
120
- show: activeTab !== "own",
121
- render: (v, all) => {
122
- if (all.empty) {
123
- return <div className="daf-default-cell" />
124
- }
125
- const sources = findOptions(v, data?.options?.sourcesOptions);
126
- return sources ? <Tooltip title={sources}>{sources}</Tooltip> : '-';
127
- },
128
- },
129
- {
130
- title: t("Status"),
131
- dataIndex: 'status',
132
- ellipsis: true,
133
- show: activeTab == "own",
134
- render: (v, all) => {
135
- if (all.empty) {
136
- return <div className="daf-default-cell" />
137
- }
138
- const status = findOptions(v, data?.options?.statusOptions);
139
- return status ? <Tooltip title={status}>{status}</Tooltip> : '-';
140
- },
141
- },
142
-
143
- {
144
- title: t("Last Update"),
145
- dataIndex: "updatedAt",
146
- key: "updatedAt",
147
- width: 125,
148
- render: (date, all) => {
149
- if (all.empty) {
150
- return <div className="daf-default-cell" />;
151
- }
152
-
153
- const _date = date ? renderDateFormatted(date, "DD MMM YYYY", user?.language || 'en') : "-";
154
- return <Tooltip title={_date}>{_date}</Tooltip>;
155
- },
156
- ellipsis: true,
157
- },
158
- {
159
- id: 'actions',
160
- title: "",
161
- width: 60,
162
- render: (_, all) => {
163
- if (all.empty) {
164
- return <div className="daf-default-cell" />;
165
- }
166
-
167
- const link = `/app/view/${subject}/${all.datastakeId}`;
168
-
169
- return <div style={{ display: "flex", justifyContent: "center" }}>
170
- <a href={getRedirectLink(link)}>
171
- <CustomIcon name="Link" size={15} color={theme.baseGray70} />
172
- </a>
173
- </div>;
174
- }
175
- }
176
- ].filter((column) => column.show !== false);
@@ -1,170 +0,0 @@
1
- export const checkboxConfig = {
2
- name: 'Name',
3
- datastakeId: 'ID'
4
- }
5
-
6
- export const getFiltersConfig = ({t}) => {
7
- return {
8
-
9
- timeframe: {
10
- type: "timeframe",
11
- label: "Timeframe",
12
- style: { flex: 1 },
13
- },
14
- country: {
15
- type: 'select',
16
- label: 'Country',
17
- placeholder: (t) => `${t('Filter by')} ${t('Country').toLowerCase()}`,
18
- style: { flex: 1 },
19
- labelStyle: { flex: 1 },
20
- getLabel: (option) => option.label,
21
- getValue: (option) => option.value,
22
- },
23
- administrativeLevel1: {
24
- type: 'ajaxSelect',
25
- label: ({ t = (s) => s, options = {}, filters = {}, language = 'en' }) => {
26
- const { administrativeLevel1 } = options;
27
-
28
- if (administrativeLevel1) {
29
- if (options.country) {
30
- const _item = administrativeLevel1[filters.country];
31
- if (_item) {
32
- if (_item[language]) {
33
- return _item[language]
34
- }
35
- }
36
- }
37
- }
38
-
39
- return t('Province');
40
- },
41
- placeholder: (t) => `${t('Filter by')} ${t('Province').toLowerCase()}`,
42
- filters: (data) => ({
43
- country: data.country,
44
- level: 'level_1',
45
- }),
46
- show: (data) => !data.country,
47
- disabled: (data) => !data.country,
48
- mapper: { label: "name", value: "id" },
49
- method: 'getOptions',
50
- entity: 'AdministrativeLevel',
51
- style: { flex: 1 },
52
- labelStyle: { flex: 1 },
53
- },
54
- administrativeLevel2: {
55
- type: 'ajaxSelect',
56
- label: ({ t = (s) => s, options = {}, filters = {}, language = 'en' }) => {
57
- const { administrativeLevel2 } = options;
58
-
59
- if (administrativeLevel2) {
60
- if (options.country) {
61
- const _item = administrativeLevel2[filters.country];
62
- if (_item) {
63
- if (_item[language]) {
64
- return _item[language]
65
- }
66
- }
67
- }
68
- }
69
-
70
- return t('Province');
71
- },
72
- show: (data) => !(data.country && data.administrativeLevel1),
73
- placeholder: (t) => `${t('Filter by')} ${t('Territory').toLowerCase()}`,
74
- filters: (data) => ({
75
- country: data.country,
76
- level: 'level_2',
77
- administrativeLevel1: data.administrativeLevel1,
78
- }),
79
- disabled: (data) => !(data.country && data.administrativeLevel1),
80
- mapper: { label: "name", value: "id" },
81
- method: 'getOptions',
82
- entity: 'AdministrativeLevel',
83
- style: { flex: 1 },
84
- labelStyle: { flex: 1 },
85
- },
86
- subCategory: {
87
- type: 'select',
88
- label: 'Category',
89
- placeholder: (t) => `${t('Filter by')} ${t('Category').toLowerCase()}`,
90
- style: { flex: 1 },
91
- labelStyle: { flex: 1 },
92
- getLabel: (option) => option.label,
93
- getValue: (option) => option.value,
94
- filterOptions: (val) => {
95
- if (val) {
96
- const { option, filters } = val
97
- if (filters && option) {
98
- const { filters: optionFilters } = option;
99
- if (Array.isArray(optionFilters) && optionFilters.length) {
100
- const { value, condition } = optionFilters[0];
101
- if (condition === 'includes') {
102
- return value.includes('corporation');
103
- }
104
- }
105
- }
106
- }
107
- return true;
108
- },
109
- },
110
- positionInTheMineralSupplyChain: {
111
- type: 'select',
112
- label: 'Position',
113
- placeholder: (t) => `${t('Filter by')} ${t('Position').toLowerCase()}`,
114
- style: { flex: 1 },
115
- labelStyle: { flex: 1 },
116
- getLabel: (option) => option.label,
117
- getValue: (option) => option.value,
118
- },
119
- status: {
120
- type: "select",
121
- label: "Status",
122
- placeholder: (t) => `${t("Filter by")} ${t("Status").toLowerCase()}`,
123
- style: { flex: 1 },
124
- labelStyle: { fley: 1 },
125
- getLabel: (option) => option.label,
126
- getValue: (option) => option.value,
127
- },
128
- }
129
- }
130
-
131
- export const filtersConfig = {
132
- name: '',
133
- datastakeId: '',
134
- };
135
-
136
- export const getFilterOptions = (options, t) => {
137
- const {
138
- timeframe = [],
139
- statusOptions = [],
140
- categoryOptions = [],
141
- countries = [],
142
- subCategory = [],
143
- subCategoriesOptions,
144
- stakeholderCategoryOptions,
145
- stakeholderSubCategoriesOptions,
146
- administrativeLevel1,
147
- administrativeLevel2,
148
- } = options || {};
149
-
150
- const _default = {
151
- timeframe: timeframe,
152
- category: stakeholderCategoryOptions || categoryOptions,
153
- country: countries,
154
- administrativeLevel1,
155
- administrativeLevel2,
156
- subCategory: subCategoriesOptions,
157
- status: [
158
- {
159
- value: "submitted",
160
- label: "Submitted",
161
- },
162
- {
163
- value: "private",
164
- label: "Private",
165
- },
166
- ],
167
- }
168
-
169
- return _default;
170
- }
@@ -1,104 +0,0 @@
1
- import React, { useEffect} from 'react'
2
- import { message } from 'antd';
3
- import { MessageTypes } from '../../../../helpers/messages.js';
4
- import DynamicForm from '../../../core/components/DynamicForm/index.jsx';
5
-
6
- const IncidentsCreate = ({
7
- namespace = "event",
8
- view = "event",
9
- edit = false,
10
- formData = {},
11
- loading = false,
12
- onSubmitted = () => {},
13
- onCancel = () => {},
14
- getData = () => {},
15
- saveData = () => {},
16
- form: formConfig = {},
17
- formValue = {},
18
- defaultData = {},
19
- user = {},
20
- APP,
21
- query,
22
- goTo = () => {},
23
- t = () => {},
24
- ajaxForms = {},
25
- changeAjaxForms = () => {},
26
- ajaxOptions = {},
27
- changeAjaxOptions = () => {},
28
- getAppHeader = () => {},
29
- getApiBaseUrl = () => {},
30
- }) => {
31
- let {
32
- form = {},
33
- data = defaultData || {},
34
- } = !edit ? (formData[`${APP}-${view}`] || {}) : {
35
- form: formConfig,
36
- data: formValue
37
- };
38
-
39
- useEffect(() => {
40
- if (Object.keys(form).length === 0 && !formData[`${APP}-${view}`]) {
41
- if (!edit) {
42
- getData({ namespace, module: APP, view, scope: 'createIncident' });
43
- } else {
44
- form = formConfig;
45
- data = formValue;
46
- }
47
- }
48
- }, [edit, user?.language]);
49
-
50
- return (
51
- <div className="daf-create-form">
52
- <DynamicForm
53
- form={form}
54
- data={{...defaultData, ...data}}
55
- showSaveAndNext={false}
56
- module={APP}
57
- onCancel={onCancel}
58
- isCreate
59
- t={t}
60
- excludedKeys={["title"]}
61
- user={user}
62
- ajaxForms={ajaxForms}
63
- ajaxOptions={ajaxOptions}
64
- getAppHeader={getAppHeader}
65
- getApiBaseUrl={getApiBaseUrl}
66
- changeAjaxOptions={changeAjaxOptions}
67
- app={APP}
68
- query={query}
69
- goTo={goTo}
70
- changeAjaxForms={changeAjaxForms}
71
- submit={(payload, setSelectedFormNext) => {
72
- const payloadData = { ...payload, module: APP, namespace };
73
-
74
- const newPayload = {
75
- ...defaultData,
76
- ...payloadData,
77
- form: 'incident'
78
- };
79
-
80
- const callback = (type, m, data) => {
81
- if (setSelectedFormNext) {
82
- setSelectedFormNext();
83
- }
84
- if (type === MessageTypes.SUCCESS) {
85
- if (onSubmitted) onSubmitted(type, m, data);
86
- } else {
87
- message.error(m);
88
- }
89
- };
90
-
91
- saveData(
92
- !data && !data.id ? newPayload : Object.assign(newPayload, { id: data.id }),
93
- callback,
94
- );
95
- }}
96
- isFormDisabled={() => {
97
- return !data || !data.typeOfEvent;
98
- }}
99
- />
100
- </div>
101
- )
102
- }
103
-
104
- export default IncidentsCreate
@@ -1,156 +0,0 @@
1
- import React, { useMemo, useState, useEffect, useCallback } from 'react'
2
- import TablePageWithTabs from '../../pages/TablePageWithTabs/index.jsx'
3
- import { getColumns } from './columns.js';
4
- import { checkboxConfig, getFiltersConfig, filtersConfig, getFilterOptions } from './config.js';
5
- import { useGetQueryParams } from '../../../hooks/useGetQueryParams.js';
6
- import IncidentsCreate from './create.jsx';
7
- import { displayMessage } from '../../../../helpers/messages.js';
8
-
9
- const IncidentsTable = ({
10
- t = () => {},
11
- goTo = () => {},
12
- user = {},
13
- options = {},
14
- getRedirectLink = () => {},
15
- theme = {},
16
- loading = false,
17
- data = {},
18
- isMobile,
19
- APP,
20
- location,
21
- getData = () => {},
22
- getApiBaseUrl = () => {},
23
- getAppHeader = () => {},
24
- getFormData = () => {},
25
- saveFormData = () => {},
26
- formLoading = false,
27
- query = {},
28
- ajaxForms = {},
29
- changeAjaxForms = () => {},
30
- ajaxOptions = {},
31
- changeAjaxOptions = () => {},
32
- formData = {},
33
- formValue = {},
34
- form = {},
35
- extendingFilters = {},
36
- createDefaultValues = {},
37
- }) => {
38
- const [selectOptions, setSelectOptions] = useState();
39
- const [activeTab, setActiveTab] = useState("own");
40
-
41
- const columns = useMemo(() => getColumns({
42
- t,
43
- goTo,
44
- user,
45
- options,
46
- activeTab,
47
- getRedirectLink,
48
- theme,
49
- subject: 'incidents',
50
- data,
51
- }), [t, goTo, user, options, activeTab, getRedirectLink, theme, data]);
52
-
53
- const breadCrumbs = [];
54
-
55
- const { paginationQuery, searchParams, otherParams, sortBy, sortDir } = useGetQueryParams({location});
56
-
57
- const filters = useMemo(() => {
58
- return {
59
- ...otherParams,
60
- ...extendingFilters
61
- }
62
- }, [otherParams, extendingFilters])
63
-
64
- useEffect(() => {
65
- getData({
66
- pagination: paginationQuery,
67
- ...(Object.keys(searchParams).length > 0 && { search: searchParams }),
68
- ...otherParams,
69
- tab: activeTab,
70
- sortBy: {
71
- [sortBy || "updatedAt"]: sortDir ? (sortDir === "ascend" ? 1 : -1) : -1,
72
- },
73
- ...extendingFilters
74
- }, 'incidents')
75
- }, [location.search, activeTab, JSON.stringify(extendingFilters)]);
76
-
77
- const selectFiltersConfig = useMemo(() => {
78
- return getFiltersConfig({t});
79
- }, [t]);
80
-
81
- useEffect(() => {
82
- setSelectOptions((prev) => ({
83
- ...prev,
84
- ...getFilterOptions(options, t),
85
- }))
86
- }, [options, t])
87
-
88
- const handleActiveTabChange = useCallback((value) => {
89
- setActiveTab(value);
90
- }, []);
91
-
92
- return (
93
- <TablePageWithTabs
94
- t={t}
95
- title={t("incidents")}
96
- breadCrumbs={breadCrumbs}
97
- location={location}
98
- loading={loading}
99
- goTo={goTo}
100
- defaultActiveTab={"own"}
101
- columns={columns}
102
- data={data}
103
- checkboxConfig={checkboxConfig}
104
- APP={APP}
105
- getApiBaseUrl={getApiBaseUrl}
106
- selectOptions={selectOptions}
107
- selectFiltersConfig={selectFiltersConfig}
108
- getRedirectLink={getRedirectLink}
109
- filtersConfig={filtersConfig}
110
- isMobile={isMobile}
111
- view="incidents"
112
-
113
- getActiveTab={handleActiveTabChange}
114
- onDownload={() => {
115
- console.log("download");
116
- }}
117
- drawerTitle={t("Create Incident")}
118
- >
119
- {({onDrawerClose}) => (
120
- <IncidentsCreate
121
- defaultData={createDefaultValues}
122
- t={t}
123
- goTo={goTo}
124
- user={user}
125
- APP={APP}
126
- getApiBaseUrl={getApiBaseUrl}
127
- getAppHeader={getAppHeader}
128
- getData={getFormData}
129
- saveData={saveFormData}
130
- loading={formLoading}
131
- onSubmitted={(type, m, data) => {
132
- if (data.datastakeId) {
133
- displayMessage(
134
- type,
135
- t("affirmations::subject-created-successfully") || m,
136
- );
137
- // goTo(`/app/edit/stakeholders/${data.datastakeId}`);
138
- goTo(`/app/edit/incidents/${data.datastakeId}`)
139
- }
140
- }}
141
- onCancel={onDrawerClose}
142
- query={query}
143
- ajaxForms={ajaxForms}
144
- changeAjaxForms={changeAjaxForms}
145
- ajaxOptions={ajaxOptions}
146
- changeAjaxOptions={changeAjaxOptions}
147
- formData={formData}
148
- formValue={formValue}
149
- form={form}
150
- />
151
- )}
152
- </TablePageWithTabs>
153
- )
154
- }
155
-
156
- export default IncidentsTable