diff --git a/server/controller/CuestionarioAlumno/nuevo.js b/server/controller/CuestionarioAlumno/nuevo.js index 15e07d4..d35f20b 100644 --- a/server/controller/CuestionarioAlumno/nuevo.js +++ b/server/controller/CuestionarioAlumno/nuevo.js @@ -101,7 +101,7 @@ const nuevo = async (body) => { 'Este Servicio Social se encuentra rechazado. No se puede avanzar hasta que se corriga lo necesario.' ); case 10: - throw new Error('Este Servicio Social esta cancelado.'); + throw new Error('Este Servicio Social fue cancelado.'); } }) .then((res) => { @@ -111,7 +111,7 @@ const nuevo = async (body) => { ); }) .then((res) => { - return { message: 'Se guardo tus respuestas correctamente.' }; + return { message: 'Se guardaron tus respuestas correctamente.' }; }); }; diff --git a/server/controller/CuestionarioPrograma/nuevo.js b/server/controller/CuestionarioPrograma/nuevo.js index c60f812..0ef9876 100644 --- a/server/controller/CuestionarioPrograma/nuevo.js +++ b/server/controller/CuestionarioPrograma/nuevo.js @@ -39,10 +39,11 @@ const nuevo = async (body) => { 'Aun no se puede contestar el cuestionario este Servicio Social.' ); case 5: - case 6: throw new Error( 'Este Servicio Social ya paso la fase de contestar el cuestionario.' ); + case 6: + throw new Error('Este Servicio Social ya finalizó.'); case 7: case 8: case 9: @@ -50,7 +51,7 @@ const nuevo = async (body) => { 'Este Servicio Social se encuentra rechazado. No se puede avanzar hasta que se corriga lo necesario.' ); case 10: - throw new Error('Este Servicio Social esta cancelado.'); + throw new Error('Este Servicio Social fue cancelado.'); } }) .then((res) => { @@ -60,7 +61,7 @@ const nuevo = async (body) => { ); }) .then((res) => { - return { message: 'Se guardo tus respuestas correctamente.' }; + return { message: 'Se guradaron tus respuestas correctamente.' }; }); }; diff --git a/server/controller/Servicio/cancelar.js b/server/controller/Servicio/cancelar.js index 8e72b74..a0411e5 100644 --- a/server/controller/Servicio/cancelar.js +++ b/server/controller/Servicio/cancelar.js @@ -17,7 +17,7 @@ const cancelar = async (body) => { include: [{ model: Programa, include: [{ model: Usuario }] }], }) .then((res) => { - if (!res) throw new Error('No existe este servicio.'); + if (!res) throw new Error('No existe este Servicio Social.'); if (res.idStatus === 10) throw new Error('Este Servicio Social ya fue cancelado.'); if (res.idStatus === 6) diff --git a/server/controller/Servicio/cartaTermino.js b/server/controller/Servicio/cartaTermino.js index a4650fb..c35be58 100644 --- a/server/controller/Servicio/cartaTermino.js +++ b/server/controller/Servicio/cartaTermino.js @@ -10,7 +10,7 @@ const cartaTermino = async (body, file) => { }) .then((res) => { if (!res) throw new Error('Este servicio no existe.'); - if (res.cartaTermino) throw new Error('Ya se subio la carta de termino.'); + if (res.cartaTermino) throw new Error('Ya se subio la Carta de Termino.'); switch (res.idStatus) { case 4: case 8: @@ -28,20 +28,21 @@ const cartaTermino = async (body, file) => { case 2: case 3: throw new Error( - 'Aun no se puede subir la carta de termino a este Servicio Social.' + 'Aun no se puede subir la Carta de Termino a este Servicio Social.' ); case 5: - case 6: throw new Error( - 'Este Servicio Social ya paso la fase de subir la carta de termino.' + 'Este Servicio Social ya paso la fase de subir la Carta de Termino.' ); + case 6: + throw new Error('Este Servicio Social ya finalizó.'); case 7: case 9: throw new Error( 'Este Servicio Social se encuentra rechazado. No se puede avanzar hasta que se corriga lo necesario.' ); case 10: - throw new Error('Este Servicio Social esta cancelado.'); + throw new Error('Este Servicio Social esta cancelado. Comunicate con COESI para solucionar tu problema.'); } }) .then((res) => { @@ -51,7 +52,7 @@ const cartaTermino = async (body, file) => { return validar.validarPreTermino(idServicio); }) .then((res) => { - return { message: `Se subio el informe global correctamente. ${res}` }; + return { message: `Se subio la Carta de Termino correctamente. ${res}` }; }); }; diff --git a/server/controller/Servicio/informeGlobal.js b/server/controller/Servicio/informeGlobal.js index 3088db7..bcccf9f 100644 --- a/server/controller/Servicio/informeGlobal.js +++ b/server/controller/Servicio/informeGlobal.js @@ -10,7 +10,7 @@ const informeGlobal = async (body, file) => { }) .then((res) => { if (!res) throw new Error('Este servicio no existe.'); - if (res.informeGlobal) throw new Error('Ya se subio el informe global.'); + if (res.informeGlobal) throw new Error('Ya se subio el Informe Global.'); switch (res.idStatus) { case 4: case 9: @@ -30,20 +30,21 @@ const informeGlobal = async (body, file) => { case 2: case 3: throw new Error( - 'Aun no se puede subir el informe global a este Servicio Social.' + 'Aun no se puede subir el Informe Global a este Servicio Social.' ); case 5: - case 6: throw new Error( - 'Este Servicio Social ya paso la fase de subir el informe global.' + 'Este Servicio Social ya paso la fase de subir el Informe Global.' ); + case 6: + throw new Error('Este Servicio Social ya finalizó.'); case 7: case 8: throw new Error( 'Este Servicio Social se encuentra rechazado. No se puede avanzar hasta que se corriga lo necesario.' ); case 10: - throw new Error('Este Servicio Social esta cancelado.'); + throw new Error('Este Servicio Social esta cancelado. Comunicate con COESI para solucionar tu problema.'); } }) .then((res) => { @@ -53,7 +54,7 @@ const informeGlobal = async (body, file) => { return validar.validarPreTermino(idServicio); }) .then((res) => { - return { message: `Se subio el informe global correctamente. ${res}` }; + return { message: `Se subio el Informe Global correctamente. ${res}` }; }); }; diff --git a/server/controller/Servicio/rechazarAceptacion.js b/server/controller/Servicio/rechazarAceptacion.js index e69de29..68987d4 100644 --- a/server/controller/Servicio/rechazarAceptacion.js +++ b/server/controller/Servicio/rechazarAceptacion.js @@ -0,0 +1,68 @@ +const validar = require('../../helper/validar'); +const gmail = require('../../helper/gmail'); +const correos = require('../../helper/correos'); +const Servicio = require('../../db/tablas/Servicio'); +const Usuario = require('../../db/tablas/Usuario'); +const Programa = require('../../db/tablas/Programa'); + +const cancelar = async (body) => { + let idServicio = validar.validarId(body.idServicio); + let mensaje = validar.validarAlfanumerico(body.mensaje, 'El mensaje', 800); + let correoResponsable = {}; + let emailResponsable = ''; + + return Servicio.findOne({ + where: { idServicio }, + include: [{ model: Programa, include: [{ model: Usuario }] }], + }) + .then((res) => { + if (!res) throw new Error('No existe este Servicio Social.'); + + switch (res.idStatus) { + case 1: + let correoAlumno = correos.preRegistroRechazadoAlumno( + mensaje, + res.Usuario.nombre + ); + + correoResponsable = correos.preRegistroRechazadoResponsable( + mensaje, + res.Usuario.nombre + ); + emailResponsable = res.Programa.Usuario.usuario; + return gmail(correoAlumno.subject, res.correo, correoAlumno.msj); + case 2: + case 3: + case 4: + case 5: + case 8: + case 9: + throw new Error( + 'No se puede rechazar la Carta de Aceptación en este punto del Servicio Social.' + ); + case 6: + throw new Error('Este Servicio Social ya finalizó.'); + case 7: + throw new Error( + 'Este Servicio Social ya tiene la Carta de Aceptación rechazada.' + ); + case 10: + throw new Error('Este Servicio Social fue cancelado.'); + } + }) + .then((res) => { + return gmail( + correoResponsable.subject, + emailResponsable, + correoResponsable.msj + ); + }) + .then((res) => { + return Servicio.update({ idStatus: 7 }, { where: { idServicio } }); + }) + .then((res) => { + return { message: 'Se rechazo correctamente la Carta de Aceptación.' }; + }); +}; + +module.exports = cancelar; diff --git a/server/controller/Servicio/rechazarInform.js b/server/controller/Servicio/rechazarInform.js deleted file mode 100644 index e69de29..0000000 diff --git a/server/controller/Servicio/rechazarInforme.js b/server/controller/Servicio/rechazarInforme.js new file mode 100644 index 0000000..e830322 --- /dev/null +++ b/server/controller/Servicio/rechazarInforme.js @@ -0,0 +1,68 @@ +const validar = require('../../helper/validar'); +const gmail = require('../../helper/gmail'); +const correos = require('../../helper/correos'); +const Servicio = require('../../db/tablas/Servicio'); +const Usuario = require('../../db/tablas/Usuario'); +const Programa = require('../../db/tablas/Programa'); + +const cancelar = async (body) => { + let idServicio = validar.validarId(body.idServicio); + let mensaje = validar.validarAlfanumerico(body.mensaje, 'El mensaje', 800); + let correoResponsable = {}; + let emailResponsable = ''; + + return Servicio.findOne({ + where: { idServicio }, + include: [{ model: Programa, include: [{ model: Usuario }] }], + }) + .then((res) => { + if (!res) throw new Error('No existe este Servicio Social.'); + switch (res.idStatus) { + case 5: + let correoAlumno = correos.terminoRechazadoAlumno( + mensaje, + res.Usuario.nombre + ); + + correoResponsable = correos.terminoRechazadoResponsable( + mensaje, + res.Usuario.nombre + ); + emailResponsable = res.Programa.Usuario.usuario; + return gmail(correoAlumno.subject, res.correo, correoAlumno.msj); + case 1: + case 2: + case 3: + case 4: + throw new Error('Aun no se puede rechazar el Informe Global.'); + case 6: + throw new Error('Este Servicio Social ya finalizó.'); + case 7: + case 8: + throw new Error( + 'No se puede rechazar el Informe Global en este punto del Servicio Social.' + ); + case 9: + throw new Error( + 'Este Servicio Social ya tiene el Informe Global rechazado.' + ); + case 10: + throw new Error('Este Servicio Social fue cancelado.'); + } + }) + .then((res) => { + return gmail( + correoResponsable.subject, + emailResponsable, + correoResponsable.msj + ); + }) + .then((res) => { + return Servicio.update({ idStatus: 9 }, { where: { idServicio } }); + }) + .then((res) => { + return { message: 'Se rechazo correctamente el Informe Global.' }; + }); +}; + +module.exports = cancelar; diff --git a/server/controller/Servicio/rechazarTermino.js b/server/controller/Servicio/rechazarTermino.js index e69de29..3578ebd 100644 --- a/server/controller/Servicio/rechazarTermino.js +++ b/server/controller/Servicio/rechazarTermino.js @@ -0,0 +1,68 @@ +const validar = require('../../helper/validar'); +const gmail = require('../../helper/gmail'); +const correos = require('../../helper/correos'); +const Servicio = require('../../db/tablas/Servicio'); +const Usuario = require('../../db/tablas/Usuario'); +const Programa = require('../../db/tablas/Programa'); + +const cancelar = async (body) => { + let idServicio = validar.validarId(body.idServicio); + let mensaje = validar.validarAlfanumerico(body.mensaje, 'El mensaje', 800); + let correoResponsable = {}; + let emailResponsable = ''; + + return Servicio.findOne({ + where: { idServicio }, + include: [{ model: Programa, include: [{ model: Usuario }] }], + }) + .then((res) => { + if (!res) throw new Error('No existe este Servicio Social.'); + switch (res.idStatus) { + case 5: + let correoAlumno = correos.terminoRechazadoAlumno( + mensaje, + res.Usuario.nombre + ); + + correoResponsable = correos.terminoRechazadoResponsable( + mensaje, + res.Usuario.nombre + ); + emailResponsable = res.Programa.Usuario.usuario; + return gmail(correoAlumno.subject, res.correo, correoAlumno.msj); + case 1: + case 2: + case 3: + case 4: + throw new Error('Aun no se puede rechazar la Carta de Termino.'); + case 6: + throw new Error('Este Servicio Social ya finalizó.'); + case 7: + case 9: + throw new Error( + 'No se puede rechazar la Carta de Termino en este punto del Servicio Social.' + ); + case 8: + throw new Error( + 'Este Servicio Social ya tiene la Carta de Termino rechazado.' + ); + case 10: + throw new Error('Este Servicio Social fue cancelado.'); + } + }) + .then((res) => { + return gmail( + correoResponsable.subject, + emailResponsable, + correoResponsable.msj + ); + }) + .then((res) => { + return Servicio.update({ idStatus: 8 }, { where: { idServicio } }); + }) + .then((res) => { + return { message: 'Se rechazo correctamente la Carta de Termino.' }; + }); +}; + +module.exports = cancelar; diff --git a/server/controller/Servicio/registro.js b/server/controller/Servicio/registro.js index 954d2ac..367f110 100644 --- a/server/controller/Servicio/registro.js +++ b/server/controller/Servicio/registro.js @@ -29,8 +29,9 @@ const registro = async (body) => { case 3: case 4: case 5: - case 6: throw new Error('Este Servicio Social ya paso por el Registro.'); + case 6: + throw new Error('Este Servicio Social ya finalizó.'); case 7: case 8: case 9: @@ -38,7 +39,7 @@ const registro = async (body) => { 'Este Servicio Social se encuentra rechazado. No se puede aceptar hasta que se corriga lo necesario.' ); case 10: - throw new Error('Este Servicio Social esta cancelado.'); + throw new Error('Este Servicio Social fue cancelado.'); } }) .then((res) => { diff --git a/server/controller/Servicio/registroValidado.js b/server/controller/Servicio/registroValidado.js index e7a7b20..1c0e514 100644 --- a/server/controller/Servicio/registroValidado.js +++ b/server/controller/Servicio/registroValidado.js @@ -46,10 +46,11 @@ const registroValidado = async (body) => { ); case 4: case 5: - case 6: throw new Error( 'Este Servicio Social ya paso por el Registro Validado.' ); + case 6: + throw new Error('Este Servicio Social ya finalizó.'); case 7: case 8: case 9: @@ -58,7 +59,7 @@ const registroValidado = async (body) => { ); case 10: throw new Error( - 'Este Servicio Social esta cancelado. Comunicate con COESI para solucionar tu problema.' + 'Este Servicio Social fue cancelado. Comunicate con COESI para solucionar tu problema.' ); } }) diff --git a/server/helper/correos.js b/server/helper/correos.js index d962ee5..b49fe66 100644 --- a/server/helper/correos.js +++ b/server/helper/correos.js @@ -66,31 +66,6 @@ ${dudas}`, }; }; -const registroRechazadoAlumno = (motivo, nombre) => { - return { - subject: 'Rechazo de registro.', - msj: `Estimado(a) ${nombre}: - -Te informamos que hay un error con tu registro de servicio social por los siguientes motivos: - -${motivo} - -${dudas}`, - }; -}; - -const registroRechazadoResponsable = (motivo, nombre) => { - return { - subject: 'Rechazo de registro.', - msj: `Estimado responsable de programa: -Te informamos que hay un error con el registro de servicio social del alumno ${nombre} por los siguientes motivos: - -${motivo} - -${dudas}`, - }; -}; - const terminoValidado = (nombre) => { return { subject: 'Validación de término.', @@ -303,8 +278,6 @@ module.exports = { preRegistroRechazadoResponsable, registroValidadoAlumno, registroValidadoResponsable, - registroRechazadoAlumno, - registroRechazadoResponsable, terminoValidado, terminoRechazadoAlumno, terminoRechazadoResponsable,