Add check if player already exist

This commit is contained in:
2024-11-12 19:11:03 +01:00
parent 19566a682a
commit aec6fb70ce
2 changed files with 18 additions and 3 deletions

View File

@@ -314,9 +314,21 @@ if (window.location.href.includes("arbitrage.html")) {
"prenom": prenom,
"promo": promoId
};
await pb.collection('joueurs').create(data);
//rechargement de la page
window.location.href = "arbitrage.html";
const allPlayerList = await pb.collection('joueurs').getFullList({
expand: 'promo'
});
const existingPlayer = allPlayerList.find(player =>
player.name.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "") === nom.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "") &&
player.prenom.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "") === prenom.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "") &&
player.promo === promoId
);
if (existingPlayer) {
alert("Un joueur avec ce nom, prénom et promo existe déjà.");
} else {
await pb.collection('joueurs').create(data);
window.location.href = "arbitrage.html";
}
});
}

View File

@@ -11,6 +11,9 @@
## Point d'amélioration:
- Verification de doublon dans les joueurs
- Import des equipes depuis un excel
- Modifier les equipes
- Recherche des joueurs pour la creation d'une equipe
- Interface mettre tous les points d'un coup
## Show your support