Skip to content

Commit

Permalink
verificação na extração de alunos
Browse files Browse the repository at this point in the history
  • Loading branch information
yaskisoba committed Dec 13, 2023
1 parent 702fcd2 commit 8ed18e2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
26 changes: 21 additions & 5 deletions backend/controllers/ExtractStudents.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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.' });
Expand Down
11 changes: 3 additions & 8 deletions frontend/src/pages/Signin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

}

Expand Down

0 comments on commit 8ed18e2

Please sign in to comment.