This commit is contained in:
Damien Broqua 2022-10-28 22:56:04 +02:00
parent 980586d8eb
commit e01f01337c
10 changed files with 450 additions and 370 deletions

View file

@ -1,42 +1,43 @@
if ( typeof contactMethod !== 'undefined' && contactMethod === 'smtp' ) {
// eslint-disable-next-line no-undef
if (typeof contactMethod !== "undefined" && contactMethod === "smtp") {
Vue.createApp({
data() {
return {
email: '',
name: '',
message: '',
captcha: '',
email: "",
name: "",
message: "",
captcha: "",
loading: false,
}
};
},
methods: {
send(event) {
event.preventDefault();
if ( this.loading ) {
if (this.loading) {
return false;
}
this.loading = true;
const {
email,
message,
name,
captcha,
} = this;
const { email, message, name, captcha } = this;
axios.post('/api/v1/contact', {email, name, message, captcha})
.then( () => {
return axios
.post("/api/v1/contact", { email, name, message, captcha })
.then(() => {
showToastr("Message correctement envoyé", true);
})
.catch((err) => {
showToastr(err.response?.data?.message || "Impossible d'envoyer votre message", false);
showToastr(
err.response?.data?.message ||
"Impossible d'envoyer votre message",
false
);
})
.finally(() => {
this.loading = false;
})
});
},
},
}).mount('#contact');
}
}).mount("#contact");
}