Update Number to Access Group Links
@@ -141,12 +142,18 @@ export default {
GroupUrl: null,
GroupUrl2: null,
GLmail: null,
- Phone: null,
+ Phone: "",
+ Phone2: null,
+ updating: false,
};
},
methods: {
async updateuser() {
- if (this.Phone) {
+ // Set updating to true when the update process begins
+ this.updating = true;
+ // Trim the input and check if it's not empty
+ const trimmedPhone = this.Phone2.trim();
+ if (trimmedPhone) {
let token = localStorage.getItem('Token');
try {
const url = `${this.$globalData.backendUrl}/updateuser/`;
@@ -157,22 +164,23 @@ export default {
};
const data = {
'token': token,
- 'phone' : this.Phone
+ 'phone': trimmedPhone, // Use the trimmed value
};
const result = await axios.post(url, data, config);
if (result.data.success == true) {
- alert("Whatsapp Number Updated Successfully.")
+ alert("Whatsapp Number Updated Successfully.");
location.reload();
}
-
-
-
-
} catch (error) {
console.error('Error updating user details:', error);
}
+ } else {
+ // Display an error message or handle the empty input case
+ alert("Please enter a valid WhatsApp number.");
}
+ this.updating = false;
},
+
},
async mounted() {
const storedUserDetails = localStorage.getItem('userDetails');
@@ -203,6 +211,13 @@ export default {
this.GroupUrl = result.data.link;
this.GroupUrl2 = result.data.link2;
this.GLmail = result.data.gl_email;
+ this.Phone = result.data.phone;
+ if (this.Phone === null) {
+ alert("Please Update your whatsapp number to access whatsapp group links.")
+ }
+ }
+ else {
+ alert("Data not found.")
}
} catch (error) {
console.error('Error fetching user details:', error);
diff --git a/src/main.js b/src/main.js
index 9cd081c..65834ca 100644
--- a/src/main.js
+++ b/src/main.js
@@ -12,7 +12,7 @@ const storedUserDetails = localStorage.getItem('userDetails');
}
const globalData = {
backendUrl: "https://sundarbans.camlio.shop",
- // backendUrl: "http://127.0.0.1:8000", (for development use)
+ // backendUrl: "http://127.0.0.1:8000", // (for development use)
userDetails : userDetail
};