From 965c08aec1347453e3d7a57c758038f8ae2ff99d Mon Sep 17 00:00:00 2001 From: Julien Froidefond Date: Fri, 22 Aug 2025 12:18:26 +0200 Subject: [PATCH] fix: add all skills KO if no skill in categ --- components/evaluation/client-wrapper.tsx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/components/evaluation/client-wrapper.tsx b/components/evaluation/client-wrapper.tsx index 9dd78e6..32b1953 100644 --- a/components/evaluation/client-wrapper.tsx +++ b/components/evaluation/client-wrapper.tsx @@ -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,