datastake-daf 0.6.798 → 0.6.800

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 (72) hide show
  1. package/dist/components/index.js +1206 -311
  2. package/dist/context/index.js +6 -6
  3. package/dist/pages/index.js +250 -14
  4. package/dist/services/index.js +187 -84
  5. package/dist/utils/index.js +14 -17
  6. package/package.json +1 -1
  7. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/hook.js +0 -1
  8. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/index.jsx +1 -1
  9. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/hook.js +1 -1
  10. package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/index.jsx +1 -1
  11. package/src/@daf/core/components/Screens/Admin/AdminModals/AddUser/index.jsx +0 -1
  12. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/columns.js +79 -0
  13. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/helper.js +2 -2
  14. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/index.jsx +18 -8
  15. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineSubjects/index.jsx +6 -6
  16. package/src/@daf/core/components/Screens/Admin/AdminModals/NewAccount/index.jsx +1 -1
  17. package/src/@daf/core/components/Screens/Admin/AdminModals/NewUser/index.jsx +61 -38
  18. package/src/@daf/core/components/Screens/Admin/AdminScreens/Accounts.jsx +1 -4
  19. package/src/@daf/core/components/Screens/Admin/AdminScreens/AccountsView.jsx +2 -0
  20. package/src/@daf/core/components/Screens/Admin/AdminScreens/Dashboard.jsx +2 -2
  21. package/src/@daf/core/components/Screens/Admin/AdminScreens/Location.jsx +10 -8
  22. package/src/@daf/core/components/Screens/Admin/AdminScreens/Subjects.jsx +5 -3
  23. package/src/@daf/core/components/Screens/Admin/AdminScreens/SubjectsView.jsx +395 -0
  24. package/src/@daf/core/components/Screens/Admin/AdminScreens/index.js +1 -0
  25. package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/index.jsx +1 -0
  26. package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/column.js +225 -0
  27. package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/helper.js +65 -0
  28. package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/index.jsx +78 -46
  29. package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/columns.js +41 -39
  30. package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/index.jsx +53 -24
  31. package/src/@daf/core/components/Screens/Admin/AdminTables/UserTable/index.jsx +1 -0
  32. package/src/@daf/core/components/Screens/Admin/AdminViews/EditLocation/configTransformer.js +137 -0
  33. package/src/@daf/core/components/Screens/Admin/AdminViews/EditLocation/index.js +9 -0
  34. package/src/@daf/core/components/Screens/Admin/AdminViews/EditLocation/index.jsx +196 -0
  35. package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/configTransformer.js +216 -0
  36. package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/index.js +7 -0
  37. package/src/@daf/core/components/Screens/Admin/AdminViews/EditStakeholder/index.jsx +184 -0
  38. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/config.js +64 -0
  39. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/helpers.js +13 -0
  40. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/index.jsx +77 -0
  41. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/config.js +51 -0
  42. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/helpers.js +0 -0
  43. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/index.jsx +75 -0
  44. package/src/@daf/core/components/Screens/Admin/AdminViews/components/Edit/index.jsx +7 -1
  45. package/src/@daf/core/components/Screens/Admin/AdminViews/components/SidebarMenu/index.jsx +5 -3
  46. package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/helper.js +13 -8
  47. package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/index.jsx +16 -10
  48. package/src/@daf/core/components/Screens/Admin/AdminViews/components/View/index.jsx +2 -1
  49. package/src/@daf/core/components/Screens/Admin/AdminViews/index.jsx +66 -26
  50. package/src/@daf/core/components/Screens/Admin/AppInvitation/index.jsx +193 -0
  51. package/src/@daf/core/components/Screens/Admin/adminRoutes.js +37 -2
  52. package/src/@daf/layouts/AppLayout/index.jsx +0 -1
  53. package/src/@daf/pages/Edit/hooks/usePrepareForm.js +1 -1
  54. package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/columns.js +180 -0
  55. package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/config.js +0 -0
  56. package/src/@daf/pages/SelfAssesment/components/AssociatedInformationTable/index.jsx +27 -0
  57. package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/columns.js +157 -0
  58. package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/config.js +31 -0
  59. package/src/@daf/pages/SelfAssesment/components/OrgInformationTable/index.js +77 -0
  60. package/src/@daf/pages/SelfAssesment/components/ProductionSiteTable/columns.js +117 -0
  61. package/src/@daf/pages/SelfAssesment/components/ProductionSiteTable/index.jsx +54 -0
  62. package/src/@daf/pages/SelfAssesment/index.jsx +0 -0
  63. package/src/@daf/pages/View/hooks/usePrepareForm.js +11 -1
  64. package/src/@daf/pages/View/index.jsx +9 -2
  65. package/src/@daf/services/AdminService.js +112 -7
  66. package/src/@daf/services/AuthenticationService.js +1 -0
  67. package/src/@daf/services/DashboardService.js +2 -1
  68. package/src/@daf/utils/filters.js +15 -13
  69. package/src/constants/locales/en/translation.js +7 -0
  70. package/src/constants/locales/fr/translation.js +1 -1
  71. package/src/constants/locales/sp/translation.js +1 -1
  72. package/src/index.js +1 -0
@@ -0,0 +1,54 @@
1
+ import React from 'react';
2
+ import TablePage from '../../../TablePage/index.jsx';
3
+ import { getColumns } from './columns.js';
4
+
5
+ const ProductionSiteTable = ({
6
+ t = () => {},
7
+ goTo = () => {},
8
+ user = {},
9
+ options = {},
10
+ getRedirectLink = () => {},
11
+ theme = {},
12
+ loading = false,
13
+ data = {},
14
+ isMobile,
15
+ APP,
16
+ location,
17
+ getData = () => {},
18
+ getApiBaseUrl = () => {},
19
+ getAppHeader = () => {},
20
+ applications = [],
21
+ subjectClear = () => {},
22
+ breadcrumbs = [],
23
+ extendingFilters = {},
24
+ createDefaultValues = {},
25
+ }) => {
26
+ return (
27
+ <TablePage
28
+ t={t}
29
+ goTo={goTo}
30
+ user={user}
31
+ options={options}
32
+ getRedirectLink={getRedirectLink}
33
+ theme={theme}
34
+ loading={loading}
35
+ data={data}
36
+ isMobile={isMobile}
37
+ APP={APP}
38
+ location={location}
39
+ applications={applications}
40
+ subject="production-sites"
41
+ getData={getData}
42
+ getApiBaseUrl={getApiBaseUrl}
43
+ getAppHeader={getAppHeader}
44
+ subjectClear={subjectClear}
45
+ extendingFilters={extendingFilters}
46
+ breadcrumbs={breadcrumbs}
47
+ formConfig={formConfig}
48
+ defaultValues={createDefaultValues}
49
+ onDownload={() => console.log("download")}
50
+ />
51
+ )
52
+ }
53
+
54
+ export default ProductionSiteTable
File without changes
@@ -17,10 +17,16 @@ export const usePrepareForm = ({
17
17
  const [linkingForms, setLinkingForms] = useState({});
18
18
  const [loading, setLoading] = useState(true);
19
19
  const [notFound, setNotFound] = useState(false);
20
+
21
+ console.log({form, data, groups, linkingForms, loading, notFound})
20
22
 
21
23
  const prepareForm = (currentView) => {
22
24
  const dKey = namespaceConfig?.dataKey;
23
25
  const nKey = `${APP}-${currentView}`;
26
+ console.log({dKey, nKey, allData})
27
+
28
+ console.log({condition1: hasKeyInObject(allData, dKey)})
29
+ console.log({condition2: hasKeyInObject(allData[dKey], nKey)})
24
30
 
25
31
  if (hasKeyInObject(allData, dKey) && hasKeyInObject(allData[dKey], nKey)) {
26
32
  const {
@@ -29,8 +35,10 @@ export const usePrepareForm = ({
29
35
  config = {},
30
36
  linkingForms = {},
31
37
  } = JSON.parse(JSON.stringify(allData[dKey][nKey] || {}));
38
+ console.log("here", dKey, nKey)
32
39
 
33
- if (data.datastakeId === id || id === "user") {
40
+ if (data.datastakeId === id || id === "user" || data.id === id) {
41
+ console.log("here2", data.datastakeId, id, data.id)
34
42
  // if (viewConfig.linkingSubjects.includes(namespace)) {
35
43
  setForm({
36
44
  ...form,
@@ -58,6 +66,8 @@ export const usePrepareForm = ({
58
66
  }
59
67
  }
60
68
  }
69
+
70
+ console.log('data', data)
61
71
  };
62
72
 
63
73
  const getCertainData = allData?.[namespaceConfig?.dataKey];
@@ -54,7 +54,7 @@ const View = ({
54
54
  }) => {
55
55
  const getNamespaceConfig = (namespace) => namespaceConfiguration?.[namespace] || {};
56
56
  const [openRecordsModal, setOpenRecordsModal] = useState(false);
57
-
57
+
58
58
  // HANDLES THE URL PARAMS FOR THE VIEW PAGE
59
59
  const {
60
60
  namespace,
@@ -215,6 +215,13 @@ const View = ({
215
215
  : pageActions;
216
216
  }, [groupForm, pageActions]);
217
217
 
218
+ console.log({namespaceConfiguration, namespaceConfig, allData, namespace, id, group, subsection,
219
+ version,
220
+ source,
221
+ isSupported,
222
+ notFound
223
+ })
224
+
218
225
  if(!isSupported || notFound) {
219
226
  return <Loading />
220
227
  }
@@ -230,7 +237,7 @@ const View = ({
230
237
  extraButtons={extraPageActions}
231
238
  addedHeaderFirst
232
239
  addedHeader={
233
- <div className="flex flex-row gap-4">
240
+ namespaceConfig?.isAdmin ? null : <div className="flex flex-row gap-4">
234
241
  <Multiselect
235
242
  options={[...sourceOptions]}
236
243
  isAvatarGroup
@@ -1,5 +1,6 @@
1
1
  import { BaseService } from './BaseService.js';
2
2
  import { createLazyService } from './helpers/LazyService.js';
3
+ import { filterCreateData } from "../../helpers/Forms.js";
3
4
 
4
5
  class AdminService extends BaseService {
5
6
  updateCompany(id, data) {
@@ -15,6 +16,14 @@ class AdminService extends BaseService {
15
16
  })
16
17
  }
17
18
 
19
+
20
+ inviteCompanyAccount({ companyId, data }) {
21
+ return this.apiPost({
22
+ url: `/accounts/${companyId}/invite`,
23
+ data,
24
+ })
25
+ }
26
+
18
27
  inviteAccount(data) {
19
28
  return this.apiPost({
20
29
  url: `/accounts/inviteAccount`,
@@ -69,18 +78,114 @@ class AdminService extends BaseService {
69
78
  }
70
79
 
71
80
  getSubjects({ subject, params }) {
72
- return this.apiGet({
73
- url: `${subject}`,
81
+ return this.apiGet({
82
+ url: `/management/subjects/${subject}`,
74
83
  params,
75
- })
84
+ });
76
85
  }
77
86
 
78
- mergeSubjects({ subject, ...data }) {
87
+
88
+ mergeLocations({ ids, data }) {
89
+ const [id1, id2, ...remainingIds] = ids || [];
90
+
91
+ if (!id1 || !id2) {
92
+ throw new Error('At least two IDs are required for merging');
93
+ }
94
+
95
+ const url = `/management/merge/location/${id1}/${id2}`;
96
+
97
+ const payload = {
98
+ ...data,
99
+ };
100
+
101
+ if (remainingIds.length > 0) {
102
+ payload.additionalIds = remainingIds;
103
+ }
104
+
105
+ return this.apiPost({
106
+ url,
107
+ data: payload,
108
+ });
109
+ }
110
+
111
+
112
+
113
+
114
+ mergeSubjects({ subject, ids, data }) {
115
+ const [id1, id2, ...remainingIds] = ids || [];
116
+
117
+ if (!id1 || !id2) {
118
+ throw new Error('At least two IDs are required for merging');
119
+ }
120
+
121
+ const url = `/management/merge/${subject}/${id1}/${id2}`;
122
+
123
+ const payload = {
124
+ ...data,
125
+
126
+ };
127
+
128
+ if (remainingIds.length > 0) {
129
+ payload.additionalIds = remainingIds;
130
+ }
131
+
79
132
  return this.apiPost({
80
- url: `/merge/${subject}`,
81
- data,
82
- })
133
+ url,
134
+ data: payload,
135
+ });
136
+ }
137
+
138
+ getSubjectForm({ subject, scope = 'global' }) {
139
+ return this.apiGet({
140
+ url: `/forms/${subject}`,
141
+ params: { scope },
142
+ });
83
143
  }
144
+
145
+ getSubjectData({ subject, id }) {
146
+ return this.apiGet({
147
+ url: `/management/subject/${subject}/${id}`,
148
+ });
149
+ }
150
+
151
+
152
+ viewLocation({ id }) {
153
+ return this.apiGet({
154
+ url: `/management/subject/location/${id}`,
155
+ });
156
+ }
157
+
158
+ viewStakeholder({ id }) {
159
+ return this.apiGet({
160
+ url: `/management/subject/stakeholder/${id}`,
161
+ });
162
+ }
163
+
164
+
165
+ updateSubject({ subject, id, data }) {
166
+ const type = subject === 'location' ? 'location' : 'stakeholder';
167
+ return this.apiPut({
168
+ url: `/management/subject/${type}/${id}`,
169
+ data: filterCreateData(data),
170
+ });
171
+ }
172
+
173
+ deleteSubject({ subject, id }) {
174
+ const type = subject === 'location' ? 'location' : 'stakeholder';
175
+ return this.apiDelete({
176
+ url: `/management/subject/${type}/${id}`,
177
+ });
178
+ }
179
+
180
+ getUserGrowth(activeFilter) {
181
+ return this.apiGet({
182
+ url: `/accounts/dashboard/user-growth`,
183
+ isUserManager: true,
184
+ params: { activeFilter },
185
+ });
186
+ }
187
+
188
+
84
189
  }
85
190
 
86
191
  export default createLazyService(AdminService);
@@ -1,5 +1,6 @@
1
1
  import { BaseService } from "./BaseService.js";
2
2
  import { createLazyService } from "./helpers/LazyService.js";
3
+ import { StorageManager } from '../../helpers/StorageManager.js';
3
4
 
4
5
  class AuthenticationService extends BaseService {
5
6
  register(form) {
@@ -26,4 +26,5 @@ class DashboardService extends BaseService {
26
26
  }
27
27
  }
28
28
 
29
- export default createLazyService(DashboardService);
29
+ export default createLazyService(DashboardService);
30
+
@@ -63,19 +63,29 @@ export const getDefaultActiveFilters = (
63
63
  };
64
64
 
65
65
  const NEW_PAGINATION_APPS = ["nashiriki"];
66
+
66
67
  export const filterParams = (value, module) => {
67
68
  const { activeFilters, ...rest } = value;
68
69
 
69
- const { page, pageSize, sortDir, sortBy, search, searchParams, ...filters } =
70
- activeFilters || {};
70
+ const {
71
+ page = 1,
72
+ pageSize = 20,
73
+ sortDir,
74
+ sortBy,
75
+ search,
76
+ searchParams,
77
+ ...filters
78
+ } = activeFilters || {};
71
79
 
72
80
  const params = {};
73
-
81
+
74
82
  params.pagination = JSON.stringify({
75
- [NEW_PAGINATION_APPS.includes(module) ? "skip" : "page"]: page,
76
- [NEW_PAGINATION_APPS.includes(module) ? "take" : "pageSize"]: pageSize,
83
+ page,
84
+ pageSize,
77
85
  });
78
86
 
87
+ params.filters = JSON.stringify(filters);
88
+
79
89
  if (search && searchParams) {
80
90
  params.search = JSON.stringify({
81
91
  qs: search,
@@ -90,14 +100,6 @@ export const filterParams = (value, module) => {
90
100
  });
91
101
  }
92
102
 
93
- if (Object.keys(filters).length) {
94
- if (value.sourceId && value.sourceId === "overview") {
95
- params.filters = JSON.stringify(filters);
96
- } else {
97
- params.filters = JSON.stringify({ ...filters, authorId: undefined });
98
- }
99
- }
100
-
101
103
  return { ...rest, ...params };
102
104
  };
103
105
 
@@ -1,5 +1,12 @@
1
1
  const en = {
2
2
  "All Data": "All Data",
3
+ "sbg-admin::remove-user-title":"Remove User Title",
4
+ "sbg-admin::remove-user-body":"Remove User Body",
5
+ "Administrative-level-1": "Administrative Level 1",
6
+ "Administrative-level-2": "Administrative Level 2",
7
+ "merge-output": "Merge Output",
8
+ "admin::current_subjects": "Current Subjects",
9
+ "add-account":"Add Account",
3
10
  "Site": "Site",
4
11
  "Production Sites": "Production Sites",
5
12
  "Type of account": "Type of account",
@@ -421,7 +421,7 @@ const fr = {
421
421
  Documentation: "Documents",
422
422
  "Edit project": "Modifier le projet",
423
423
  Name: "Nom",
424
- Type: "Tapez",
424
+ Type: "Type",
425
425
  type: "Type",
426
426
  Province: "Province",
427
427
  Territory: "Territoire",
@@ -234,7 +234,7 @@ const sp = {
234
234
  "Documentation": "Documentos",
235
235
  "Edit project": "Modificar proyecto",
236
236
  "Name": "Nombre",
237
- "Type": "Escribe",
237
+ "Type": "Tipo",
238
238
  "type": "Tipo",
239
239
  "Province": "Provincia",
240
240
  "Territory": "Territorio",
package/src/index.js CHANGED
@@ -152,6 +152,7 @@ export { default as StakeholderMappings } from "./@daf/core/components/Graphs/St
152
152
  //* ------------------------------ Screens ------------------------------
153
153
  export { default as BaseScreen } from "./@daf/core/components/Screens/BaseScreen/index.jsx";
154
154
  // Admin - Base Components
155
+ export { default as AppInvitation } from "./@daf/core/components/Screens/Admin/AppInvitation/index.jsx";
155
156
  export { default as AdminDashboard } from "./@daf/core/components/Screens/Admin/AdminDashboard/index.jsx";
156
157
  export { default as UserTable } from "./@daf/core/components/Screens/Admin/AdminTables/UserTable/index.jsx";
157
158
  export { default as AccountTable } from "./@daf/core/components/Screens/Admin/AdminTables/AccountTable/index.jsx";