Browse Source

add message on too long comment

tripeur 4 years ago
parent
commit
1f047b8157
1 changed files with 13 additions and 1 deletions
  1. 13 1
      src/components/Questionaire.vue

+ 13 - 1
src/components/Questionaire.vue

@@ -157,6 +157,7 @@ export default defineComponent({
     saveBenevole() {
       this.checkDone = true;
       if (!this.areQuestionValid) {
+        Toast({ html: "Email invalide", classes: "error" });
         return;
       }
       if (this.name == "") {
@@ -186,6 +187,16 @@ export default defineComponent({
         .filter((q) => q.type == "text")
         .map((q) => q.title + " : " + (this.commentObject[q.uuid] ?? ""))
         .join("\n\r");
+      if (this.comment.length > 500) {
+        Toast({
+          html:
+            "Les réponses textuels sont trop longues<br>" +
+            this.comment.length +
+            "/500 charactères",
+          classes: "error",
+        });
+        return;
+      }
       const benevole: BenevoleJSON = {
         name: this.name,
         surname: this.surname,
@@ -218,7 +229,8 @@ export default defineComponent({
         })
         .then((data: BenevoleJSON) => {
           this.$emit("newRegistration", Benevole.fromJSON(data));
-        });
+        })
+        .catch((error) => Toast({ html: "Erreur" + error, classes: "error" }));
     },
   },
 });