From b17d58931bb504aa7b3da683be59e59bdacba36e Mon Sep 17 00:00:00 2001 From: Thomas <4159106+dtslvr@users.noreply.github.com> Date: Sun, 26 Dec 2021 20:31:28 +0100 Subject: [PATCH] Fix file type detection (application/vnd.ms-excel instead of text/csv) --- .../portfolio/transactions/transactions-page.component.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/client/src/app/pages/portfolio/transactions/transactions-page.component.ts b/apps/client/src/app/pages/portfolio/transactions/transactions-page.component.ts index 1827e156e..1178c8aea 100644 --- a/apps/client/src/app/pages/portfolio/transactions/transactions-page.component.ts +++ b/apps/client/src/app/pages/portfolio/transactions/transactions-page.component.ts @@ -188,7 +188,7 @@ export class TransactionsPageComponent implements OnDestroy, OnInit { const fileContent = readerEvent.target.result as string; try { - if (file.type === 'application/json') { + if (file.name.endsWith('.json')) { const content = JSON.parse(fileContent); if (!isArray(content.orders)) { @@ -203,11 +203,12 @@ export class TransactionsPageComponent implements OnDestroy, OnInit { this.handleImportSuccess(); } catch (error) { + console.error(error); this.handleImportError({ error, orders: content.orders }); } return; - } else if (file.type === 'text/csv') { + } else if (file.name.endsWith('.csv')) { try { await this.importTransactionsService.importCsv({ fileContent, @@ -217,6 +218,7 @@ export class TransactionsPageComponent implements OnDestroy, OnInit { this.handleImportSuccess(); } catch (error) { + console.error(error); this.handleImportError({ error: { error: { message: error?.error?.message ?? [error?.message] } @@ -230,6 +232,7 @@ export class TransactionsPageComponent implements OnDestroy, OnInit { throw new Error(); } catch (error) { + console.error(error); this.handleImportError({ error: { error: { message: ['Unexpected format'] } }, orders: []