#66 - Compiler le JS avant de l'envoyer au client

This commit is contained in:
Damien Broqua 2022-10-28 22:40:02 +02:00
parent a74c67e241
commit 8f9e902587
20 changed files with 809 additions and 762 deletions

View file

@ -1,4 +1,4 @@
<section class="box" id="app">
<section class="box" id="contact">
<h1>Nous contacter</h1>
<form @submit="send" <% if (config.mailMethod === 'formspree' ) { %> id="contact" method="POST" action="https://formspree.io/f/<%= config.formspreeId %>" <% } %>>
<div class="grid grid-cols-1 lg:grid-cols-2 gap-16">
@ -34,47 +34,6 @@
</form>
</section>
<% if (config.mailMethod === 'smtp' ) { %>
<script>
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('#app');
</script>
<% } %>
<script>
const contactMethod = '<%= config.mailMethod %>';
</script>