From ee397c8047b44a4382cb7c9c0bcc8b1bbad78a13 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sun, 26 Dec 2021 20:54:53 +0100 Subject: [PATCH] Bugfix/fix file type detection for import (#587) * Fix file type detection ("application/vnd.ms-excel" instead of "text/csv") * Update changelog --- CHANGELOG.md | 14 ++++++++++---- .../transactions/transactions-page.component.ts | 7 +++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 297c488d1..b51725273 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,16 +5,22 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Changed + +- Upgraded `prisma` from version `3.6.0` to `3.7.0` + +### Fixed + +- Fixed the file type detection in the import functionality for transactions + ## 1.95.0 - 26.12.2021 ### Added - Added a warning to the log if the data gathering fails -### Changed - -- Upgraded `prisma` from version `3.6.0` to `3.7.0` - ### Fixed - Filtered potential `null` currencies 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: []