datastake-daf 0.6.813 → 0.6.814
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.
- package/build/favicon.ico +0 -0
- package/build/logo192.png +0 -0
- package/build/logo512.png +0 -0
- package/build/manifest.json +25 -0
- package/build/robots.txt +3 -0
- package/dist/components/index.js +3056 -4315
- package/dist/hooks/index.js +4 -11
- package/dist/layouts/index.js +478 -464
- package/dist/pages/index.js +490 -576
- package/dist/services/index.js +6 -56
- package/dist/style/datastake/mapbox-gl.css +330 -0
- package/dist/utils/index.js +483 -492
- package/package.json +1 -1
- package/src/@daf/core/components/AuthForm/index.jsx +3 -12
- package/src/@daf/core/components/Icon/configs/index.js +3 -1
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/TopContributors/index.jsx +1 -0
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/hook.js +1 -0
- package/src/@daf/core/components/Screens/Admin/AdminDashboard/components/UserStatistics/UserGrowth/index.jsx +3 -1
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/index.jsx +51 -51
- package/src/@daf/core/components/Screens/Admin/AdminModals/CombineSubjects/index.jsx +1 -6
- package/src/@daf/core/components/Screens/Admin/AdminModals/NewAccount/index.jsx +31 -56
- package/src/@daf/core/components/Screens/Admin/AdminModals/NewUser/index.jsx +10 -36
- package/src/@daf/core/components/Screens/Admin/AdminModals/TransferRights/index.jsx +1 -1
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Accounts.jsx +10 -37
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Dashboard.jsx +2 -2
- package/src/@daf/core/components/Screens/Admin/AdminScreens/index.js +0 -2
- package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/helper.js +30 -22
- package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/index.jsx +13 -25
- package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/index.jsx +2 -17
- package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/index.jsx +13 -27
- package/src/@daf/core/components/Screens/Admin/AdminTables/UserTable/index.jsx +1 -0
- package/src/@daf/core/components/Screens/Admin/AdminTables/components/index.jsx +2 -4
- package/src/@daf/core/components/Screens/Admin/AdminTables/hook.js +0 -3
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Edit/index.jsx +9 -12
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/index.jsx +4 -16
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/View/helpers.js +17 -9
- package/src/@daf/core/components/Screens/Admin/AdminViews/index.jsx +8 -9
- package/src/@daf/core/components/Screens/Admin/AppInvitation/index.jsx +99 -124
- package/src/@daf/core/components/Screens/Admin/adminRoutes.js +1 -48
- package/src/@daf/hooks/useAdminDashboard.js +4 -7
- package/src/@daf/pages/View/hooks/useViewActions.js +0 -13
- package/src/@daf/pages/View/hooks/useViewPermissions.js +0 -16
- package/src/@daf/pages/View/index.jsx +4 -29
- package/src/@daf/services/AdminService.js +5 -47
- package/src/@daf/services/DashboardService.js +3 -3
- package/src/@daf/utils/filters.js +15 -13
- package/src/constants/locales/en/translation.js +0 -13
- package/src/helpers/copyToClipboard.js +0 -60
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Documents.jsx +0 -81
- package/src/@daf/core/components/Screens/Admin/AdminScreens/Events.jsx +0 -77
- package/src/@daf/core/components/Screens/Admin/AdminTables/DocumentsTable/column.js +0 -127
- package/src/@daf/core/components/Screens/Admin/AdminTables/DocumentsTable/helper.js +0 -43
- package/src/@daf/core/components/Screens/Admin/AdminTables/DocumentsTable/index.jsx +0 -201
- package/src/@daf/core/components/Screens/Admin/AdminTables/EventsTable/column.js +0 -146
- package/src/@daf/core/components/Screens/Admin/AdminTables/EventsTable/helper.js +0 -58
- package/src/@daf/core/components/Screens/Admin/AdminTables/EventsTable/index.jsx +0 -176
|
@@ -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 {
|
|
70
|
-
|
|
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
|
-
|
|
76
|
-
|
|
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,17 +1,4 @@
|
|
|
1
1
|
const en = {
|
|
2
|
-
"admin::events": "Events",
|
|
3
|
-
"admin::document": "Documents",
|
|
4
|
-
"events": "Events",
|
|
5
|
-
"merge-locations": "Merge Locations",
|
|
6
|
-
"edit-account": "Edit Account",
|
|
7
|
-
"Are-you-sure-you-want-to-remove-the-user-from-this-account?": "Are you sure you want to remove the user from this account?",
|
|
8
|
-
"The-user-will-lose-access-to-the-application-and-to-all-data-created-for-this-account.": "The user will lose access to the application and to all data created for this account.",
|
|
9
|
-
"merge": "Merge",
|
|
10
|
-
"Are-you-sure-you-want-to-suspend-this-account?": "Are you sure you want to suspend this account?",
|
|
11
|
-
"Associated-users-will-lose-access-to-the-application-and-to-all-data-created-for-this-account.": "Associated users will lose access to the application and to all data created for this account.",
|
|
12
|
-
"current_subjects": "Current Subjects",
|
|
13
|
-
"merged_output": "Merged Output",
|
|
14
|
-
"merge-subjects": "Merge Subjects",
|
|
15
2
|
"All Data": "All Data",
|
|
16
3
|
"sbg-admin::remove-user-title":"Remove User Title",
|
|
17
4
|
"sbg-admin::remove-user-body":"Remove User Body",
|
|
@@ -41,63 +41,3 @@ export const copyToClipboard = (id) => {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Copies a string directly to the clipboard.
|
|
47
|
-
*
|
|
48
|
-
* This function takes a string and copies it to the clipboard.
|
|
49
|
-
* It handles browser compatibility issues between IE and modern browsers.
|
|
50
|
-
*
|
|
51
|
-
* @param {string} text - The string to copy to clipboard
|
|
52
|
-
* @returns {Promise<boolean>} - Returns true if copying succeeded, false otherwise
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* copyStringToClipboard('Text to copy'); // Copies "Text to copy" to clipboard
|
|
56
|
-
*/
|
|
57
|
-
export const copyStringToClipboard = async (text) => {
|
|
58
|
-
if (!text) {
|
|
59
|
-
console.warn("No text provided to copy");
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Try modern Clipboard API first
|
|
64
|
-
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
65
|
-
try {
|
|
66
|
-
await navigator.clipboard.writeText(text);
|
|
67
|
-
return true;
|
|
68
|
-
} catch (ex) {
|
|
69
|
-
console.warn("Clipboard API failed, trying fallback:", ex);
|
|
70
|
-
// Fall through to fallback methods
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// Fallback for older browsers or when Clipboard API fails
|
|
75
|
-
if (window.clipboardData && window.clipboardData.setData) {
|
|
76
|
-
// IE: prevent textarea being shown while dialog is visible
|
|
77
|
-
return window.clipboardData.setData("Text", text);
|
|
78
|
-
} else if (document.queryCommandSupported &&
|
|
79
|
-
document.queryCommandSupported("copy")) {
|
|
80
|
-
var textarea = document.createElement("textarea");
|
|
81
|
-
textarea.textContent = text;
|
|
82
|
-
// Prevent scrolling to bottom of page in MS Edge
|
|
83
|
-
textarea.style.position = "fixed";
|
|
84
|
-
textarea.style.opacity = "0";
|
|
85
|
-
textarea.style.left = "-9999px";
|
|
86
|
-
document.body.appendChild(textarea);
|
|
87
|
-
textarea.select();
|
|
88
|
-
try {
|
|
89
|
-
// Security exception may be thrown by some browsers
|
|
90
|
-
const success = document.execCommand("copy");
|
|
91
|
-
return success;
|
|
92
|
-
} catch (ex) {
|
|
93
|
-
console.warn("Copy to clipboard failed.", ex);
|
|
94
|
-
return false;
|
|
95
|
-
} finally {
|
|
96
|
-
document.body.removeChild(textarea);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import React, { useCallback } from "react";
|
|
2
|
-
import { message } from "antd";
|
|
3
|
-
import DocumentsTable from "../AdminTables/DocumentsTable/index.jsx";
|
|
4
|
-
/**
|
|
5
|
-
* Admin Location Screen Wrapper
|
|
6
|
-
* This is a ready-to-use route component that can be configured per application
|
|
7
|
-
*
|
|
8
|
-
* @param {Object} config - Application configuration
|
|
9
|
-
* @param {string} config.appName - Application name
|
|
10
|
-
* @param {string} config.module - Module identifier (APP constant)
|
|
11
|
-
* @param {Function} config.goTo - Navigation function
|
|
12
|
-
* @param {Function} config.t - Translation function
|
|
13
|
-
* @param {Object} config.location - Router location object
|
|
14
|
-
* @param {boolean} config.isMobile - Is mobile viewport
|
|
15
|
-
* @param {Function} config.getRedirectLink - Function to get redirect links
|
|
16
|
-
* @param {Object} config.AdminService - Admin service with methods
|
|
17
|
-
* @param {Object} config.options - Options object with categories, countries, etc.
|
|
18
|
-
* @param {Function} config.handleError - Error handling function
|
|
19
|
-
* @param {number} config.defaultPageSize - Default pagination page size
|
|
20
|
-
* @param {string} config.view - View identifier
|
|
21
|
-
* @param {string} config.headerTitle - Header title for the table
|
|
22
|
-
* @param {Array} config.breadcrumbs - Breadcrumbs configuration
|
|
23
|
-
* @param {any} config.refetchTrigger - Trigger to refetch data
|
|
24
|
-
* @param {Function} config.getData - Optional custom getData function
|
|
25
|
-
*/
|
|
26
|
-
export default function AdminLocationScreen({ config }) {
|
|
27
|
-
const {
|
|
28
|
-
appName = "app",
|
|
29
|
-
module,
|
|
30
|
-
goTo,
|
|
31
|
-
t,
|
|
32
|
-
location,
|
|
33
|
-
isMobile,
|
|
34
|
-
getRedirectLink,
|
|
35
|
-
AdminService,
|
|
36
|
-
options,
|
|
37
|
-
handleError,
|
|
38
|
-
defaultPageSize = 20,
|
|
39
|
-
view,
|
|
40
|
-
headerTitle = "documents",
|
|
41
|
-
breadcrumbs,
|
|
42
|
-
refetchTrigger,
|
|
43
|
-
getData,
|
|
44
|
-
user,
|
|
45
|
-
} = config;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const getSubjects = useCallback((params) => {
|
|
50
|
-
if (getData) {
|
|
51
|
-
return getData(params);
|
|
52
|
-
}
|
|
53
|
-
return AdminService.getItems({ item: 'document', params });
|
|
54
|
-
}, [getData, AdminService]);
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<DocumentsTable
|
|
58
|
-
t={t}
|
|
59
|
-
goTo={goTo}
|
|
60
|
-
getRedirectLink={getRedirectLink}
|
|
61
|
-
location={location}
|
|
62
|
-
module={module}
|
|
63
|
-
headerTitle={headerTitle}
|
|
64
|
-
getData={getSubjects}
|
|
65
|
-
isMobile={isMobile}
|
|
66
|
-
defaultPageSize={defaultPageSize}
|
|
67
|
-
view={view}
|
|
68
|
-
breadcrumbs={breadcrumbs}
|
|
69
|
-
refetchTrigger={refetchTrigger}
|
|
70
|
-
config={{
|
|
71
|
-
options: {
|
|
72
|
-
category: options?.category,
|
|
73
|
-
countries: options?.countries,
|
|
74
|
-
},
|
|
75
|
-
}}
|
|
76
|
-
user={user}
|
|
77
|
-
options={options}
|
|
78
|
-
/>
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import React, { useCallback } from "react";
|
|
2
|
-
import { message } from "antd";
|
|
3
|
-
import EventsTable from "../AdminTables/EventsTable/index.jsx";
|
|
4
|
-
/**
|
|
5
|
-
* Admin Location Screen Wrapper
|
|
6
|
-
* This is a ready-to-use route component that can be configured per application
|
|
7
|
-
*
|
|
8
|
-
* @param {Object} config - Application configuration
|
|
9
|
-
* @param {string} config.appName - Application name
|
|
10
|
-
* @param {string} config.module - Module identifier (APP constant)
|
|
11
|
-
* @param {Function} config.goTo - Navigation function
|
|
12
|
-
* @param {Function} config.t - Translation function
|
|
13
|
-
* @param {Object} config.location - Router location object
|
|
14
|
-
* @param {boolean} config.isMobile - Is mobile viewport
|
|
15
|
-
* @param {Function} config.getRedirectLink - Function to get redirect links
|
|
16
|
-
* @param {Object} config.AdminService - Admin service with methods
|
|
17
|
-
* @param {Object} config.options - Options object with categories, countries, etc.
|
|
18
|
-
* @param {Function} config.handleError - Error handling function
|
|
19
|
-
* @param {number} config.defaultPageSize - Default pagination page size
|
|
20
|
-
* @param {string} config.view - View identifier
|
|
21
|
-
* @param {string} config.headerTitle - Header title for the table
|
|
22
|
-
* @param {Array} config.breadcrumbs - Breadcrumbs configuration
|
|
23
|
-
* @param {any} config.refetchTrigger - Trigger to refetch data
|
|
24
|
-
* @param {Function} config.getData - Optional custom getData function
|
|
25
|
-
*/
|
|
26
|
-
export default function AdminEventsScreen({ config }) {
|
|
27
|
-
const {
|
|
28
|
-
appName = "app",
|
|
29
|
-
module,
|
|
30
|
-
goTo,
|
|
31
|
-
t,
|
|
32
|
-
location,
|
|
33
|
-
isMobile,
|
|
34
|
-
getRedirectLink,
|
|
35
|
-
AdminService,
|
|
36
|
-
options,
|
|
37
|
-
handleError,
|
|
38
|
-
defaultPageSize = 20,
|
|
39
|
-
view,
|
|
40
|
-
headerTitle = "events",
|
|
41
|
-
breadcrumbs,
|
|
42
|
-
refetchTrigger,
|
|
43
|
-
getData,
|
|
44
|
-
user,
|
|
45
|
-
} = config;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const getSubjects = useCallback((params) => {
|
|
50
|
-
if (getData) {
|
|
51
|
-
return getData(params);
|
|
52
|
-
}
|
|
53
|
-
return AdminService.getItems({ item: 'event', params });
|
|
54
|
-
}, [getData, AdminService]);
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<EventsTable
|
|
58
|
-
t={t}
|
|
59
|
-
goTo={goTo}
|
|
60
|
-
getRedirectLink={getRedirectLink}
|
|
61
|
-
location={location}
|
|
62
|
-
module={module}
|
|
63
|
-
headerTitle={headerTitle}
|
|
64
|
-
getData={getSubjects}
|
|
65
|
-
isMobile={isMobile}
|
|
66
|
-
defaultPageSize={defaultPageSize}
|
|
67
|
-
view={view}
|
|
68
|
-
breadcrumbs={breadcrumbs}
|
|
69
|
-
refetchTrigger={refetchTrigger}
|
|
70
|
-
config={{
|
|
71
|
-
options:options}}
|
|
72
|
-
user={user}
|
|
73
|
-
options={options}
|
|
74
|
-
/>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { Checkbox, Tooltip, Avatar } from "antd";
|
|
2
|
-
import CustomIcon from "../../../../Icon/CustomIcon.jsx";
|
|
3
|
-
import { findOptions } from "../../../../../../../helpers/StringHelper.js";
|
|
4
|
-
import { renderDateFormatted } from "../../../../../../../helpers/Forms.js";
|
|
5
|
-
export const getColumns = ({
|
|
6
|
-
t,
|
|
7
|
-
goTo = () => {},
|
|
8
|
-
show = "show",
|
|
9
|
-
getRedirectLink = () => {},
|
|
10
|
-
token,
|
|
11
|
-
selectedSubjects,
|
|
12
|
-
setSelectedSubjects,
|
|
13
|
-
selectOptions,
|
|
14
|
-
entity,
|
|
15
|
-
options,
|
|
16
|
-
}) => {
|
|
17
|
-
const cols = [
|
|
18
|
-
{
|
|
19
|
-
title: "",
|
|
20
|
-
dataIndex: "select",
|
|
21
|
-
key: "select",
|
|
22
|
-
width: 50,
|
|
23
|
-
show: true,
|
|
24
|
-
render: (v, all) => {
|
|
25
|
-
if (all.empty) {
|
|
26
|
-
return <div className="daf-default-cell" />;
|
|
27
|
-
}
|
|
28
|
-
return (
|
|
29
|
-
<Checkbox
|
|
30
|
-
onChange={() =>
|
|
31
|
-
setSelectedSubjects((prev) => {
|
|
32
|
-
const isSelected = prev?.some((p) => p.id === all.id);
|
|
33
|
-
if (isSelected) {
|
|
34
|
-
return prev.filter((p) => p.id !== all.id);
|
|
35
|
-
}
|
|
36
|
-
return [...prev, all];
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
checked={selectedSubjects?.some((p) => p.id === all.id)}
|
|
40
|
-
disabled={
|
|
41
|
-
selectedSubjects?.length >= 3 &&
|
|
42
|
-
!selectedSubjects?.some((p) => p.id === all.id)
|
|
43
|
-
}
|
|
44
|
-
/>
|
|
45
|
-
);
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
title: t("ID"),
|
|
50
|
-
dataIndex: "datastakeId",
|
|
51
|
-
key: "datastakeId",
|
|
52
|
-
ellipsis: true,
|
|
53
|
-
show: true,
|
|
54
|
-
render: (value, all) => {
|
|
55
|
-
if (all.empty) {
|
|
56
|
-
return <div className="daf-default-cell" />;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return <Tooltip title={value}>{value}</Tooltip>;
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
title: t("Title"),
|
|
64
|
-
dataIndex: "name",
|
|
65
|
-
key: "name",
|
|
66
|
-
ellipsis: true,
|
|
67
|
-
show: true,
|
|
68
|
-
render: (value, all) => {
|
|
69
|
-
if (all.empty) {
|
|
70
|
-
return <div className="daf-default-cell" />;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return <Tooltip title={value}>{value}</Tooltip>;
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
{
|
|
78
|
-
title: t("Date"),
|
|
79
|
-
dataIndex: "date",
|
|
80
|
-
key: "date",
|
|
81
|
-
show: true,
|
|
82
|
-
render: (value, all) => {
|
|
83
|
-
if (all.empty) {
|
|
84
|
-
return <div className="daf-default-cell" />;
|
|
85
|
-
}
|
|
86
|
-
return <Tooltip title={renderDateFormatted(value, "DD MMM YYYY", 'en')}>{renderDateFormatted(value, "DD MMM YYYY", 'en') }</Tooltip>;
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
title: t("Last Update"),
|
|
91
|
-
dataIndex: "updatedAt",
|
|
92
|
-
key: "updatedAt",
|
|
93
|
-
show: true,
|
|
94
|
-
render: (value, all) => {
|
|
95
|
-
if (all.empty) {
|
|
96
|
-
return <div className="daf-default-cell" />;
|
|
97
|
-
}
|
|
98
|
-
return <Tooltip title={renderDateFormatted(value, "DD MMM YYYY", 'en')}>{renderDateFormatted(value, "DD MMM YYYY", 'en')}</Tooltip>;
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
title: "",
|
|
103
|
-
dataIndex: "actions",
|
|
104
|
-
key: "actions",
|
|
105
|
-
width: 60,
|
|
106
|
-
show: true,
|
|
107
|
-
render: (value, all) => {
|
|
108
|
-
if (all.empty) {
|
|
109
|
-
return <div className="daf-default-cell" />;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return (
|
|
113
|
-
<div
|
|
114
|
-
className="cursor-pointer"
|
|
115
|
-
onClick={() => {
|
|
116
|
-
goTo(getRedirectLink(`/app/view/management-document/${all.id}`));
|
|
117
|
-
}}
|
|
118
|
-
>
|
|
119
|
-
<CustomIcon name="Link" width={18} height={18} />
|
|
120
|
-
</div>
|
|
121
|
-
);
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
];
|
|
125
|
-
|
|
126
|
-
return cols.filter((c) => c[show]);
|
|
127
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export const selectFiltersConfig = {
|
|
4
|
-
category: {
|
|
5
|
-
type: "select",
|
|
6
|
-
label: "Category",
|
|
7
|
-
placeholder: (t) => t("Category"),
|
|
8
|
-
style: { flex: 1 },
|
|
9
|
-
labelStyle: { flex: 1 },
|
|
10
|
-
getLabel: (option) => option.label,
|
|
11
|
-
getValue: (option) => option.value,
|
|
12
|
-
},
|
|
13
|
-
country: {
|
|
14
|
-
type: "select",
|
|
15
|
-
label: "Country",
|
|
16
|
-
placeholder: (t) => t("Country"),
|
|
17
|
-
style: { flex: 1 },
|
|
18
|
-
labelStyle: { flex: 1 },
|
|
19
|
-
getLabel: (option) => option.label,
|
|
20
|
-
getValue: (option) => option.value,
|
|
21
|
-
},
|
|
22
|
-
sources: {
|
|
23
|
-
type: "select",
|
|
24
|
-
label: "Sources",
|
|
25
|
-
placeholder: (t) => t("Sources"),
|
|
26
|
-
style: { flex: 1 },
|
|
27
|
-
labelStyle: { flex: 1 },
|
|
28
|
-
getLabel: (option) => option.label,
|
|
29
|
-
getValue: (option) => option.value,
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const filtersConfig = {
|
|
34
|
-
name: "",
|
|
35
|
-
datastakeId: "",
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export const defaultUrlParams = { activeTab: "active" };
|
|
39
|
-
|
|
40
|
-
export const checkboxConfig = {
|
|
41
|
-
name: "Name",
|
|
42
|
-
datastakeId: "ID",
|
|
43
|
-
};
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import { useState, useMemo } from "react";
|
|
2
|
-
import { useAdminTable } from "../hook";
|
|
3
|
-
import AdminTable from "../components/index.jsx";
|
|
4
|
-
import DAFTable from "../../../../Table/index.jsx";
|
|
5
|
-
import { theme, Tag, message } from "antd";
|
|
6
|
-
import CustomIcon from "../../../../Icon/CustomIcon.jsx";
|
|
7
|
-
import {
|
|
8
|
-
selectFiltersConfig,
|
|
9
|
-
filtersConfig,
|
|
10
|
-
defaultUrlParams,
|
|
11
|
-
checkboxConfig,
|
|
12
|
-
} from "./helper.js";
|
|
13
|
-
import { getColumns } from "./column.js";
|
|
14
|
-
const { useToken } = theme;
|
|
15
|
-
|
|
16
|
-
export default function DocumentsTable({
|
|
17
|
-
t = (text) => text,
|
|
18
|
-
isMobile,
|
|
19
|
-
goTo,
|
|
20
|
-
getRedirectLink,
|
|
21
|
-
location,
|
|
22
|
-
getData,
|
|
23
|
-
module,
|
|
24
|
-
config,
|
|
25
|
-
defaultPageSize = 20,
|
|
26
|
-
view,
|
|
27
|
-
headerTitle,
|
|
28
|
-
breadcrumbs,
|
|
29
|
-
refetchTrigger,
|
|
30
|
-
user,
|
|
31
|
-
options,
|
|
32
|
-
}) {
|
|
33
|
-
const [showFilters, setShowFilters] = useState(false);
|
|
34
|
-
const [hasError, setHasError] = useState(false);
|
|
35
|
-
const [selectedDocuments, setSelectedDocuments] = useState([]);
|
|
36
|
-
const { token } = useToken();
|
|
37
|
-
|
|
38
|
-
const getDataWithStringPagination = async ({ params }) => {
|
|
39
|
-
const { pagination, tab, filters, search, sort, ...otherParams } = params;
|
|
40
|
-
|
|
41
|
-
let paginationObj = { page: 1, pageSize: 20 };
|
|
42
|
-
if (pagination) {
|
|
43
|
-
try {
|
|
44
|
-
paginationObj = typeof pagination === 'string' ? JSON.parse(pagination) : pagination;
|
|
45
|
-
} catch (e) {
|
|
46
|
-
console.error('Failed to parse pagination', e);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const pageSize = Number(paginationObj.pageSize) || Number(paginationObj.take) || 20;
|
|
52
|
-
|
|
53
|
-
let pageNumber = 1;
|
|
54
|
-
|
|
55
|
-
if (paginationObj.page || paginationObj.current) {
|
|
56
|
-
pageNumber = Number(paginationObj.page) || Number(paginationObj.current);
|
|
57
|
-
} else if (typeof paginationObj.skip === 'number') {
|
|
58
|
-
|
|
59
|
-
pageNumber = Math.floor(paginationObj.skip / pageSize) + 1;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
pageNumber = pageNumber || 1;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
let activeTab = tab || "active";
|
|
66
|
-
if (!tab && filters) {
|
|
67
|
-
try {
|
|
68
|
-
const parsedFilters = typeof filters === 'string' ? JSON.parse(filters) : filters;
|
|
69
|
-
activeTab = parsedFilters.activeTab || "active";
|
|
70
|
-
} catch (e) {
|
|
71
|
-
activeTab = "active";
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const transformedParams = {
|
|
76
|
-
pagination: {
|
|
77
|
-
skip: pageNumber,
|
|
78
|
-
take: pageSize,
|
|
79
|
-
},
|
|
80
|
-
tab: activeTab,
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
return getData({ params: transformedParams });
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const {
|
|
87
|
-
filter,
|
|
88
|
-
activeTab,
|
|
89
|
-
canClearSearch,
|
|
90
|
-
totalPending,
|
|
91
|
-
data,
|
|
92
|
-
loading,
|
|
93
|
-
initFetchDone,
|
|
94
|
-
fetchData,
|
|
95
|
-
fetchPendingAccounts,
|
|
96
|
-
setLoading,
|
|
97
|
-
} = useAdminTable({
|
|
98
|
-
goTo,
|
|
99
|
-
location,
|
|
100
|
-
selectFiltersConfig,
|
|
101
|
-
view,
|
|
102
|
-
// defaultUrlParams,
|
|
103
|
-
module,
|
|
104
|
-
defaultPageSize,
|
|
105
|
-
filtersConfig,
|
|
106
|
-
getRedirectLink,
|
|
107
|
-
getData: getDataWithStringPagination,
|
|
108
|
-
refetchTrigger,
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
const selectOptions = useMemo(() => {
|
|
112
|
-
return {
|
|
113
|
-
category: config.options?.category,
|
|
114
|
-
country: config.options?.countries,
|
|
115
|
-
sources: [],
|
|
116
|
-
};
|
|
117
|
-
}, [config.options]);
|
|
118
|
-
|
|
119
|
-
const columns = useMemo(() => {
|
|
120
|
-
return getColumns({
|
|
121
|
-
t,
|
|
122
|
-
goTo,
|
|
123
|
-
token,
|
|
124
|
-
module,
|
|
125
|
-
selectedDocuments,
|
|
126
|
-
setSelectedDocuments,
|
|
127
|
-
getRedirectLink,
|
|
128
|
-
selectOptions,
|
|
129
|
-
entity: headerTitle,
|
|
130
|
-
options,
|
|
131
|
-
});
|
|
132
|
-
}, [t, goTo, module, token, selectedDocuments, getRedirectLink, selectOptions, headerTitle, options]);
|
|
133
|
-
|
|
134
|
-
console.log({data}, "data");
|
|
135
|
-
|
|
136
|
-
return (
|
|
137
|
-
<>
|
|
138
|
-
<AdminTable
|
|
139
|
-
filters={filter}
|
|
140
|
-
t={t}
|
|
141
|
-
headerTitle={headerTitle}
|
|
142
|
-
// actionButton={[
|
|
143
|
-
// {
|
|
144
|
-
// icon: "Merge",
|
|
145
|
-
// onClick: () => setIsModalOpen(true),
|
|
146
|
-
// tooltip: t("merge-subjects"),
|
|
147
|
-
// disabled: selectedDocuments.length < 2,
|
|
148
|
-
// },
|
|
149
|
-
// ]}
|
|
150
|
-
// tabs={getTabs({ t })}
|
|
151
|
-
isMobile={isMobile}
|
|
152
|
-
// activeTab={activeTab}
|
|
153
|
-
showFilters={showFilters}
|
|
154
|
-
setShowFilters={setShowFilters}
|
|
155
|
-
hasError={hasError}
|
|
156
|
-
setHasError={setHasError}
|
|
157
|
-
canClearSearch={canClearSearch}
|
|
158
|
-
selectOptions={selectOptions}
|
|
159
|
-
checkboxConfig={checkboxConfig}
|
|
160
|
-
defaultTableFilters={{}}
|
|
161
|
-
breadcrumbs={breadcrumbs}
|
|
162
|
-
>
|
|
163
|
-
{selectedDocuments.length > 0 && (
|
|
164
|
-
<div className="flex flex-row ml-6 mt-5" style={{ flexWrap: "wrap", gap: "8px" }}>
|
|
165
|
-
{selectedDocuments.map((document) => (
|
|
166
|
-
<Tag
|
|
167
|
-
key={document.id}
|
|
168
|
-
className="flex flex-row gap-2 items-center"
|
|
169
|
-
onClick={() =>
|
|
170
|
-
setSelectedDocuments((prev) => prev.filter((a) => a.id !== document.id))
|
|
171
|
-
}
|
|
172
|
-
style={{ cursor: "pointer" }}
|
|
173
|
-
>
|
|
174
|
-
<span>{document.name}</span>
|
|
175
|
-
<CustomIcon name="Close" size={10} />
|
|
176
|
-
</Tag>
|
|
177
|
-
))}
|
|
178
|
-
</div>
|
|
179
|
-
)}
|
|
180
|
-
<DAFTable
|
|
181
|
-
columns={columns}
|
|
182
|
-
data={data}
|
|
183
|
-
loading={loading}
|
|
184
|
-
hideOnLoading={false}
|
|
185
|
-
pagination={filter.pagination}
|
|
186
|
-
rowKey="id"
|
|
187
|
-
selectOptions={selectOptions}
|
|
188
|
-
doEmptyRows
|
|
189
|
-
setShowFilters={setShowFilters}
|
|
190
|
-
filtersConfig={selectFiltersConfig}
|
|
191
|
-
onFilterChange={filter.onFiltersChange}
|
|
192
|
-
showFilters={showFilters}
|
|
193
|
-
defaultFilters={filter.defaultFilters}
|
|
194
|
-
onChange={filter.onTableChange}
|
|
195
|
-
/>
|
|
196
|
-
</AdminTable>
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
</>
|
|
200
|
-
);
|
|
201
|
-
}
|