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