From 7e386c6837f2d622ca03caa6d85c8cd55136ac11 Mon Sep 17 00:00:00 2001 From: "priyanka@TL" Date: Tue, 20 Feb 2024 21:31:01 +0530 Subject: [PATCH 1/2] removed empty rows --- src/services/userInvite.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/services/userInvite.js b/src/services/userInvite.js index 9a3980280..ea900fcb6 100644 --- a/src/services/userInvite.js +++ b/src/services/userInvite.js @@ -140,18 +140,23 @@ module.exports = class UserInviteHelper { try { const csvToJsonData = await csv().fromFile(csvFilePath) const header = Object.keys(csvToJsonData[0]) + const parsedCSVData = [] if (header.map((column) => column.toLowerCase()).includes('roles')) { // Process the data, split roles, and handle unquoted roles csvToJsonData.forEach((row) => { - const roles = row.roles.replace(/"/g, '').split(',') - row.roles = roles + if (row.name && row.email && row.roles) { + const roles = row.roles.replace(/"/g, '').split(',') + row.roles = roles + parsedCSVData.push(row) + } }) } + return { success: true, result: { - data: csvToJsonData, + data: parsedCSVData, }, } } catch (error) { From 586f421282b97c164f0951761df3ad1005c47b16 Mon Sep 17 00:00:00 2001 From: "priyanka@TL" Date: Tue, 20 Feb 2024 21:40:47 +0530 Subject: [PATCH 2/2] updated the logic --- src/services/userInvite.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/userInvite.js b/src/services/userInvite.js index ea900fcb6..d1a8f3b4b 100644 --- a/src/services/userInvite.js +++ b/src/services/userInvite.js @@ -145,7 +145,7 @@ module.exports = class UserInviteHelper { if (header.map((column) => column.toLowerCase()).includes('roles')) { // Process the data, split roles, and handle unquoted roles csvToJsonData.forEach((row) => { - if (row.name && row.email && row.roles) { + if (row.name || row.email || row.roles) { const roles = row.roles.replace(/"/g, '').split(',') row.roles = roles parsedCSVData.push(row)