fix: evaluation on empty eval category was KO

This commit is contained in:
Julien Froidefond
2025-08-22 12:03:59 +02:00
parent 376012fce6
commit 76015510f3
5 changed files with 88 additions and 31 deletions

View File

@@ -1,6 +1,6 @@
"use client";
import { useState } from "react";
import { useState, useEffect } from "react";
import { Button } from "@/components/ui/button";
import {
Dialog,
@@ -42,13 +42,22 @@ export function SkillSelector({
const currentCategory = categories.find(
(cat) => cat.category === selectedCategory
);
// Utiliser les évaluations passées en props (qui viennent du contexte et sont mises à jour)
const currentEvaluation = evaluations.find(
(evaluation) => evaluation.category === selectedCategory
);
if (!currentCategory) return null;
const selectedSkillIds = currentEvaluation?.selectedSkillIds || [];
// Si la catégorie n'existe pas dans l'évaluation, créer une évaluation vide pour cette catégorie
const effectiveEvaluation = currentEvaluation || {
category: selectedCategory,
skills: [],
selectedSkillIds: [],
};
const selectedSkillIds = effectiveEvaluation.selectedSkillIds || [];
const filteredSkills = currentCategory.skills.filter(
(skill) =>