Skip to content

Commit

Permalink
Bloquer l'inscription si aucun nb de participants n'est renseigné #21
Browse files Browse the repository at this point in the history
  • Loading branch information
amandine-sahl committed Jun 30, 2023
1 parent 67c3a0d commit 09318ab
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions front-vite/src/components/EventReservationForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@
/>
</div>
</div>

<div class="sm:col-span-12">
<vv-error-message
name="nb_total"
/>
</div>
</div>
</div>

Expand Down Expand Up @@ -356,8 +362,13 @@ const formSchema = yup.object().shape({
nb_plus_12_ans: yup.number().min(0).default(0).label('Plus de 12 ans'),
liste_attente: yup.bool().label('En liste d\'attente'),
confirmed: yup.bool().label('Confirmée par le créateur'),
});
nb_total: yup
.number()
.test("nb_total_notnull", "Au moins un participant doit être inscrit", function (code) {
const { nb_adultes, nb_moins_6_ans, nb_6_8_ans, nb_9_12_ans, nb_plus_12_ans } = this.parent;
return nb_adultes + nb_moins_6_ans + nb_6_8_ans + nb_9_12_ans + nb_plus_12_ans >= 1;
})
})
const formValues = {
Expand All @@ -375,6 +386,7 @@ const formValues = {
liste_attente: props.originalValues.liste_attente,
confirmed: props.originalValues.confirmed,
}
</script>

<style scoped>
Expand Down

0 comments on commit 09318ab

Please sign in to comment.