"use client"; import { useState } from "react"; import { Button } from "@/components/ui/button"; import { ChevronDown, ChevronRight, ExternalLink } from "lucide-react"; import { getCategoryIcon } from "@/lib/category-icons"; import { getScoreColors } from "@/lib/score-utils"; import { getImportanceColors } from "@/lib/tech-colors"; import { SkillProgress } from "./skill-progress"; import Link from "next/link"; interface CategoryCardProps { category: { category: string; score: number; maxScore: number; }; categoryEval?: { category: string; selectedSkillIds: string[]; skills: Array<{ skillId: string; level: string | null; }>; }; skillCategory?: { category: string; icon: string; skills: Array<{ id: string; name: string; icon?: string; importance: "incontournable" | "majeure" | "standard"; }>; }; } export function CategoryCard({ category, categoryEval, skillCategory, }: CategoryCardProps) { const [isExpanded, setIsExpanded] = useState(false); const skillsCount = categoryEval?.selectedSkillIds?.length || 0; const evaluatedCount = categoryEval?.skills.filter((s) => s.level !== null).length || 0; const CategoryIcon = skillCategory ? getCategoryIcon(skillCategory.icon) : null; return (
setIsExpanded(!isExpanded)} >
{isExpanded ? ( ) : ( )} {CategoryIcon && }

{category.category}

{skillsCount > 0 ? ( (() => { const colors = getScoreColors(category.score); return (
{Math.round((category.score / 3) * 100)}%
); })() ) : (
Aucune
)}
{skillsCount > 0 ? `${evaluatedCount}/${skillsCount} compétences sélectionnées évaluées` : "Aucune compétence sélectionnée"}
{skillsCount > 0 ? (
{(() => { const colors = getScoreColors(category.score); return (
); })()}
) : (
)}
{/* Expanded Skills */} {isExpanded && (
{categoryEval && skillCategory && skillsCount > 0 ? (
{categoryEval.selectedSkillIds .map((skillId) => { const skill = skillCategory.skills.find( (s) => s.id === skillId ); return skill ? { ...skill, id: skillId } : null; }) .filter( (skill): skill is NonNullable => skill !== null ) .sort((a, b) => { const importanceOrder = { incontournable: 2, majeure: 1, standard: 0, }; return ( importanceOrder[b.importance] - importanceOrder[a.importance] ); }) .map((skill) => { const skillEval = categoryEval.skills.find( (s) => s.skillId === skill.id ); return ( ); })}
) : (

Aucune compétence sélectionnée dans cette catégorie

)}
0 ? "mt-3 pt-3 border-t border-white/10" : "" }`} >
)}
); }