"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 { getTechIcon } from "./icons/tech-icons"; 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 (
{selectedSkills.length} compétence {selectedSkills.length > 1 ? "s" : ""} sélectionnée {selectedSkills.length > 1 ? "s" : ""}
Aucune compétence sélectionnée
Cliquez sur "Ajouter une compétence" pour commencer