This commit is contained in:
Lemuel Marquez
2021-01-12 21:09:37 -06:00
parent 2a0f649f59
commit fc77a4d755
16 changed files with 1334 additions and 125 deletions
+10 -17
View File
@@ -9,6 +9,7 @@ const cancelar = async (body) => {
let idServicio = validar.validarId(body.idServicio);
let mensaje = validar.validarAlfanumerico(body.mensaje, 'El mensaje', 800);
let correoResponsable = {};
let correoAlumno = {};
let emailResponsable = '';
let idUsuario;
@@ -27,10 +28,8 @@ const cancelar = async (body) => {
throw new Error(
'Este Servicio Social ya fue finalizado, no se puede cancelar.'
);
let correoAlumno = correos.canceladoAlumno(mensaje, res.Usuario.nombre);
idUsuario = res.idUsuario;
correoAlumno = correos.canceladoAlumno(mensaje, res.Usuario.nombre);
correoResponsable = correos.canceladoResponsable(
mensaje,
res.Usuario.nombre
@@ -38,22 +37,16 @@ const cancelar = async (body) => {
emailResponsable = res.Programa.Usuario.usuario;
return gmail(correoAlumno.subject, res.correo, correoAlumno.msj);
})
.then((res) => {
return gmail(
correoResponsable.subject,
emailResponsable,
correoResponsable.msj
);
})
.then((res) => {
return Usuario.update(
.then((res) =>
gmail(correoResponsable.subject, emailResponsable, correoResponsable.msj)
)
.then((res) =>
Usuario.update(
{ activo: false, password: null },
{ where: { idUsuario } }
);
})
.then((res) => {
return Servicio.update({ idStatus: 10 }, { where: { idServicio } });
})
)
)
.then((res) => Servicio.update({ idStatus: 10 }, { where: { idServicio } }))
.then((res) => {
return { message: 'Se cancelo correctamente este Servicio Social.' };
});