From bcda0e7315a9e7f28b9ffda35e95530387f926b0 Mon Sep 17 00:00:00 2001 From: mnerv <24420859+mnerv@users.noreply.github.com> Date: Mon, 20 Apr 2026 01:14:11 +0200 Subject: [PATCH] Add drag-and-drop section reordering --- src/App.tsx | 10 +++++++++- src/components/SectionBlock.tsx | 27 +++++++++++++++++++++++++-- src/hooks/useCarts.ts | 13 +++++++++++++ 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 2624fb6..8515420 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -52,7 +52,9 @@ export default function App() { const importRef = useRef(null) const { catalog, loading: catalogLoading, error: catalogError } = useCatalog() - const { carts, activeCart, activeId, storageError, setActiveCart, createCart, deleteCart, renameCart, importCart, exportCart, addSection, removeSection, renameSection, addItem, updateItem, removeItem } = useCarts() + const { carts, activeCart, activeId, storageError, setActiveCart, createCart, deleteCart, renameCart, importCart, exportCart, addSection, removeSection, renameSection, reorderSections, addItem, updateItem, removeItem } = useCarts() + const [dragSectionId, setDragSectionId] = useState(null) + const [dragOverId, setDragOverId] = useState(null) function commitCartRename() { if (renamingCartId && renameCartValue.trim()) renameCart(renamingCartId, renameCartValue.trim()) @@ -219,6 +221,12 @@ export default function App() { onEditItem={item => updateItem(section.id, item)} onRemoveSection={() => removeSection(section.id)} onRenameSection={label => renameSection(section.id, label)} + isDragging={dragSectionId === section.id} + isDragOver={dragOverId === section.id} + onDragStart={() => setDragSectionId(section.id)} + onDragOver={e => { e.preventDefault(); setDragOverId(section.id) }} + onDrop={() => { if (dragSectionId) reorderSections(dragSectionId, section.id); setDragOverId(null) }} + onDragEnd={() => { setDragSectionId(null); setDragOverId(null) }} /> ))}