import { useState, useEffect } from 'react'; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card"; import { Trash2, Edit2, Plus, Terminal, Loader2 } from "lucide-react"; import { ScrollArea } from "@/components/ui/scroll-area"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger, DialogFooter } from "@/components/ui/dialog"; import { Label } from "@/components/ui/label"; import { Textarea } from "@/components/ui/textarea"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { api } from "@/lib/api"; interface Skill { id: string; name: string; description: string; content: string; type: 'python' | 'sql' | 'api'; } export function Skills() { const [skills, setSkills] = useState([]); const [isLoading, setIsLoading] = useState(false); const [isDialogOpen, setIsDialogOpen] = useState(false); const [newSkill, setNewSkill] = useState>({ type: 'python', content: '' }); useEffect(() => { fetchSkills(); }, []); const fetchSkills = async () => { setIsLoading(true); try { const data = await api.get('/api/v1/skills'); setSkills(data); } catch (error) { console.error("Failed to fetch skills", error); } finally { setIsLoading(false); } }; const handleAddSkill = async () => { if (newSkill.name && newSkill.description && newSkill.content) { try { const skillToCreate = { ...newSkill, id: Date.now().toString(), }; const createdSkill = await api.post('/api/v1/skills', skillToCreate); setSkills([...skills, createdSkill]); setNewSkill({ type: 'python', content: '' }); setIsDialogOpen(false); } catch (error) { console.error("Failed to create skill", error); } } }; const handleDeleteSkill = async (id: string) => { try { await api.delete(`/api/v1/skills/${id}`); setSkills(skills.filter(s => s.id !== id)); } catch (error) { console.error("Failed to delete skill", error); } }; return (

Skills

Manage AI capabilities and tools

Add Skill } /> Add New Skill
setNewSkill({...newSkill, name: e.target.value})} className="col-span-3" />