Files
inscripciones_api/server/controller/Admin/validarTicket.js
T

41 lines
1010 B
JavaScript
Raw Normal View History

2022-02-04 01:08:23 -06:00
const dbPath = '../../db/tablas';
const Inscripcion = require(`${dbPath}/Inscripcion`);
const validarTicket = async (body) => {
console.log(body);
return Inscripcion.findOne({
where: { folio: body.folio },
})
.then((res) => {
if (!res) throw new Error('Este folio no existe');
return Inscripcion.update(
{
validacion: body.validacion,
},
{
where: {
folio: body.folio,
},
}
);
})
.then((res) => {
2022-02-10 00:44:23 -06:00
if (body.validacion === 0)
2022-02-22 16:31:40 -06:00
throw new Error(
'El administrador a declinado el ticket, ya que los datos no coinciden.'
);
2022-02-04 01:08:23 -06:00
})
2022-03-03 23:09:14 -06:00
.then((res) => {
return usuarioInscrito(body.numeroCuenta).then(async (res) => {
return {
message: '¡ El ticket a sido validado de forma correcta !',
};
});
})
2022-02-04 01:08:23 -06:00
.catch((err) => {
2022-02-05 00:28:53 -06:00
throw new Error('No fue posible validar el ticket. ' + err);
2022-02-04 01:08:23 -06:00
});
};
module.exports = validarTicket;