42 lines
No EOL
1.2 KiB
JavaScript
42 lines
No EOL
1.2 KiB
JavaScript
if ( typeof contactMethod !== 'undefined' && contactMethod === 'smtp' ) {
|
|
Vue.createApp({
|
|
data() {
|
|
return {
|
|
email: '',
|
|
name: '',
|
|
message: '',
|
|
captcha: '',
|
|
loading: false,
|
|
}
|
|
},
|
|
methods: {
|
|
send(event) {
|
|
event.preventDefault();
|
|
|
|
if ( this.loading ) {
|
|
return false;
|
|
}
|
|
|
|
this.loading = true;
|
|
|
|
const {
|
|
email,
|
|
message,
|
|
name,
|
|
captcha,
|
|
} = this;
|
|
|
|
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);
|
|
})
|
|
.finally(() => {
|
|
this.loading = false;
|
|
})
|
|
},
|
|
},
|
|
}).mount('#contact');
|
|
} |