feat: restrict license creation to only one license per adherent

This commit is contained in:
2026-05-19 22:53:05 +02:00
parent bcd4a94973
commit 2a116b1e02
2 changed files with 7 additions and 1 deletions
@@ -48,6 +48,12 @@ public class LicenceController {
Adherent adherent = adherentRepository.findById(id)
.orElseThrow(() -> new IllegalArgumentException("Invalid Adherent ID"));
List<Licence> existingLicences = licenceRepository.findByAdherentId(id);
if (!existingLicences.isEmpty()) {
return "redirect:/adherents/" + id + "/edit";
}
Categorie categorie = categorieRepository.findById(categorieId)
.orElseThrow(() -> new IllegalArgumentException("Invalid Categorie ID"));
@@ -144,7 +144,7 @@
<div th:if="${adherent.id != null}" class="max-w-3xl mx-auto bg-white rounded-xl shadow-sm border border-gray-100 p-8 mt-6">
<div class="flex justify-between items-center mb-6">
<h3 class="text-xl font-bold text-gray-900">Licences de l'adhérent</h3>
<button onclick="openLicenceModal()" class="bg-green-600 text-white px-4 py-2 rounded-lg text-sm font-medium hover:bg-green-700 transition-colors">
<button th:if="${#lists.isEmpty(licences)}" onclick="openLicenceModal()" class="bg-green-600 text-white px-4 py-2 rounded-lg text-sm font-medium hover:bg-green-700 transition-colors">
+ Ajouter une Licence
</button>
</div>