From e67c74b60e8b5a897fa032e6e152ca0362d5a8d5 Mon Sep 17 00:00:00 2001
From: Reshmi <revas.nair@gmail.com>
Date: Tue, 16 Jan 2024 00:41:56 +0530
Subject: [PATCH] Added upload schedule file validations

---
 asessorScheduler.js |  2 +-
 backgroundWorker.js |  2 +-
 index.js            | 10 ----------
 3 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/asessorScheduler.js b/asessorScheduler.js
index 9a8af4b..347aa93 100644
--- a/asessorScheduler.js
+++ b/asessorScheduler.js
@@ -9,7 +9,7 @@ const UPDATE_ASSESSMENT_ENDPOINT = "/rest/assessorUpdateForm"
 const SCHEDULES_ENDPOINT = "/rest/getAssessmentSchedule";
 const TARGET_URL = process.env.TARGET_URL || "https://hasura.upsmfac.org";
 const REACT_APP_NODE_URL = process.env.REACT_APP_API_URL || "https://uphrh.in/api/api";
-const AUTH_TOKEN = process.env.REACT_APP_AUTH_TOKEN || "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJSR3RkMkZzeG1EMnJER3I4dkJHZ0N6MVhyalhZUzBSSyJ9.kMLn6177rvY53i0RAN3SPD5m3ctwaLb32pMYQ65nBdA";
+const AUTH_TOKEN = process.env.REACT_APP_AUTH_TOKEN;
 
 // Creating an Axios instance with custom headers
 const axiosInstance = axios.create({
diff --git a/backgroundWorker.js b/backgroundWorker.js
index 7aa5e1e..a5470ed 100644
--- a/backgroundWorker.js
+++ b/backgroundWorker.js
@@ -2,7 +2,7 @@ import axios from "axios";
 import async from "async";
 const targetURL = process.env.TARGET_URL || "https://hasura.upsmfac.org";
 const REACT_APP_NODE_URL = process.env.REACT_APP_API_URL || "https://uphrh.in/api/api";
-const AUTH_TOKEN = process.env.REACT_APP_AUTH_TOKEN || "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJSR3RkMkZzeG1EMnJER3I4dkJHZ0N6MVhyalhZUzBSSyJ9.kMLn6177rvY53i0RAN3SPD5m3ctwaLb32pMYQ65nBdA";
+const AUTH_TOKEN = process.env.REACT_APP_AUTH_TOKEN;
 
 const getBulkUploadAssessorSchedule = '/api/rest/getBulkUploadAssessorSchedule';
 const filterAssessments = '/api/rest/filterAssessments';
diff --git a/index.js b/index.js
index a177db0..8da0220 100644
--- a/index.js
+++ b/index.js
@@ -175,7 +175,6 @@ app.post('/upload/assessor/schedule', upload.single('file'), async(req, res) =>
 
     const results = [];
     const header = [];
-  //  var invalidFile = true;
     // Iterate over rows and columns
     worksheet.eachRow((row, rowNumber) => {
       const rowData = {};
@@ -196,18 +195,13 @@ app.post('/upload/assessor/schedule', upload.single('file'), async(req, res) =>
               cellValue = cell.value;
               rowData[header [colNumber]] = cellValue;
             }
-            //console.log (cellValue + ": "+header [colNumber]);
             if(cellValue.length<=1){
               console.error("Invalid data format");
               throw new BadRequestError("Invalid data format : "+cellValue );
-              //invalidFile = true;
-              //return;
             }
           }else{
             console.error("Invalid file format");
             throw new BadRequestError("Invalid file format : "+header [colNumber] );
-            //invalidFile = true;
-            //return;
           }
         }
       });
@@ -223,9 +217,6 @@ app.post('/upload/assessor/schedule', upload.single('file'), async(req, res) =>
     if(results.length===0){
       throw new BadRequestError("Invalid file format");
     }
-    //if(invalidFile){
-   //     return res;
-    //} else{
       results.forEach((item) => {
         item["process_id"]=processId;
         item["uploaded_by"]=userId;
@@ -249,7 +240,6 @@ app.post('/upload/assessor/schedule', upload.single('file'), async(req, res) =>
       // Process the parsed CSV data
       return res.json({ data: results });
         
-   // }
   } catch (error) {
     if (error instanceof BadRequestError) {
       console.error(`Caught BadRequestError: ${error.message}`);
-- 
GitLab