datastake-daf 0.6.753 → 0.6.755

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.
@@ -0,0 +1,173 @@
1
+ import React, { useMemo, useState, useEffect } from 'react'
2
+ import { Drawer } from 'antd'
3
+ import { getColumns } from './columns.js';
4
+ import { checkboxConfig, getFiltersConfig, filtersConfig, getFilterOptions } from './config.js';
5
+ import { useGetQueryParams } from '../../../../hooks/useGetQueryParams.js';
6
+ import UsersCreate from './create.jsx';
7
+ import Header from '../../../../core/components/Header/index.jsx';
8
+ import BaseScreen from '../BaseScreen/index.jsx';
9
+ import { CREATE_DRAWER_WIDTH } from '../../../../../helpers/Forms.js';
10
+ import DrawerHeader from '../../../../core/components/Header/DrawerHeader/index.jsx';
11
+
12
+ const UsersTable = ({
13
+ t = () => {},
14
+ goTo = () => {},
15
+ user = {},
16
+ options = {},
17
+ getRedirectLink = () => {},
18
+ theme = {},
19
+ loading = false,
20
+ data = {},
21
+ isMobile,
22
+ APP,
23
+ location,
24
+ getData = () => {},
25
+ getApiBaseUrl = () => {},
26
+ getAppHeader = () => {},
27
+ onInviteUser = () => {},
28
+ onEditUser = () => {},
29
+ query = {},
30
+ ajaxForms = {},
31
+ changeAjaxForms = () => {},
32
+ ajaxOptions = {},
33
+ changeAjaxOptions = () => {},
34
+ extendingFilters = {},
35
+ userRoles = [],
36
+ }) => {
37
+ const [selectOptions, setSelectOptions] = useState();
38
+ const params = new URLSearchParams(location?.search);
39
+ const [openCreateModal, setOpenCreateModal] = useState(params.has("create"));
40
+ const [userToEdit, setUserToEdit] = useState(null);
41
+
42
+ const columns = useMemo(() => getColumns({
43
+ t,
44
+ goTo,
45
+ user,
46
+ options,
47
+ getRedirectLink,
48
+ theme,
49
+ subject: 'user',
50
+ data,
51
+ setUserToEdit,
52
+ }), [t, goTo, user, options, getRedirectLink, theme, data]);
53
+
54
+ const breadCrumbs = [];
55
+
56
+ const { paginationQuery, searchParams, otherParams, sortBy, sortDir } = useGetQueryParams({ location });
57
+
58
+ const filters = useMemo(() => ({
59
+ ...otherParams,
60
+ ...extendingFilters,
61
+ }), [otherParams, extendingFilters]);
62
+
63
+ useEffect(() => {
64
+ getData({
65
+ pagination: paginationQuery,
66
+ ...(Object.keys(searchParams).length > 0 && { search: searchParams }),
67
+ ...otherParams,
68
+ sortBy: {
69
+ [sortBy || 'updatedAt']: sortDir ? (sortDir === 'ascend' ? 1 : -1) : -1,
70
+ },
71
+ ...extendingFilters,
72
+ }, 'users');
73
+ }, [location.search, JSON.stringify(extendingFilters)]);
74
+
75
+ const selectFiltersConfig = useMemo(() => getFiltersConfig({ t }), [t]);
76
+
77
+ useEffect(() => {
78
+ setSelectOptions((prev) => ({
79
+ ...prev,
80
+ ...getFilterOptions(options, t),
81
+ }));
82
+ }, [options, t]);
83
+
84
+ return (
85
+ <div className="semibold form-input-output daf-create-view">
86
+ <Header
87
+ title={t("users")}
88
+ breadcrumbs={breadCrumbs}
89
+ actionButtons={[
90
+ {
91
+ type: "primary",
92
+ onClick: () => setOpenCreateModal(true),
93
+ tooltip: t("New"),
94
+ icon: "Add",
95
+ },
96
+ ]}
97
+ // onDownload={() => {
98
+ // console.log("download");
99
+ // }}
100
+ // downloadDisabled={false}
101
+ />
102
+ <BaseScreen
103
+ t={t}
104
+ checkboxConfig={checkboxConfig}
105
+ defaultTableFilters={{}}
106
+ columns={columns}
107
+ data={data}
108
+ loading={loading}
109
+ location={location}
110
+ goTo={goTo}
111
+ APP={APP}
112
+ getApiBaseUrl={getApiBaseUrl}
113
+ selectOptions={selectOptions}
114
+ selectFilters={selectFiltersConfig}
115
+ view="users"
116
+ getRedirectLink={getRedirectLink}
117
+ defaultUrlParams={{}}
118
+ module={APP}
119
+ filtersConfig={filtersConfig}
120
+ isMobile={isMobile}
121
+ />
122
+ {(openCreateModal || !!userToEdit) && (
123
+ <Drawer
124
+ destroyOnClose
125
+ title={
126
+ <DrawerHeader
127
+ title={t(userToEdit ? "Edit User" : "New User")}
128
+ />
129
+ }
130
+ open={openCreateModal || !!userToEdit}
131
+ onClose={() => {
132
+ setOpenCreateModal(false);
133
+ setUserToEdit(null);
134
+ }}
135
+ width={CREATE_DRAWER_WIDTH}
136
+ bodyStyle={{ padding: 0 }}
137
+ maskClosable={false}
138
+ >
139
+ <UsersCreate
140
+ t={t}
141
+ goTo={goTo}
142
+ user={user}
143
+ APP={APP}
144
+ getApiBaseUrl={getApiBaseUrl}
145
+ getAppHeader={getAppHeader}
146
+ onSubmitted={(payload) => {
147
+ if (userToEdit) {
148
+ onEditUser(payload);
149
+ } else {
150
+ onInviteUser(payload);
151
+ }
152
+ setOpenCreateModal(false);
153
+ setUserToEdit(null);
154
+ }}
155
+ onCancel={() => {
156
+ setOpenCreateModal(false);
157
+ setUserToEdit(null);
158
+ }}
159
+ query={query}
160
+ ajaxForms={ajaxForms}
161
+ changeAjaxForms={changeAjaxForms}
162
+ ajaxOptions={ajaxOptions}
163
+ changeAjaxOptions={changeAjaxOptions}
164
+ userRoles={userRoles}
165
+ userToEdit={userToEdit}
166
+ />
167
+ </Drawer>
168
+ )}
169
+ </div>
170
+ );
171
+ };
172
+
173
+ export default UsersTable;
@@ -1,9 +1,9 @@
1
1
  import React, { useState, useEffect, useRef } from 'react'
2
2
  import { Tabs, Drawer } from 'antd'
3
- import Header from '../../../Header/index.jsx'
4
- import BaseScreen from '../../BaseScreen/index.jsx'
5
- import { CREATE_DRAWER_WIDTH } from '../../../../helpers/Forms.js'
6
- import DrawerHeader from '../../../Header/DrawerHeader/index.jsx'
3
+ import Header from '../../../../core/components/Header/index.jsx'
4
+ import BaseScreen from '../../../components/Screens/BaseScreen/index.jsx'
5
+ import { CREATE_DRAWER_WIDTH } from '../../../../../helpers/Forms.js'
6
+ import DrawerHeader from '../../../../core/components/Header/DrawerHeader/index.jsx'
7
7
 
8
8
  const TablePageWithTabs = ({
9
9
  t= () => {},
@@ -1,5 +1,3 @@
1
- import React from 'react';
2
-
3
1
  // ============================================================================
4
2
  // REGION: Photo/Image Extraction
5
3
  // ============================================================================
@@ -122,93 +120,6 @@ export const getGenderTooltipChildren = (item, isEmpty, genderDistributionData,
122
120
  });
123
121
  };
124
122
 
125
- // ============================================================================
126
- // REGION: Multiselect Options
127
- // ============================================================================
128
-
129
- /**
130
- * Get filtered options for multiselect based on activityData.origin
131
- * Filters options based on whether origin contains 'kobo', 'straatos', or both
132
- *
133
- * @param {Object} activityData - Activity data object containing origin array
134
- * @param {React.Component} CustomIcon - CustomIcon component for rendering Monitor option avatar
135
- * @returns {Array} - Filtered array of option objects
136
- */
137
- export const getFilteredOptions = (activityData, CustomIcon) => {
138
- const allOptions = [
139
- {
140
- label: "Own Data",
141
- value: "own",
142
- avatar: <span>OWN</span>,
143
- background: "#016C6E",
144
- color: "white",
145
- },
146
- {
147
- label: "Monitor",
148
- value: "other",
149
- avatar: <CustomIcon name={"Search02"} size={14} />,
150
- },
151
- ];
152
-
153
- if (!activityData?.origin || !Array.isArray(activityData.origin)) {
154
- return allOptions;
155
- }
156
-
157
- // Extract origin names from the array
158
- const originNames = activityData.origin
159
- .map(item => item?.name?.toLowerCase())
160
- .filter(Boolean);
161
-
162
- const hasKobo = originNames.includes('kobo');
163
- const hasStraatos = originNames.includes('straatos');
164
-
165
- // If contains kobo only, show only Monitor
166
- if (hasKobo && !hasStraatos) {
167
- return allOptions.filter(option => option.value === 'other');
168
- }
169
-
170
- // If contains straatos only, show only Own Data
171
- if (hasStraatos && !hasKobo) {
172
- return allOptions.filter(option => option.value === 'own');
173
- }
174
-
175
- // If contains both or neither, show both
176
- return allOptions;
177
- };
178
-
179
- /**
180
- * Get default selected value for multiselect based on activityData.origin
181
- *
182
- * @param {Object} activityData - Activity data object containing origin array
183
- * @returns {Array} - Array of default selected values
184
- */
185
- export const getDefaultSelected = (activityData) => {
186
- if (!activityData?.origin || !Array.isArray(activityData.origin)) {
187
- return ['own'];
188
- }
189
-
190
- // Extract origin names from the array
191
- const originNames = activityData.origin
192
- .map(item => item?.name?.toLowerCase())
193
- .filter(Boolean);
194
-
195
- const hasKobo = originNames.includes('kobo');
196
- const hasStraatos = originNames.includes('straatos');
197
-
198
- // If contains kobo only, default to monitor (other)
199
- if (hasKobo && !hasStraatos) {
200
- return ['other'];
201
- }
202
-
203
- // If contains straatos only, default to own
204
- if (hasStraatos && !hasKobo) {
205
- return ['own'];
206
- }
207
-
208
- // If contains both or neither, default to own
209
- return ['own'];
210
- };
211
-
212
123
  // ============================================================================
213
124
  // REGION: Activity Indicators
214
125
  // ============================================================================
@@ -1,7 +1,7 @@
1
1
  import { useMemo, useCallback } from 'react';
2
- import { DashboardLayout, Header, ImageCarousel, KeyIndicators, MineSiteMap, Widget, PieChart, ActivityIndicators, Multiselect, CustomIcon } from '../../../../../../src/index.js'
2
+ import { DashboardLayout, Header, ImageCarousel, KeyIndicators, MineSiteMap, Widget, PieChart, ActivityIndicators } from '../../../../../../src/index.js'
3
3
  import { getKeyIndicatorsRowConfig } from './config';
4
- import { getActivityImages, getGenderDistributionData, isGenderDistributionEmpty, calculateGenderPieData, getGenderTooltipChildren, getActivityIndicatorsConfig, getFilteredOptions, getDefaultSelected } from './helper';
4
+ import { getActivityImages, getGenderDistributionData, isGenderDistributionEmpty, calculateGenderPieData, getGenderTooltipChildren, getActivityIndicatorsConfig } from './helper';
5
5
  import { renderTooltipJsx } from '../../../../../../src/utils';
6
6
  import { useResizeContext } from '../../../../../../src/context';
7
7
 
@@ -24,18 +24,6 @@ const RestorationActivitySummary = ({ activityData, supportText, onDownload, dow
24
24
  [activityData, t]
25
25
  );
26
26
 
27
- // Filter options based on activityData.origin
28
- const filteredOptions = useMemo(() =>
29
- getFilteredOptions(activityData, CustomIcon),
30
- [activityData]
31
- );
32
-
33
- // Get default selected based on activityData.origin
34
- const defaultSelected = useMemo(() =>
35
- getDefaultSelected(activityData),
36
- [activityData]
37
- );
38
-
39
27
  return (
40
28
  <DashboardLayout
41
29
  header={
@@ -48,24 +36,6 @@ const RestorationActivitySummary = ({ activityData, supportText, onDownload, dow
48
36
  breadcrumbs={breadcrumbs}
49
37
  goBackTo={goBackTo}
50
38
  loading={loading}
51
- addedHeaderFirst
52
- addedHeader={
53
- <div style={{ marginRight: 0 }}>
54
- <Multiselect
55
- canUnselectLast={false}
56
- options={filteredOptions}
57
- isAvatarGroup
58
- selectionType="checkbox"
59
- onChange={(selected) => {
60
- console.log(selected);
61
- }}
62
- dropDownWidth={200}
63
- defaultSelected={defaultSelected}
64
- placeholder="Select partners..."
65
- />
66
- </div>
67
-
68
- }
69
39
  />
70
40
  }
71
41
  >
@@ -87,6 +57,57 @@ const RestorationActivitySummary = ({ activityData, supportText, onDownload, dow
87
57
  app={"straatos"}
88
58
  showSider={false}
89
59
  user={null}
60
+ data={[
61
+ {
62
+ _id: {},
63
+ id: "7f2aaed4-4b2e-406c-8e0a-6659c5c8367b",
64
+ color: "#6698E4",
65
+ parent: {
66
+ _id: {},
67
+ createdAt: "2024-06-13T14:51:55.296Z",
68
+ updatedAt: "2024-06-13T14:51:55.296Z",
69
+ id: "a5340bf1-2c7d-413f-a2a5-ccd7dc8f7a7c",
70
+ name: "New Mine",
71
+ authorId: "4e6066e9-00d8-423a-94ec-c7c9d3432fec",
72
+ collectId: "f8a2b6a9cc935ef3e5844427f49aade34e152eca",
73
+ country: "AL",
74
+ category: "mineSite",
75
+ datastakeId: "LOC-00000000141",
76
+ __v: 0,
77
+ },
78
+ administrativeLevel1: "6839cb26-5af4-44a3-b136-a0f0a0bcecc6",
79
+ administrativeLevel2: "f849835d-5640-4bee-ae98-9f1c810c1abe",
80
+ // "name": "New Mine",
81
+ country: "AL",
82
+ category: "mineSite",
83
+ authorId: "4e6066e9-00d8-423a-94ec-c7c9d3432fec",
84
+ gps: {
85
+ latitude: 7,
86
+ longitude: 1,
87
+ },
88
+ area: [
89
+ [6, 5],
90
+ [7, 1],
91
+ [9, 2],
92
+ ],
93
+ associatedSubjects: [
94
+ {
95
+ entity: "Event",
96
+ _id: {},
97
+ nature: "",
98
+ },
99
+ ],
100
+ published: false,
101
+ version: 1,
102
+ createdAt: "2024-06-13T14:51:55.296Z",
103
+ updatedAt: "2024-06-13T14:51:55.296Z",
104
+ name: "Name",
105
+ type: "Loc Type",
106
+ __v: 0,
107
+ datastakeId: "LOC-00000000141",
108
+ },
109
+ ]}
110
+ // tooltipAsText: true,
90
111
  primaryLink={true}
91
112
  renderTooltip={() => {
92
113
  return [
@@ -96,8 +117,8 @@ const RestorationActivitySummary = ({ activityData, supportText, onDownload, dow
96
117
  },
97
118
  ];
98
119
  }}
99
-
100
- mapConfig={{ maxZoom: 18, zoom: 5, center: [14, -14] }}
120
+ center={[13, -15]}
121
+ mapConfig={{ maxZoom: 18 }}
101
122
  type={'territory'}
102
123
  link={true}
103
124
  onClickLink={() => { }}
package/src/pages.js CHANGED
@@ -11,7 +11,7 @@ export { default as ActivitiesTable } from './@daf/pages/Events/Activities/index
11
11
 
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
+ export { default as UsersTable } from './@daf/core/components/Screens/Users/index.jsx';
15
15
 
16
16
  // Summary
17
17
  export { default as OperatorSummary } from './@daf/pages/Summary/Operator/index.jsx';
package/build/favicon.ico DELETED
Binary file
package/build/logo192.png DELETED
Binary file
package/build/logo512.png DELETED
Binary file
@@ -1,25 +0,0 @@
1
- {
2
- "short_name": "React App",
3
- "name": "Create React App Sample",
4
- "icons": [
5
- {
6
- "src": "favicon.ico",
7
- "sizes": "64x64 32x32 24x24 16x16",
8
- "type": "image/x-icon"
9
- },
10
- {
11
- "src": "logo192.png",
12
- "type": "image/png",
13
- "sizes": "192x192"
14
- },
15
- {
16
- "src": "logo512.png",
17
- "type": "image/png",
18
- "sizes": "512x512"
19
- }
20
- ],
21
- "start_url": ".",
22
- "display": "standalone",
23
- "theme_color": "#000000",
24
- "background_color": "#ffffff"
25
- }
package/build/robots.txt DELETED
@@ -1,3 +0,0 @@
1
- # https://www.robotstxt.org/robotstxt.html
2
- User-agent: *
3
- Disallow: