'use client'; import { useState, useCallback } from 'react'; import { X } from '@phosphor-icons/react'; import { SkillCombobox } from '@/components/skill-combobox'; import { Badge } from '@/components/ui/badge'; import type { ProfileSkill } from '@/lib/types'; interface PositionSkillEditorProps { linkedSkills: ProfileSkill[]; /** All skills on the user's profile, for combobox suggestions. */ profileSkills?: ProfileSkill[]; onAdd: (skillName: string, category: string) => void; onRemove: (rkey: string) => void; } export function PositionSkillEditor({ linkedSkills, profileSkills, onAdd, onRemove, }: PositionSkillEditorProps) { const [query, setQuery] = useState(''); const [category, setCategory] = useState(''); const handleChange = useCallback((skillName: string, cat: string) => { setQuery(skillName); setCategory(cat); }, []); const handleSelect = useCallback( (skillName: string, cat: string) => { if (skillName.trim().length < 2) return; onAdd(skillName.trim(), cat); setQuery(''); setCategory(''); }, [onAdd], ); return (
{linkedSkills.length > 0 && (
{linkedSkills.map((skill) => ( {skill.name} ))}
)}
); }