Hopefully Eightpieces is less buggish now
[vchess.git] / client / src / components / ContactForm.vue
index f9c5c60..b7aea94 100644 (file)
@@ -4,12 +4,15 @@ div
     type="checkbox"
     @change="trySetEnterTime($event)"
   )
-  div(
+  div#contactDiv(
     role="dialog"
     data-checkbox="modalContact"
   )
     .card
       label.modal-close(for="modalContact")
+      a#discordLink(href="https://discord.gg/a9ZFKBe")
+        span {{ st.tr["Discord invitation"] }}
+        img(src="/images/icons/discord.svg")
       fieldset
         label(for="userEmail") {{ st.tr["Email"] }}
         input#userEmail(type="email" :value="st.user.email")
@@ -23,9 +26,10 @@ div
 </template>
 
 <script>
-import { ajax } from "../utils/ajax";
+import { ajax } from "@/utils/ajax";
 import { store } from "@/store";
 import { checkNameEmail } from "@/data/userCheck";
+import { processModalClick } from "@/utils/modalClick.js";
 export default {
   name: "my-contact-form",
   data: function() {
@@ -35,6 +39,10 @@ export default {
       infoMsg: ""
     };
   },
+  mounted: function() {
+    document.getElementById("contactDiv")
+      .addEventListener("click", processModalClick);
+  },
   methods: {
     trySetEnterTime: function(event) {
       if (event.target.checked) {
@@ -66,14 +74,17 @@ export default {
         "/messages",
         "POST",
         {
-          email: email.value,
-          subject: subject.value,
-          content: content.value
-        },
-        () => {
-          this.infoMsg = "Email sent!";
-          subject.value = "";
-          content.value = "";
+          nocredentials: true,
+          data: {
+            email: email.value,
+            subject: subject.value,
+            content: content.value
+          },
+          success: () => {
+            this.infoMsg = "Email sent!";
+            subject.value = "";
+            content.value = "";
+          }
         }
       );
     }
@@ -90,6 +101,16 @@ textarea#mailContent
   width: 100%
   min-height: 100px
 
+#discordLink
+  display: block
+  margin-top: 10px
+  text-align: center
+  font-size: 1.3em
+  & > img
+    height: 1.5em
+    display: inline-block
+    margin-left: 5px
+
 #dialog
   padding: 5px
   color: blue