forked from dbroqua/MusicTopus
#66 - Compiler le JS avant de l'envoyer au client
This commit is contained in:
parent
a74c67e241
commit
8f9e902587
20 changed files with 809 additions and 762 deletions
42
javascripts/conctact.js
Normal file
42
javascripts/conctact.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
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');
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue