This commit is contained in:
Lemuel Marquez
2021-01-13 12:00:11 -06:00
parent ff6699ff20
commit 5de85194fe
8 changed files with 53 additions and 75 deletions
+10 -14
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 = '';
return Servicio.findOne({
@@ -22,11 +23,10 @@ const cancelar = async (body) => {
if (!res) throw new Error('No existe este Servicio Social.');
switch (res.idStatus) {
case 5:
let correoAlumno = correos.terminoRechazadoAlumno(
correoAlumno = correos.terminoRechazadoAlumno(
mensaje,
res.Usuario.nombre
);
correoResponsable = correos.terminoRechazadoResponsable(
mensaje,
res.Usuario.nombre
@@ -53,19 +53,15 @@ const cancelar = async (body) => {
throw new Error('Este Servicio Social fue cancelado.');
}
})
.then((res) => {
return gmail(
correoResponsable.subject,
emailResponsable,
correoResponsable.msj
);
})
.then((res) => {
return Servicio.update(
{ idStatus: 8, cartaTermino: "" },
.then((res) =>
gmail(correoResponsable.subject, emailResponsable, correoResponsable.msj)
)
.then((res) =>
Servicio.update(
{ idStatus: 8, cartaTermino: '' },
{ where: { idServicio } }
);
})
)
)
.then((res) => {
return { message: 'Se rechazo correctamente la Carta de Termino.' };
});