fix: add all skills KO if no skill in categ

This commit is contained in:
Julien Froidefond
2025-08-22 12:18:26 +02:00
parent 90c2f25ec7
commit 965c08aec1

View File

@@ -265,7 +265,7 @@ export function EvaluationClientWrapper({
try {
// 1. Mise à jour optimiste de l'UI (immédiate)
const updatedEvaluations: CategoryEvaluation[] =
let updatedEvaluations: CategoryEvaluation[] =
currentEvaluation.evaluations.map((catEval) => {
if (catEval.category === category) {
// Filtrer seulement les compétences qui ne sont pas déjà sélectionnées
@@ -292,6 +292,25 @@ export function EvaluationClientWrapper({
return catEval;
});
// Si la catégorie n'existe pas encore, la créer
if (
!updatedEvaluations.find(
(evaluation) => evaluation.category === category
)
) {
const newCategoryEvaluation: CategoryEvaluation = {
category,
selectedSkillIds: skillIds,
skills: skillIds.map((skillId) => ({
skillId,
level: "never" as SkillLevel,
canMentor: false,
wantsToLearn: false,
})),
};
updatedEvaluations = [...updatedEvaluations, newCategoryEvaluation];
}
const newEvaluation: UserEvaluation = {
...currentEvaluation,
evaluations: updatedEvaluations,