no puede registrarse si ya paso la hora del recorrido

This commit is contained in:
xXpuma99Xx
2021-10-28 15:15:07 -05:00
parent 0ce86a74fd
commit 97f7f3a105
+4
View File
@@ -1,3 +1,4 @@
const moment = require('moment');
const dbHelper = '../../helper';
const { validarId } = require(`${dbHelper}/validar`);
const { correoAlumno } = require(`${dbHelper}/correos`);
@@ -6,6 +7,7 @@ const dbPath = '../../db/tablas';
const Alumno = require(`${dbPath}/Alumno`);
const Carrera = require(`${dbPath}/Carrera`);
const Horario = require(`${dbPath}/Horario`);
const ahora = moment();
const registrar = async (body) => {
const idHorario = validarId(body.idHorario);
@@ -30,6 +32,8 @@ const registrar = async (body) => {
horario = res;
if (alumno.turno != horario.turno)
throw new Error('Este horario no corresponde con el turno del alumno.');
if (moment(horario.horario).add(20, 'm') < ahora)
throw new Error('Ya no puedes incribirte a este horario.');
return Alumno.findAll({ where: { idHorario } });
})
.then((res) => {