Skip to content

Commit

Permalink
modify comments
Browse files Browse the repository at this point in the history
  • Loading branch information
darwin1501 committed Nov 2, 2021
1 parent 49a8112 commit 6f718f7
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions public/js/import_xls.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ disableImportBtn()
fileUploadInput.addEventListener('change',(event)=> {
selectedFile = event.target.files[0];
const fileFormat = selectedFile.name.split('.')[1];
console.log(fileFormat)
// check if file was excel format
if(fileFormat === 'xls' || fileFormat === 'xlsx'){
// valid file
// enable import button
Expand Down Expand Up @@ -68,19 +68,10 @@ btnImport.addEventListener('click',()=> {
);
// converted to JSON
let students = JSON.parse(JSON.stringify(rowObjejct));
// get total data to be imported
let studentsCount = Object.keys(students).length;

// for testing
// document.getElementById("jsonData").innerHTML = jsonObject;

// (future updates)
//check the data if formatted correctly e.g StudentsName PhoneNumber
// then insert data to students database


// run for each
for (const student of students) {
// console.log(student.StudentsName);
// call a route here to insert students
axios.post('/addstudent',{
studentName:student.StudentsName,
Expand Down Expand Up @@ -108,8 +99,6 @@ btnImport.addEventListener('click',()=> {
showImportFailedModal();
disableImportBtn();
return false;
// alert('import failed')
// load modal instead of alert
})
}
});
Expand Down

0 comments on commit 6f718f7

Please sign in to comment.