From f62abb3e8b70f2d9562f2ff926ab57fde4a29b34 Mon Sep 17 00:00:00 2001 From: Disha Talreja Date: Tue, 22 Feb 2022 17:21:23 +0530 Subject: [PATCH 1/3] Implemented: logic to parse csv file and display in console(#22c8vdr) --- src/utils/index.ts | 6 ++--- src/views/PurchaseOrder.vue | 44 ++++++++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/utils/index.ts b/src/utils/index.ts index 3904faf2..7e6f2c9f 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -58,16 +58,16 @@ const showToast = async (message: string) => { // ['Jake', '33', 'c'], // ['Jill', '30', 'd']] -const parseCsv = async (file: File, options: any) => { +const parseCsv = async (file: File, options?: any) => { return new Promise ((resolve, reject) => { Papa.parse(file, { - header: false, + header: true, skipEmptyLines: true, complete: function (results: any) { if (results.errors.length) { reject(results.error) } else { - resolve(results) + resolve(results.data) } }, ...options diff --git a/src/views/PurchaseOrder.vue b/src/views/PurchaseOrder.vue index 45bf1912..50625969 100644 --- a/src/views/PurchaseOrder.vue +++ b/src/views/PurchaseOrder.vue @@ -11,9 +11,9 @@
- {{ $t("Purchase order") }} - - {{ $t("Upload") }} + {{ $t("Purchase order") }} + +
@@ -44,9 +44,10 @@ -