fix: evaluation on empty eval category was KO
This commit is contained in:
@@ -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) =>
|
||||
|
||||
Reference in New Issue
Block a user