From 6218fc3c12595a484cbbcd0609f8abd5c9c93031 Mon Sep 17 00:00:00 2001 From: sebseb7 Date: Fri, 1 Aug 2025 14:03:03 +0200 Subject: [PATCH] Refactor CSV import API call in CSVImportDialog to use a structured request body. Increase JSON payload limit in index.js to support larger CSV imports. --- client/src/components/CSVImportDialog.js | 13 ++++++++----- src/index.js | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/client/src/components/CSVImportDialog.js b/client/src/components/CSVImportDialog.js index 9d8718d..bb7be05 100644 --- a/client/src/components/CSVImportDialog.js +++ b/client/src/components/CSVImportDialog.js @@ -138,11 +138,14 @@ class CSVImportDialog extends Component { this.setState({ importing: true, error: null }); try { - const response = await this.authService.apiCall('/data/import-csv-transactions', 'POST', { - transactions: csvData, - headers: headers, - filename: file.name, - batchId: `import_${Date.now()}_${file.name}` + const response = await this.authService.apiCall('/data/import-csv-transactions', { + method: 'POST', + body: JSON.stringify({ + transactions: csvData, + headers: headers, + filename: file.name, + batchId: `import_${Date.now()}_${file.name}` + }) }); if (response && response.ok) { diff --git a/src/index.js b/src/index.js index 6a93b08..9e87cb7 100644 --- a/src/index.js +++ b/src/index.js @@ -14,7 +14,7 @@ const PORT = process.env.PORT || 5000; // Middleware app.use(cors()); -app.use(express.json()); +app.use(express.json({ limit: '10mb' })); // Increased limit for CSV imports // Routes app.use('/api/auth', authRoutes);