diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.cjs
similarity index 100%
rename from frontend/.eslintrc.js
rename to frontend/.eslintrc.cjs
diff --git a/frontend/src/components/DataTable/DataTable.jsx b/frontend/src/components/DataTable/DataTable.jsx
index b6f34b43dd..fd456407fa 100644
--- a/frontend/src/components/DataTable/DataTable.jsx
+++ b/frontend/src/components/DataTable/DataTable.jsx
@@ -6,47 +6,61 @@ import {
DeleteOutlined,
EllipsisOutlined,
RedoOutlined,
- ArrowRightOutlined,
ArrowLeftOutlined,
+ DownloadOutlined,
} from '@ant-design/icons';
+
import { Dropdown, Table, Button, Input } from 'antd';
import { PageHeader } from '@ant-design/pro-layout';
import { useSelector, useDispatch } from 'react-redux';
import { crud } from '@/redux/crud/actions';
import { selectListItems } from '@/redux/crud/selectors';
+
import useLanguage from '@/locale/useLanguage';
import { dataForTable } from '@/utils/dataStructure';
import { useMoney, useDate } from '@/settings';
-import { generate as uniqueId } from 'shortid';
-
import { useCrudContext } from '@/context/crud';
+import { exportCSV } from '@/utils/exportCSV';
+/* -------------------- ADD NEW ITEM -------------------- */
function AddNewItem({ config }) {
const { crudContextAction } = useCrudContext();
- const { collapsedBox, panel } = crudContextAction;
+ const { panel, collapsedBox } = crudContextAction;
const { ADD_NEW_ENTITY } = config;
- const handelClick = () => {
+ const handleClick = () => {
panel.open();
collapsedBox.close();
};
return (
- ,
- ,
+ }
+ >
+ Export CSV
+ ,
+
+ ,
]}
- style={{
- padding: '20px 0px',
- }}
- >
+ />
item._id}
dataSource={dataSource}
pagination={pagination}
loading={listIsLoading}
- onChange={handelDataTableLoad}
+ onChange={loadTable}
scroll={{ x: true }}
/>
>
);
-}
+}
\ No newline at end of file
diff --git a/frontend/src/utils/exportCSV.js b/frontend/src/utils/exportCSV.js
new file mode 100644
index 0000000000..58f1cd45f3
--- /dev/null
+++ b/frontend/src/utils/exportCSV.js
@@ -0,0 +1,29 @@
+export const exportCSV = (data, filename = 'export.csv') => {
+ if (!data || !data.length) return;
+
+ const headers = Object.keys(data[0]);
+
+ const csvRows = [
+ headers.join(','),
+ ...data.map((row) =>
+ headers.map((header) => JSON.stringify(row[header] ?? '')).join(',')
+ ),
+ ];
+
+ const csvContent = csvRows.join('\n');
+
+ const blob = new Blob([csvContent], {
+ type: 'text/csv;charset=utf-8;',
+ });
+
+ const url = URL.createObjectURL(blob);
+
+ const link = document.createElement('a');
+ link.href = url;
+ link.download = filename;
+ document.body.appendChild(link);
+ link.click();
+ document.body.removeChild(link);
+
+ URL.revokeObjectURL(url);
+};
\ No newline at end of file