[]) => {
+ const rowData = rows.map((row) => row.original);
+ const csv = generateCsv(csvConfig)(rowData);
+ download(csvConfig)(csv);
+ };
+
+ const handleExportData = () => {
+ const csv = generateCsv(csvConfig)(data);
+ download(csvConfig)(csv);
+ };
+
return (
-
-
История выплат
-
+ История выплат
+
-
);
}
\ No newline at end of file
diff --git a/src/components/ReferralsTable.tsx b/src/components/ReferralsTable.tsx
index 8bb43d2..d70e67e 100644
--- a/src/components/ReferralsTable.tsx
+++ b/src/components/ReferralsTable.tsx
@@ -1,6 +1,9 @@
import { useEffect, useState, useMemo } from 'react';
-import { MaterialReactTable, MRT_ColumnDef } from 'material-react-table';
+import { MaterialReactTable, MRT_ColumnDef, MRT_Row, useMaterialReactTable } from 'material-react-table';
import styles from "../styles/stat.module.css";
+import { Box, Button } from '@mui/material';
+import FileDownloadIcon from '@mui/icons-material/FileDownload';
+import { mkConfig, generateCsv, download } from 'export-to-csv';
function formatCurrency(amount: number) {
return amount?.toLocaleString("ru-RU", {
@@ -35,17 +38,44 @@ export default function ReferralsTable({ filters, reloadKey }: { filters: { date
[]
);
- return (
-
- );
+ const csvConfig = mkConfig({
+ fieldSeparator: ',',
+ decimalSeparator: '.',
+ useKeysAsHeaders: true,
+ });
+
+ const table = useMaterialReactTable({
+ columns,
+ data,
+ enableRowSelection: false,
+ renderTopToolbarCustomActions: ({ table }) => (
+
+
+
+
+
+ ),
+ muiTableBodyCellProps: { sx: { fontSize: 14 } },
+ muiTableHeadCellProps: { sx: { fontWeight: 700 } },
+ initialState: { pagination: { pageSize: 10, pageIndex: 0 } },
+ });
+
+ const handleExportRows = (rows: MRT_Row[]) => {
+ const rowData = rows.map((row) => row.original);
+ const csv = generateCsv(csvConfig)(rowData);
+ download(csvConfig)(csv);
+ };
+
+ const handleExportData = () => {
+ const csv = generateCsv(csvConfig)(data);
+ download(csvConfig)(csv);
+ };
+
+ return ;
}
\ No newline at end of file
diff --git a/src/components/SalesTable.tsx b/src/components/SalesTable.tsx
index fa1d5cc..5a070e9 100644
--- a/src/components/SalesTable.tsx
+++ b/src/components/SalesTable.tsx
@@ -1,6 +1,9 @@
import { useEffect, useState, useMemo } from 'react';
-import { MaterialReactTable, MRT_ColumnDef } from 'material-react-table';
+import { MaterialReactTable, MRT_ColumnDef, MRT_Row, useMaterialReactTable } from 'material-react-table';
import styles from "../styles/stat.module.css";
+import { Box, Button } from '@mui/material';
+import FileDownloadIcon from '@mui/icons-material/FileDownload';
+import { mkConfig, generateCsv, download } from 'export-to-csv';
function formatCurrency(amount: number) {
return amount?.toLocaleString("ru-RU", {
@@ -36,17 +39,44 @@ export default function SalesTable({ filters, reloadKey }: { filters: { dateStar
[]
);
- return (
-
- );
+ const csvConfig = mkConfig({
+ fieldSeparator: ',',
+ decimalSeparator: '.',
+ useKeysAsHeaders: true,
+ });
+
+ const table = useMaterialReactTable({
+ columns,
+ data,
+ enableRowSelection: false,
+ renderTopToolbarCustomActions: ({ table }) => (
+
+
+
+
+
+ ),
+ muiTableBodyCellProps: { sx: { fontSize: 14 } },
+ muiTableHeadCellProps: { sx: { fontWeight: 700 } },
+ initialState: { pagination: { pageSize: 10, pageIndex: 0 } },
+ });
+
+ const handleExportRows = (rows: MRT_Row[]) => {
+ const rowData = rows.map((row) => row.original);
+ const csv = generateCsv(csvConfig)(rowData);
+ download(csvConfig)(csv);
+ };
+
+ const handleExportData = () => {
+ const csv = generateCsv(csvConfig)(data);
+ download(csvConfig)(csv);
+ };
+
+ return ;
}
\ No newline at end of file