Fixes
[vchess.git] / client / src / components / UpsertUser.vue
index 2be637c..dc948cf 100644 (file)
@@ -4,7 +4,7 @@ div
     type="checkbox"
     @change="trySetEnterTime($event)"
   )
-  div(
+  div#upsertDiv(
     role="dialog"
     data-checkbox="modalUser"
   )
@@ -59,6 +59,7 @@ div
 import { store } from "@/store";
 import { checkNameEmail } from "@/data/userCheck";
 import { ajax } from "@/utils/ajax";
+import { processModalClick } from "@/utils/modalClick.js";
 export default {
   name: "my-upsert-user",
   data: function() {
@@ -71,6 +72,10 @@ export default {
       user: {}
     };
   },
+  mounted: function() {
+    document.getElementById("upsertDiv")
+      .addEventListener("click", processModalClick);
+  },
   watch: {
     nameOrEmail: function(newValue) {
       if (newValue.indexOf("@") >= 0) {
@@ -165,21 +170,26 @@ export default {
       ajax(
         this.ajaxUrl(),
         this.ajaxMethod(),
-        this.stage == "Login"
-          ? { nameOrEmail: this.nameOrEmail }
-          : this.user,
-        () => {
-          this.infoMsg = this.infoMessage();
-          if (this.stage != "Update") this.nameOrEmail = "";
-          else {
-            this.st.user.name = this.user.name;
-            this.st.user.email = this.user.email;
-            this.st.user.notify = this.user.notify;
+        {
+          credentials: true,
+          data: (
+            this.stage == "Login"
+              ? { nameOrEmail: this.nameOrEmail }
+              : this.user
+          ),
+          success: () => {
+            this.infoMsg = this.infoMessage();
+            if (this.stage != "Update") this.nameOrEmail = "";
+            else {
+              this.st.user.name = this.user.name;
+              this.st.user.email = this.user.email;
+              this.st.user.notify = this.user.notify;
+            }
+          },
+          error: (err) => {
+            this.infoMsg = "";
+            alert(err);
           }
-        },
-        err => {
-          this.infoMsg = "";
-          alert(err);
         }
       );
     },