diff --git a/components/admin/inputTableA.vue b/components/admin/inputTableA.vue new file mode 100644 index 0000000..196d152 --- /dev/null +++ b/components/admin/inputTableA.vue @@ -0,0 +1,313 @@ + + + + + diff --git a/components/responsable/cartaAceptacion.vue b/components/responsable/cartaAceptacion.vue index 383dcb3..b13f639 100644 --- a/components/responsable/cartaAceptacion.vue +++ b/components/responsable/cartaAceptacion.vue @@ -49,6 +49,8 @@ >Enviar + + @@ -62,6 +64,7 @@ export default { file: [], idServicio: "", cartaAceptacion: "", + isLoading: false, token: { headers: { token: window.localStorage.getItem("token"), @@ -92,17 +95,15 @@ export default { const formData = new FormData(); formData.append("data", JSON.stringify(data)); formData.append("cartaAceptacion", this.file); - console.log(formData); + this.isLoading = true; axios .put(`${process.env.api}/servicio/carta_aceptacion`, formData, { headers: { "Content-Type": "multipart/form-data", + token: this.token.headers.token, }, }) .then((res) => { - console.log(res.data); - - loadingComponent.close(); this.$buefy.dialog.alert({ title: "Success", message: "Se enviaron los datos correctamente", @@ -115,19 +116,10 @@ export default { }); }) .catch((error) => { - loadingComponent.close(); - this.$buefy.dialog.alert({ - title: "Error", - message: error.response.data.message, - type: "is-danger", - hasIcon: true, - icon: "alert-circle", - iconPack: "mdi", - ariaRole: "alertdialog", - ariaModal: true, - }); + error(error.response.data.message); }) .finally(() => { + this.isLoading = false; this.$router.push("/responsable"); localStorage.removeItem("idServicio"); localStorage.removeItem("cartaAceptacion"); @@ -141,6 +133,37 @@ export default { this.$router.push("/responsable"); } }, + error(msj) { + let salir = false; + switch (msj) { + case "invalid signature": + msj = "tu token no es valido, inicia sesión de nuevo"; + break; + case "jwt expired": + msj = "tu sesión ha expirado, inicia sesión de nuevo"; + break; + case "no hay token": + msj = "no has enviado tu token, inicia sesión de nuevo"; + break; + default: + salir = true; + } + + this.$buefy.dialog.alert({ + title: "Error", + message: msj, + type: "is-danger", + hasIcon: true, + icon: "alert-circle", + iconPack: "mdi", + ariaRole: "alertdialog", + ariaModal: true, + }); + if (salir === true) { + localStorage.clear(); + this.$router.push(`/`); + } + }, }, watch: { file: function(newFile, oldFile) { diff --git a/components/responsable/cartaTermino.vue b/components/responsable/cartaTermino.vue index 2dacb78..09a705f 100644 --- a/components/responsable/cartaTermino.vue +++ b/components/responsable/cartaTermino.vue @@ -49,6 +49,8 @@ Enviar + + @@ -62,6 +64,7 @@ export default { file: [], idServicio: "", cartaTermino: "", + isLoading: false, token: { headers: { token: window.localStorage.getItem("token"), @@ -93,11 +96,12 @@ export default { const formData = new FormData(); formData.append("data", JSON.stringify(data)); formData.append("cartaTermino", this.file); - console.log(formData); + this.isLoading = true; axios .put(`${process.env.api}/servicio/carta_termino`, formData, { headers: { "Content-Type": "multipart/form-data", + token: this.token.headers.token, }, }) .then((res) => { @@ -116,19 +120,10 @@ export default { }); }) .catch((error) => { - loadingComponent.close(); - this.$buefy.dialog.alert({ - title: "Error", - message: error.response.data.message, - type: "is-danger", - hasIcon: true, - icon: "alert-circle", - iconPack: "mdi", - ariaRole: "alertdialog", - ariaModal: true, - }); + error(error.response.data.message); }) .finally(() => { + this.isLoading = false; this.$router.push("/responsable"); localStorage.removeItem("idServicio"); localStorage.removeItem("cartaTermino"); @@ -142,6 +137,37 @@ export default { this.$router.push("/responsable"); } }, + error(msj) { + let salir = false; + switch (msj) { + case "invalid signature": + msj = "tu token no es valido, inicia sesión de nuevo"; + break; + case "jwt expired": + msj = "tu sesión ha expirado, inicia sesión de nuevo"; + break; + case "no hay token": + msj = "no has enviado tu token, inicia sesión de nuevo"; + break; + default: + salir = true; + } + + this.$buefy.dialog.alert({ + title: "Error", + message: msj, + type: "is-danger", + hasIcon: true, + icon: "alert-circle", + iconPack: "mdi", + ariaRole: "alertdialog", + ariaModal: true, + }); + if (salir === true) { + localStorage.clear(); + this.$router.push(`/`); + } + }, }, watch: { file: function(newFile, oldFile) { diff --git a/components/responsable/cuestionario.vue b/components/responsable/cuestionario.vue index a6b1f84..1f2042e 100644 --- a/components/responsable/cuestionario.vue +++ b/components/responsable/cuestionario.vue @@ -160,6 +160,9 @@ > + + + @@ -170,6 +173,7 @@ export default { return { idServicio: "", cuestionario: "", + isLoading: false, actividad1: "", actividad2: "", @@ -198,13 +202,33 @@ export default { p6: this.p6, p7: this.p7, }; - console.log(data); - /* + this.isLoading = true; axios - .post(`${process.env.api}/cuestionario_programa`, data) - .then((res) => {}); - */ + .post(`${process.env.api}/cuestionario_programa`, data, this.token) + .then((res) => { + this.$buefy.dialog.alert({ + title: "Success", + message: "Se enviaron los datos correctamente", + type: "is-success", + hasIcon: true, + icon: "checkbox-marked-circle", + iconPack: "mdi", + ariaRole: "alertdialog", + ariaModal: true, + }); + }) + + .catch((error) => { + error(error.response.data.message); + }) + + .finally(() => { + this.isLoading = false; + this.$router.push("/responsable"); + localStorage.removeItem("idServicio"); + localStorage.removeItem("cuestionario"); + }); }, getIdLocal() { this.idServicio = localStorage.getItem("idServicio"); @@ -214,6 +238,37 @@ export default { this.$router.push("/responsable"); } }, + error(msj) { + let salir = false; + switch (msj) { + case "invalid signature": + msj = "tu token no es valido, inicia sesión de nuevo"; + break; + case "jwt expired": + msj = "tu sesión ha expirado, inicia sesión de nuevo"; + break; + case "no hay token": + msj = "no has enviado tu token, inicia sesión de nuevo"; + break; + default: + salir = true; + } + + this.$buefy.dialog.alert({ + title: "Error", + message: msj, + type: "is-danger", + hasIcon: true, + icon: "alert-circle", + iconPack: "mdi", + ariaRole: "alertdialog", + ariaModal: true, + }); + if (salir === true) { + localStorage.clear(); + this.$router.push(`/`); + } + }, }, created() { this.getIdLocal(); diff --git a/components/responsable/inputTable.vue b/components/responsable/inputTable.vue index 7a591f5..8d619aa 100644 --- a/components/responsable/inputTable.vue +++ b/components/responsable/inputTable.vue @@ -1,5 +1,8 @@