import { useState } from 'react'; import { useTranslation } from 'react-i18next'; import { FileCode2, Trash2, Plus, GripVertical, RotateCcw } from 'lucide-react'; import { DndContext, closestCenter, KeyboardSensor, PointerSensor, useSensor, useSensors, type DragEndEvent, } from '@dnd-kit/core'; import { arrayMove, SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy, } from '@dnd-kit/sortable'; import { useSortable, } from '@dnd-kit/sortable'; import { CSS } from '@dnd-kit/utilities'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Textarea } from '@/components/ui/textarea'; import { Label } from '@/components/ui/label'; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion'; import { useAppContext } from '@/hooks/useAppContext'; import { useToast } from '@/hooks/useToast'; interface ProjectTemplate { name: string; description: string; url: string; } interface SortableTemplateItemProps { template: ProjectTemplate; index: number; onRemove: (index: number) => void; onUpdate: (index: number, template: ProjectTemplate) => void; showDragHandle: boolean; isOnlyTemplate: boolean; } function SortableTemplateItem({ template, index, onRemove, onUpdate, showDragHandle, isOnlyTemplate, }: SortableTemplateItemProps) { const { t } = useTranslation(); const { attributes, listeners, setNodeRef, transform, transition, isDragging, } = useSortable({ id: `template-${index}` }); const style = { transform: CSS.Transform.toString(transform), transition, opacity: isDragging ? 0.5 : 1, }; return (
{showDragHandle && (
)} {template.name}
onUpdate(index, { ...template, name: e.target.value })} />