Spaces:
Running
Running
Heaven K Claude Opus 4.6 (1M context) commited on
Commit ·
753edf0
1
Parent(s): 61094eb
fix: Exporter button now exports all scanned data fast
Browse filesUses the fast /transactions/export endpoint instead of the paginated
one, exports ALL transactions (not limited by current page), and
uses fixed column widths to avoid slow computation.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
packages/web/src/components/dashboard/TransactionTable.tsx
CHANGED
|
@@ -133,52 +133,43 @@ export default function TransactionTable() {
|
|
| 133 |
const handleExport = useCallback(async () => {
|
| 134 |
setExporting(true);
|
| 135 |
try {
|
| 136 |
-
//
|
| 137 |
const params = new URLSearchParams();
|
| 138 |
-
params.set('limit', '10000');
|
| 139 |
-
if (filters.search) params.set('search', filters.search);
|
| 140 |
if (filters.branch) params.set('branch', filters.branch);
|
| 141 |
-
if (filters.status) params.set('status', filters.status);
|
| 142 |
-
if (filters.reviewed) params.set('reviewed', filters.reviewed);
|
| 143 |
if (filters.from) params.set('from', filters.from);
|
| 144 |
if (filters.to) params.set('to', filters.to);
|
| 145 |
-
params.set('sortBy', filters.sortBy || 'date');
|
| 146 |
-
params.set('sortOrder', filters.sortOrder || 'desc');
|
| 147 |
|
| 148 |
-
const result = await api.get<{ transactions: any[] }>(`/transactions?${params}`);
|
| 149 |
const rows = result.transactions;
|
| 150 |
|
| 151 |
if (rows.length === 0) return;
|
| 152 |
|
| 153 |
// Build worksheet data
|
| 154 |
-
const wsData = rows.map((tx: any) => {
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
[t('table.status')]: tx.reviewed ? t('status.verified') : t('status.notVerified'),
|
| 166 |
-
'Email': tx.recipientEmail || '',
|
| 167 |
-
'Message': tx.message || '',
|
| 168 |
-
};
|
| 169 |
-
});
|
| 170 |
|
| 171 |
const ws = XLSX.utils.json_to_sheet(wsData);
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
|
|
|
|
|
|
| 182 |
|
| 183 |
const wb = XLSX.utils.book_new();
|
| 184 |
XLSX.utils.book_append_sheet(wb, ws, 'Transactions');
|
|
|
|
| 133 |
const handleExport = useCallback(async () => {
|
| 134 |
setExporting(true);
|
| 135 |
try {
|
| 136 |
+
// Use fast export endpoint with current filters
|
| 137 |
const params = new URLSearchParams();
|
|
|
|
|
|
|
| 138 |
if (filters.branch) params.set('branch', filters.branch);
|
|
|
|
|
|
|
| 139 |
if (filters.from) params.set('from', filters.from);
|
| 140 |
if (filters.to) params.set('to', filters.to);
|
|
|
|
|
|
|
| 141 |
|
| 142 |
+
const result = await api.get<{ transactions: any[] }>(`/transactions/export?${params}`);
|
| 143 |
const rows = result.transactions;
|
| 144 |
|
| 145 |
if (rows.length === 0) return;
|
| 146 |
|
| 147 |
// Build worksheet data
|
| 148 |
+
const wsData = rows.map((tx: any) => ({
|
| 149 |
+
[t('table.date')]: tx.date ? new Date(tx.date).toLocaleDateString('fr-CA', { timeZone: 'America/Toronto' }) : '',
|
| 150 |
+
[t('table.sender')]: tx.sender || '',
|
| 151 |
+
[t('table.amount')]: tx.amount,
|
| 152 |
+
'Currency': tx.currency || 'CAD',
|
| 153 |
+
[t('table.reference')]: tx.reference || '',
|
| 154 |
+
[t('table.branch')]: tx.branch || 'Montreal',
|
| 155 |
+
[t('table.status')]: tx.reviewed ? t('status.verified') : t('status.notVerified'),
|
| 156 |
+
'Email': tx.recipientEmail || '',
|
| 157 |
+
'Message': tx.message || '',
|
| 158 |
+
}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
|
| 160 |
const ws = XLSX.utils.json_to_sheet(wsData);
|
| 161 |
+
// Fixed column widths for speed
|
| 162 |
+
ws['!cols'] = [
|
| 163 |
+
{ wch: 12 }, // Date
|
| 164 |
+
{ wch: 25 }, // Sender
|
| 165 |
+
{ wch: 12 }, // Amount
|
| 166 |
+
{ wch: 6 }, // Currency
|
| 167 |
+
{ wch: 20 }, // Reference
|
| 168 |
+
{ wch: 20 }, // Branch
|
| 169 |
+
{ wch: 12 }, // Status
|
| 170 |
+
{ wch: 35 }, // Email
|
| 171 |
+
{ wch: 30 }, // Message
|
| 172 |
+
];
|
| 173 |
|
| 174 |
const wb = XLSX.utils.book_new();
|
| 175 |
XLSX.utils.book_append_sheet(wb, ws, 'Transactions');
|