diff --git a/backend/controllers/ExtractStudents.js b/backend/controllers/ExtractStudents.js index 3a12c228..edd7246b 100644 --- a/backend/controllers/ExtractStudents.js +++ b/backend/controllers/ExtractStudents.js @@ -16,10 +16,26 @@ exports.extractStudents = async (req, res) => { for (let rowIndex = 2; rowIndex <= spreadsheet.rowCount; rowIndex++) { const row = spreadsheet.getRow(rowIndex); const dataRow = {}; - columns.forEach((columnName, columnIndex) => { - dataRow[columnName] = row.getCell(columnIndex).value; - }); - data.push(dataRow); + + const matricula = row.getCell(1).value; + const nomeCompleto = row.getCell(2).value; + const ano = row.getCell(3).value; + const email = row.getCell(4).value; + + console.log(nomeCompleto.toString().length) + console.log((nomeCompleto.toString().length > 10 || nomeCompleto.toString().length < 50)) + console.log((parseInt(ano) > 1 || parseInt(ano) <= 3)) + console.log(( matricula.toString().length > 0 && matricula.toString().length <= 8)) + + + if((nomeCompleto.toString().length > 10 || nomeCompleto.toString().length < 50) && (parseInt(ano) > 1 || parseInt(ano) <= 3) && ( matricula.toString().length > 0 && matricula.toString().length <= 8)){ + columns.forEach((columnName, columnIndex) => { + dataRow[columnName] = row.getCell(columnIndex).value; + }); + data.push(dataRow); + }else{ + return res.status(400).json({ erro: 'Dados inválidos na linha ' + rowIndex }); + } } data.forEach( async (student) => { @@ -31,7 +47,7 @@ exports.extractStudents = async (req, res) => { } }); - res.json({ mensagem: 'Arquivo Excel recebido e processado com sucesso!' }); + res.status(201).json({ mensagem: 'Arquivo Excel recebido e processado com sucesso!' }); } catch (erro) { console.error('Erro ao processar arquivo Excel:', erro); res.status(500).json({ erro: 'Erro ao processar arquivo Excel.' }); diff --git a/frontend/src/pages/Signin/index.js b/frontend/src/pages/Signin/index.js index 131b37df..8e2441c1 100644 --- a/frontend/src/pages/Signin/index.js +++ b/frontend/src/pages/Signin/index.js @@ -36,17 +36,12 @@ const Signin = () => { let typeUser = isSuperUser() let user = userId() - if(typeUser == "true"){ + if(typeUser === "true"){ console.log("é adm ") - setTimeout(() => { - navigate('/home'); - }, 2000); + navigate('/home'); } else { console.log("é aluno ") - - setTimeout(() => { - navigate('/home-student'); - }, 2000); + navigate('/home-student'); }