"use client"; import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { Input } from "@/components/ui/input"; import { Plus, Search } from "lucide-react"; import { SkillCategory, CategoryEvaluation } from "@/lib/types"; import { TechIcon } from "./icons/tech-icon"; interface SkillSelectorProps { categories: SkillCategory[]; evaluations: CategoryEvaluation[]; selectedCategory: string; onAddSkill: (category: string, skillId: string) => void; onRemoveSkill: (category: string, skillId: string) => void; } export function SkillSelector({ categories, evaluations, selectedCategory, onAddSkill, onRemoveSkill, }: SkillSelectorProps) { const [isOpen, setIsOpen] = useState(false); const [searchTerm, setSearchTerm] = useState(""); const currentCategory = categories.find( (cat) => cat.category === selectedCategory ); const currentEvaluation = evaluations.find( (evaluation) => evaluation.category === selectedCategory ); if (!currentCategory) return null; const selectedSkillIds = currentEvaluation?.selectedSkillIds || []; const filteredSkills = currentCategory.skills.filter( (skill) => skill.name.toLowerCase().includes(searchTerm.toLowerCase()) || skill.description.toLowerCase().includes(searchTerm.toLowerCase()) ); const availableSkills = filteredSkills.filter( (skill) => !selectedSkillIds.includes(skill.id) ); const selectedSkills = currentCategory.skills.filter((skill) => selectedSkillIds.includes(skill.id) ); return (
{/* Selected Skills */}

Mes compétences sélectionnées

Ajouter des compétences - {selectedCategory} Choisissez les compétences que vous souhaitez évaluer dans cette catégorie.
{/* Search */}
setSearchTerm(e.target.value)} className="pl-10" />
{/* Available Skills Grid */}
{availableSkills.length > 0 ? ( availableSkills.map((skill) => (
{skill.name}

{skill.description}

)) ) : (
{searchTerm ? "Aucune compétence trouvée" : "Toutes les compétences ont été ajoutées"}
)}
{selectedSkills.length > 0 ? (

{selectedSkills.length} compétence {selectedSkills.length > 1 ? "s" : ""} sélectionnée {selectedSkills.length > 1 ? "s" : ""}

Supprimez directement depuis les lignes ci-dessous
) : (

Aucune compétence sélectionnée

Cliquez sur "Ajouter une compétence" pour commencer

)}
); }