diff --git a/src/main/java/fr/titionfire/ffsaf/data/model/CatPresetModel.java b/src/main/java/fr/titionfire/ffsaf/data/model/CatPresetModel.java index 950ef4d..56e3c65 100644 --- a/src/main/java/fr/titionfire/ffsaf/data/model/CatPresetModel.java +++ b/src/main/java/fr/titionfire/ffsaf/data/model/CatPresetModel.java @@ -28,24 +28,30 @@ public class CatPresetModel { String name = ""; - List categories; - - long roundDuration; - long pauseDuration; + @ElementCollection(fetch = FetchType.EAGER) + @CollectionTable(name = "category_preset_catconfig", joinColumns = @JoinColumn(name = "id_preset")) + List categories; SwordType swordType = SwordType.NONE; ShieldType shieldType = ShieldType.NONE; - /* Bitmask protections: - * 1 - 1 - Head - * 2 - 2 - Throat - * 3 - 4 - Torso - * 4 - 8 - Arms - * 5 - 16 - Hands - * 6 - 32 - Groin - * 7 - 64 - Legs + /* + * 1 - 1 - Casque + * 2 - 2 - Gorgerin + * 3 - 4 - Coquille et Protection pelvienne + * 4 - 8 - Gant main(s) armée(s) + * 5 - 16 - Gant main bouclier + * 6 - 32 - Plastron + * 7 - 64 - Protection de bras armé(s) + * 8 - 128 - Protection de bras de bouclier + * 9 - 256 - Protection de jambes + * 10 - 512 - Protection de genoux + * 11 - 1024 - Protection de coudes + * 12 - 2048 - Protection dorsale + * 13 - 4096 - Protection de pieds */ - int mandatoryProtection = 0; + int mandatoryProtection1 = 0; + int mandatoryProtection2 = 0; @ManyToMany(mappedBy = "categoriesInscrites", fetch = FetchType.LAZY) private List registers = new ArrayList<>(); @@ -68,4 +74,16 @@ public class CatPresetModel { BUCKLER } + @Getter + @Setter + @AllArgsConstructor + @NoArgsConstructor + @RegisterForReflection + + @Embeddable + public static class CategorieEmbeddable { + Categorie categorie; + long roundDuration; + long pauseDuration; + } } diff --git a/src/main/java/fr/titionfire/ffsaf/domain/service/CompetitionService.java b/src/main/java/fr/titionfire/ffsaf/domain/service/CompetitionService.java index b714a5b..6ac79b7 100644 --- a/src/main/java/fr/titionfire/ffsaf/domain/service/CompetitionService.java +++ b/src/main/java/fr/titionfire/ffsaf/domain/service/CompetitionService.java @@ -271,10 +271,9 @@ public class CompetitionService { presetModel.setName(preset.getName()); presetModel.setSwordType(preset.getSword()); presetModel.setShieldType(preset.getShield()); - presetModel.setRoundDuration(preset.getRoundDuration()); - presetModel.setPauseDuration(preset.getPauseDuration()); presetModel.setCategories(preset.getCategories()); - presetModel.setMandatoryProtection(preset.getMandatoryProtection()); + presetModel.setMandatoryProtection1(preset.getMandatoryProtection1()); + presetModel.setMandatoryProtection2(preset.getMandatoryProtection2()); } // Remove deleted presets @@ -399,7 +398,8 @@ public class CompetitionService { g.getCategoriesInscrites().clear(); g.getCategoriesInscrites().addAll(cats); g.getCategoriesInscrites() - .removeIf(cat -> !cat.getCategories().contains(g.getCategorie())); + .removeIf(cat -> cat.getCategories().stream() + .noneMatch(e -> e.getCategorie().equals(g.getCategorie()))); })) .chain(model -> Panache.withTransaction(() -> competitionGuestRepository.persist(model)) .call(r -> model.getCompetition().getSystem() == CompetitionSystem.INTERNAL ? @@ -495,7 +495,8 @@ public class CompetitionService { } r.getCategoriesInscrites().addAll(cats); r.getCategoriesInscrites() - .removeIf(cat -> !cat.getCategories().contains(r.getCategorie2())); + .removeIf(cat -> cat.getCategories().stream() + .noneMatch(e -> e.getCategorie().equals(r.getCategorie2()))); }))) .chain(r -> Panache.withTransaction(() -> registerRepository.persist(r))) .call(r -> c.getSystem() == CompetitionSystem.INTERNAL ? diff --git a/src/main/java/fr/titionfire/ffsaf/domain/service/ResultService.java b/src/main/java/fr/titionfire/ffsaf/domain/service/ResultService.java index 1f61f08..024fe66 100644 --- a/src/main/java/fr/titionfire/ffsaf/domain/service/ResultService.java +++ b/src/main/java/fr/titionfire/ffsaf/domain/service/ResultService.java @@ -610,7 +610,7 @@ public class ResultService { } else if ((matchModel.isC1(comb) && win > 0) || matchModel.isC2(comb) && win < 0) { stat.w++; stat.win_ids.add(matchModel.getId()); - stat.score += 3; + stat.score += 2; } else { stat.l++; } diff --git a/src/main/java/fr/titionfire/ffsaf/rest/data/PresetData.java b/src/main/java/fr/titionfire/ffsaf/rest/data/PresetData.java index 1f5dba7..60ec743 100644 --- a/src/main/java/fr/titionfire/ffsaf/rest/data/PresetData.java +++ b/src/main/java/fr/titionfire/ffsaf/rest/data/PresetData.java @@ -1,7 +1,6 @@ package fr.titionfire.ffsaf.rest.data; import fr.titionfire.ffsaf.data.model.CatPresetModel; -import fr.titionfire.ffsaf.utils.Categorie; import io.quarkus.runtime.annotations.RegisterForReflection; import lombok.AllArgsConstructor; import lombok.Data; @@ -16,17 +15,15 @@ public class PresetData { private String name; private CatPresetModel.SwordType sword; private CatPresetModel.ShieldType shield; - private List categories; - long roundDuration; - long pauseDuration; - int mandatoryProtection; + private List categories; + private int mandatoryProtection1; + private int mandatoryProtection2; public static PresetData fromModel(CatPresetModel model) { if (model == null) return null; return new PresetData(model.getId(), model.getName(), model.getSwordType(), model.getShieldType(), - model.getCategories(), model.getRoundDuration(), model.getPauseDuration(), - model.getMandatoryProtection()); + model.getCategories(), model.getMandatoryProtection1(), model.getMandatoryProtection2()); } } diff --git a/src/main/webapp/public/locales/en/common.json b/src/main/webapp/public/locales/en/common.json index eed61fa..5f0747c 100644 --- a/src/main/webapp/public/locales/en/common.json +++ b/src/main/webapp/public/locales/en/common.json @@ -83,6 +83,7 @@ "ajouterUnClub": "Add a club", "ajouterUnMembre": "Add a member", "all_season": "--- all seasons ---", + "ans": "years", "arme": "Weapon", "au": "to", "aucun": "None", @@ -105,6 +106,7 @@ "button.seDésinscrire": "Unsubscribe", "button.suivant": "Next", "button.supprimer": "Delete", + "casque": "Helmet", "cat.benjamin": "Benjamin", "cat.cadet": "Cadet", "cat.catégorieInconnue": "Unknown category", @@ -260,6 +262,7 @@ "contactInterne": "Internal contact", "contact_one": "Contact", "contact_other": "Contacts", + "coquilleProtectionPelvienne": "Shell / Pelvic protection", "date": "Date", "dateDeNaissance": "Date of birth", "days": [ @@ -299,8 +302,12 @@ "faitPar": "Done by", "femme": "Female", "filtre": "Filter", + "gantMainBouclier": "Shield hand glove", + "gantMainsArmées": "Armed hand(s) glove(s)", + "gants": "Gloves", "genre": "Gender", "gestionGroupée": "Group management", + "gorgerin": "Gorgerin", "gradeDarbitrage": "Refereeing grade", "h": "M", "home": { @@ -480,8 +487,18 @@ "perm.créerDesCompétion": "Create competitions", "perm.ffsafIntra": "FFSAF intra", "permission": "Permission", + "peutSinscrire": "Can register?", "photos": "Photos", + "plastron": "Breastplate", "prenom": "First name", + "protectionDeBras": "Arm protection", + "protectionDeBrasArmé": "Protection of armed arm(s)", + "protectionDeBrasDeBouclier": "Shield arm protection", + "protectionDeCoudes": "Elbow protection", + "protectionDeGenoux": "Knee protection", + "protectionDeJambes": "Leg protection", + "protectionDePieds": "Foot protection", + "protectionDorsale": "Back protector", "protectionObligatoire": "Mandatory protection", "prénomEtNom": "First and last name", "rechercher": "Search", diff --git a/src/main/webapp/public/locales/fr/common.json b/src/main/webapp/public/locales/fr/common.json index 29aaa1e..68f6a30 100644 --- a/src/main/webapp/public/locales/fr/common.json +++ b/src/main/webapp/public/locales/fr/common.json @@ -83,6 +83,7 @@ "ajouterUnClub": "Ajouter un club", "ajouterUnMembre": "Ajouter un membre", "all_season": "--- tout les saisons ---", + "ans": "ans", "arme": "Arme", "au": "au", "aucun": "Aucun", @@ -105,6 +106,7 @@ "button.seDésinscrire": "Se désinscrire", "button.suivant": "Suivant", "button.supprimer": "Supprimer", + "casque": "Casque", "cat.benjamin": "Benjamin", "cat.cadet": "Cadet", "cat.catégorieInconnue": "Catégorie inconnue", @@ -260,6 +262,7 @@ "contactInterne": "Contact interne", "contact_one": "Contact", "contact_other": "Contacts", + "coquilleProtectionPelvienne": "Coquille / Protection pelvienne", "date": "Date", "dateDeNaissance": "Date de naissance", "days": [ @@ -299,8 +302,12 @@ "faitPar": "Fait par", "femme": "Femme", "filtre": "Filtre", + "gantMainBouclier": "Gant main de bouclier", + "gantMainsArmées": "Gant main(s) armée(s)", + "gants": "Gants", "genre": "Genre", "gestionGroupée": "Gestion groupée", + "gorgerin": "Gorgerin", "gradeDarbitrage": "Grade d'arbitrage", "h": "H", "home": { @@ -480,8 +487,18 @@ "perm.créerDesCompétion": "Créer des compétion", "perm.ffsafIntra": "FFSAF intra", "permission": "Permission", + "peutSinscrire": "Peut s'inscrire?", "photos": "Photos", + "plastron": "Plastron", "prenom": "Prénom", + "protectionDeBras": "Protection de bras", + "protectionDeBrasArmé": "Protection de bras armé(s)", + "protectionDeBrasDeBouclier": "Protection de bras de bouclier", + "protectionDeCoudes": "Protection de coudes", + "protectionDeGenoux": "Protection de genoux", + "protectionDeJambes": "Protection de jambes", + "protectionDePieds": "Protection de pieds", + "protectionDorsale": "Protection dorsale", "protectionObligatoire": "Protection obligatoire", "prénomEtNom": "Prénom et nom", "rechercher": "Rechercher", diff --git a/src/main/webapp/src/assets/CategoryPreset.js b/src/main/webapp/src/assets/CategoryPreset.js new file mode 100644 index 0000000..05c040b --- /dev/null +++ b/src/main/webapp/src/assets/CategoryPreset.js @@ -0,0 +1,115 @@ +const CategoryPreset = [ + { + name: "Épée", + sword: "ONE_HAND", + shield: "NONE", + categories: [ + {categorie: "MINI_POUSSIN", roundDuration: 30000, pauseDuration: 60000}, + {categorie: "POUSSIN", roundDuration: 30000, pauseDuration: 60000}, + {categorie: "BENJAMIN", roundDuration: 45000, pauseDuration: 60000}, + {categorie: "MINIME", roundDuration: 45000, pauseDuration: 60000}, + {categorie: "CADET", roundDuration: 60000, pauseDuration: 60000}, + ], + mandatoryProtection1: 45, + mandatoryProtection2: 13 + }, + { + name: "Épée Bouclier", + sword: "ONE_HAND", + shield: "STANDARD", + categories: [ + {categorie: "SUPER_MINI", roundDuration: 30000, pauseDuration: 60000}, + {categorie: "MINI_POUSSIN", roundDuration: 30000, pauseDuration: 60000}, + {categorie: "POUSSIN", roundDuration: 45000, pauseDuration: 60000}, + {categorie: "BENJAMIN", roundDuration: 45000, pauseDuration: 60000}, + {categorie: "MINIME", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "CADET", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "JUNIOR", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "SENIOR1", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "SENIOR2", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "VETERAN1", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "VETERAN2", roundDuration: 60000, pauseDuration: 60000}, + ], + mandatoryProtection1: 45, + mandatoryProtection2: 13 + }, + { + name: "Épée Bocle", + sword: "ONE_HAND", + shield: "BUCKLER", + categories: [ + {categorie: "POUSSIN", roundDuration: 45000, pauseDuration: 60000}, + {categorie: "BENJAMIN", roundDuration: 45000, pauseDuration: 60000}, + {categorie: "MINIME", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "CADET", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "JUNIOR", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "SENIOR1", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "SENIOR2", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "VETERAN1", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "VETERAN2", roundDuration: 60000, pauseDuration: 60000}, + ], + mandatoryProtection1: 45, + mandatoryProtection2: 13 + }, + { + name: "Épée Longue", + sword: "TWO_HAND", + shield: "NONE", + categories: [ + {categorie: "JUNIOR", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "SENIOR1", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "SENIOR2", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "VETERAN1", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "VETERAN2", roundDuration: 60000, pauseDuration: 60000}, + ], + mandatoryProtection1: 61, + mandatoryProtection2: 29 + }, + { + name: "Sabre", + sword: "SABER", + shield: "NONE", + categories: [ + {categorie: "MINIME", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "CADET", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "JUNIOR", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "SENIOR1", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "SENIOR2", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "VETERAN1", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "VETERAN2", roundDuration: 60000, pauseDuration: 60000}, + ], + mandatoryProtection1: 47, + mandatoryProtection2: 47 + }, + { + name: "Sabre Bocle", + sword: "SABER", + shield: "BUCKLER", + categories: [ + {categorie: "MINIME", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "CADET", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "JUNIOR", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "SENIOR1", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "SENIOR2", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "VETERAN1", roundDuration: 60000, pauseDuration: 60000}, + {categorie: "VETERAN2", roundDuration: 60000, pauseDuration: 60000}, + ], + mandatoryProtection1: 47, + mandatoryProtection2: 47 + }, + { + name: "Profight Léger", + sword: "ONE_HAND", + shield: "TEARDROP", + categories: [ + {categorie: "SENIOR1", roundDuration: 120000, pauseDuration: 60000}, + {categorie: "SENIOR2", roundDuration: 120000, pauseDuration: 60000}, + {categorie: "VETERAN1", roundDuration: 120000, pauseDuration: 60000}, + {categorie: "VETERAN2", roundDuration: 120000, pauseDuration: 60000}, + ], + mandatoryProtection1: 3647, + mandatoryProtection2: 3647 + }, +] + +export default CategoryPreset; diff --git a/src/main/webapp/src/components/ProtectionSelector.jsx b/src/main/webapp/src/components/ProtectionSelector.jsx index 5ee6063..367c5af 100644 --- a/src/main/webapp/src/components/ProtectionSelector.jsx +++ b/src/main/webapp/src/components/ProtectionSelector.jsx @@ -1,98 +1,165 @@ +import {useTranslation} from "react-i18next"; -const ProtectionSelector = ({mandatoryProtection = 0, setMandatoryProtection = () => {} }) => { +const ProtectionSelector = ({ + shield = true, + mandatoryProtection = 0, setMandatoryProtection = () => { + } + }) => { + const {t} = useTranslation(); const toggle = (bit) => { + bit = 1 << (bit - 1); setMandatoryProtection(v => (v & bit ? v & ~bit : v | bit)); }; - const isOn = (bit) => (mandatoryProtection & bit) !== 0; + const props = { + style: ({cursor: "pointer"}), + }; + + const propsDash = { + style: ({cursor: "pointer"}), + opacity: "0.8", + stroke: "#7b8285", + strokeDasharray: "4 3", + strokeWidth: "1" + }; + + const isOn = (bit) => (mandatoryProtection & (1 << (bit - 1))) !== 0; const color = (bit) => (isOn(bit) ? "#4ade80" : "#e5e7eb"); + /* + 1 - 1 - Casque + 2 - 2 - Gorgerin + 3 - 4 - Coquille et Protection pelvienne + 4 - 8 - Gant main(s) armée(s) + 5 - 16 - Gant main bouclier + 6 - 32 - Plastron + 7 - 64 - Protection de bras armé(s) + 8 - 128 - Protection de bras de bouclier + 9 - 256 - Protection de jambes + 10 - 512 - Protection de genoux + 11 - 1024 - Protection de coudes + 12 - 2048 - Protection dorsale + 13 - 4096 - Protection de pieds + */ return ( -
- - + + - {/* Head */} - toggle(1)} - /> + {/* Casque */} + toggle(1)} + >{t('casque')} - {/* Throat / Neck */} - toggle(2)} - /> + {/* Gorgerin */} + toggle(2)} + >{t('gorgerin')} - {/* Torso */} - toggle(4)} - /> + {/* Plastron */} + toggle(6)} + >{t('plastron')} - {/* Arms */} - toggle(8)} - /> - toggle(8)} - /> + {/* Protection dorsale */} + toggle(12)} + >{t('protectionDorsale')} - {/* Hands */} - toggle(16)} - /> - toggle(16)} - /> + {/* Protection de bras armé(s) */} + toggle(7)} + >{shield ? t('protectionDeBrasArmé') : t('protectionDeBras')} + {/* Protection de bras de bouclier */} + toggle(shield ? 8 : 7)} + >{shield ? t('protectionDeBrasDeBouclier') : t('protectionDeBras')} - {/* Legs */} - toggle(64)} - /> - toggle(64)} - /> + {/* Protection de coudes */} + toggle(11)} + >{t('protectionDeCoudes')} + toggle(11)} + >{t('protectionDeCoudes')} - {/* Groin */} - toggle(32)} - /> + {/* Gant main(s) armée(s) */} + toggle(4)} + >{shield ? t('gantMainsArmées') : t('gants')} + {/* Gant main bouclier */} + toggle(shield ? 5 : 4)} + >{shield ? t('gantMainBouclier') : t('gants')} - {/* Feet */} - - - -
+ {/* Protection de jambes */} + toggle(9)} + >{t('protectionDeJambes')} + toggle(9)} + >{t('protectionDeJambes')} + + {/* Protection de genoux */} + toggle(10)} + >{t('protectionDeGenoux')} + toggle(10)} + >{t('protectionDeGenoux')} + + {/* Coquille et Protection pelvienne */} + toggle(3)} + >{t('coquilleProtectionPelvienne')} + + {/* Protection de pieds */} + toggle(13)} + >{t('protectionDePieds')} + toggle(13)} + >{t('protectionDePieds')} + ); } diff --git a/src/main/webapp/src/pages/competition/CompetitionEdit.jsx b/src/main/webapp/src/pages/competition/CompetitionEdit.jsx index fbadfa5..064dcf8 100644 --- a/src/main/webapp/src/pages/competition/CompetitionEdit.jsx +++ b/src/main/webapp/src/pages/competition/CompetitionEdit.jsx @@ -23,6 +23,7 @@ import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"; import {faAdd, faTrashCan} from "@fortawesome/free-solid-svg-icons"; import {Trans, useTranslation} from "react-i18next"; import ProtectionSelector from "../../components/ProtectionSelector.jsx"; +import CategoryPreset from "../../assets/CategoryPreset.js"; export function CompetitionEdit() { const {id} = useParams() @@ -372,7 +373,7 @@ function Content({data}) { setModaleState(preset)}> {preset.name} - {preset.categories.sort(sortCategories).map((cat, index) => + {preset.categories.map(e => e.categorie).sort(sortCategories).map((cat, index) => {getCatName(cat)})} )} @@ -381,11 +382,27 @@ function Content({data}) {
{presetChange && t('LesModificationsNontEnregistrer')}
- +
+ + +
    + {CategoryPreset.map((preset, index) => +
  • + +
  • )} +
+
@@ -479,10 +496,9 @@ function CatModalContent({setPresets, setPresetChange, state}) { const [name, setName] = useState(state.name || "") const [sword, setSword] = useState(state.sword || "NONE") const [shield, setShield] = useState(state.shield || "NONE") - const [time, setTime] = useState(timePrint(state.roundDuration || 90000)) - const [pause, setPause] = useState(timePrint(state.pauseDuration || 60000)) const [cats, setCats] = useState(state.categories || []) - const [mandatoryProtection, setMandatoryProtection] = useState(state.mandatoryProtection || 33) + const [mandatoryProtection1, setMandatoryProtection1] = useState(state.mandatoryProtection1 || 5) + const [mandatoryProtection2, setMandatoryProtection2] = useState(state.mandatoryProtection2 || 5) const {t} = useTranslation(); @@ -490,23 +506,42 @@ function CatModalContent({setPresets, setPresetChange, state}) { setName(state.name || "") setSword(state.sword || "NONE") setShield(state.shield || "NONE") - setTime(timePrint(state.roundDuration || 90000)) - setPause(timePrint(state.pauseDuration || 60000)) - setCats(state.categories || []) - setMandatoryProtection(state.mandatoryProtection || 33) + setCats(state.categories?.map(c => ({ + categorie: c.categorie, + roundDuration: timePrint(c.roundDuration), + pauseDuration: timePrint(c.pauseDuration) + })) || []) + setMandatoryProtection1(state.mandatoryProtection1 || 5) + setMandatoryProtection2(state.mandatoryProtection2 || 5) }, [state]); const setCat = (e, cat) => { if (e.target.checked) { if (!cats.includes(cat)) { - setCats([...cats, cat]) + setCats([...cats, {categorie: cat, roundDuration: "", pauseDuration: ""}]) } } else { - setCats(cats.filter(c => c !== cat)) + setCats(cats.filter(c => c.categorie !== cat)) } } + const setTime = (e, cat) => { + const value = e.target.value; + setCats(cats.map(c => { + if (c.categorie === cat) + return {...c, roundDuration: value} + return c + })) + } + const setPause = (e, cat) => { + const value = e.target.value; + setCats(cats.map(c => { + if (c.categorie === cat) + return {...c, pauseDuration: value} + return c + })) + } - const isCatSelected = (cat) => cats.includes(cat) + const isCatSelected = (cat) => cats.some(cat_ => cat_.categorie === cat) const parseTime = (str) => { const parts = str.split(":").map(part => parseInt(part, 10)); @@ -525,10 +560,13 @@ function CatModalContent({setPresets, setPresetChange, state}) { name: name, sword: sword, shield: shield, - roundDuration: parseTime(time), - pauseDuration: parseTime(pause), - categories: cats, - mandatoryProtection: mandatoryProtection + categories: cats.map(c => ({ + categorie: c.categorie, + roundDuration: parseTime(c.roundDuration), + pauseDuration: parseTime(c.pauseDuration) + })), + mandatoryProtection1: mandatoryProtection1, + mandatoryProtection2: mandatoryProtection2 } setPresets(presets => [...presets.filter(p => p.id !== out.id), out]) setPresetChange(true) @@ -553,19 +591,6 @@ function CatModalContent({setPresets, setPresetChange, state}) { value={name} onChange={e => setName(e.target.value)}/> -
- {t('duréeRound')} - setTime(e.target.value)}/> - (mm:ss) -
-
- {t('duréePause')} - setPause(e.target.value)}/> - (mm:ss) -
-
{t('arme')} setCat(e, cat)}/> - -
- )} - + + + + + + + + + + + {CatList.map((cat, index) => + + + + + )} + +
{t('catégorie')}{t('peutSinscrire')}{t('duréeRound')}{t('duréePause')}
setCat(e, cat)}/> c.categorie === cat)?.roundDuration || ""} + onChange={e => setTime(e, cat)} + aria-label="mm:ss" hidden={!isCatSelected(cat)} style={{width: "4.5em"}}/> c.categorie === cat)?.pauseDuration || ""} + onChange={e => setPause(e, cat)} + aria-label="mm:ss" hidden={!isCatSelected(cat)} style={{width: "4.5em"}}/>
{t('protectionObligatoire')} :
- + {cats.some(cat_ => CatList.indexOf(cat_.categorie) <= CatList.indexOf("JUNIOR")) && <> +
< 18 {t('ans')}
+ + } + {cats.some(cat_ => CatList.indexOf(cat_.categorie) > CatList.indexOf("JUNIOR")) && <> +
≥ 18 {t('ans')}
+ + }
diff --git a/src/main/webapp/src/pages/competition/CompetitionRegisterAdmin.jsx b/src/main/webapp/src/pages/competition/CompetitionRegisterAdmin.jsx index 0d88ca1..04638b7 100644 --- a/src/main/webapp/src/pages/competition/CompetitionRegisterAdmin.jsx +++ b/src/main/webapp/src/pages/competition/CompetitionRegisterAdmin.jsx @@ -3,7 +3,7 @@ import {LoadingProvider, useLoadingSwitcher} from "../../hooks/useLoading.jsx"; import {useFetch} from "../../hooks/useFetch.js"; import {AxiosError} from "../../components/AxiosError.jsx"; import {ThreeDots} from "react-loader-spinner"; -import React, {useEffect, useReducer, useRef, useState} from "react"; +import React, {useEffect, useId, useReducer, useRef, useState} from "react"; import {apiAxios, applyOverCategory, CatList, getCatName, getToastMessage} from "../../utils/Tools.js"; import {toast} from "react-toastify"; import {SimpleReducer} from "../../utils/SimpleReducer.jsx"; @@ -317,6 +317,8 @@ const AutoCompleteInput = ({suggestions = [], handleAdd}) => { function CategoriesList({error2, availableCats, fistCatInput, categories, setCategories}) { const {t} = useTranslation(); + const id = useId(); + return <> {error2 ? : <> {availableCats && availableCats.length === 0 &&
{t('aucuneCatégorieDisponible')}
} @@ -325,9 +327,9 @@ function CategoriesList({error2, availableCats, fistCatInput, categories, setCat style={{display: "contents"}}>
setCategories(e, cat.id)}/> - +
)} } @@ -427,7 +429,7 @@ function Modal({data2, error2, sendRegister, modalState, setModalState, source}) } const currenCat = gcat !== "" ? applyOverCategory(gcat, cat) : ""; - const availableCats = data2 ? (currenCat !== "" ? data2.filter(c => c.categories.includes(currenCat)) : data2).sort((a, b) => a.name.localeCompare(b.name)) : [] + const availableCats = data2 ? (currenCat !== "" ? data2.filter(c => c.categories.some(c2 => c2.categorie === currenCat)) : data2).sort((a, b) => a.name.localeCompare(b.name)) : [] if (availableCats.length === 0) { if (fistCatInput.current) { fistCatInput.current = null @@ -625,7 +627,8 @@ function MakeCentralPanel({data, data2, dispatch, id, setModalState, source}) { {req.data.categoriesInscrites.map(catId => data2?.find(c => c.id === catId)).filter(o => o !== undefined) .sort((a, b) => a.name.localeCompare(b.name)).map(cat => - {cat.name})} + {cat.name})} diff --git a/src/main/webapp/src/pages/competition/CompetitionView.jsx b/src/main/webapp/src/pages/competition/CompetitionView.jsx index c17b816..9aec3d5 100644 --- a/src/main/webapp/src/pages/competition/CompetitionView.jsx +++ b/src/main/webapp/src/pages/competition/CompetitionView.jsx @@ -74,7 +74,7 @@ function MakeContent({data}) { disabled={new Date() < new Date(data.startRegister.split('+')[0]) || new Date() > new Date(data.endRegister.split('+')[0])} onClick={_ => navigate("/competition/" + data.id + "/club/register")}>{t('comp.inscription')} } - {data.registerMode === "FREE" && !isClubAdmin(userinfo) && + {data.registerMode === "FREE" && !isClubAdmin(userinfo) && || } {data.registerMode === "HELLOASSO" && @@ -147,7 +147,7 @@ function SelfRegister({data2}) { } const currenCat = data?.length > 0 && data[0]?.categorie !== "" ? applyOverCategory(data[0]?.categorie, cat) : ""; - const availableCats = data3 ? (currenCat !== "" ? data3.filter(c => c.categories.includes(currenCat)) : data3).sort((a, b) => a.name.localeCompare(b.name)) : [] + const availableCats = data3 ? (currenCat !== "" ? data3.filter(c => c.categories.some(c2 => c2.categorie === currenCat)) : data3).sort((a, b) => a.name.localeCompare(b.name)) : [] return <> {data