2801-пофиксил зависания днд. Не нравится он мне, добавлю toggle

This commit is contained in:
2026-01-28 01:33:32 +03:00
parent 1e2d43be8e
commit 326aabd91d

View File

@@ -49,7 +49,6 @@ export const InvoiceDraftPage: React.FC = () => {
const [updatingItems, setUpdatingItems] = useState<Set<string>>(new Set()); const [updatingItems, setUpdatingItems] = useState<Set<string>>(new Set());
const [itemsOrder, setItemsOrder] = useState<Record<string, number>>({}); const [itemsOrder, setItemsOrder] = useState<Record<string, number>>({});
const [enabled, setEnabled] = useState(false);
const [isDragging, setIsDragging] = useState(false); const [isDragging, setIsDragging] = useState(false);
// Состояние для просмотра фото чека // Состояние для просмотра фото чека
@@ -171,9 +170,6 @@ export const InvoiceDraftPage: React.FC = () => {
}); });
// --- ЭФФЕКТЫ --- // --- ЭФФЕКТЫ ---
useEffect(() => {
setEnabled(true);
}, []);
useEffect(() => { useEffect(() => {
if (draft) { if (draft) {
@@ -526,65 +522,40 @@ export const InvoiceDraftPage: React.FC = () => {
</div> </div>
{/* Items List */} {/* Items List */}
{enabled ? ( <DragDropContext onDragStart={handleDragStart} onDragEnd={handleDragEnd}>
<DragDropContext <Droppable droppableId="draft-items">
onDragStart={handleDragStart} {(provided, snapshot) => (
onDragEnd={handleDragEnd} <div
> {...provided.droppableProps}
<Droppable droppableId="draft-items"> ref={provided.innerRef}
{(provided, snapshot) => ( style={{
<div display: "flex",
{...provided.droppableProps} flexDirection: "column",
ref={provided.innerRef} gap: 8,
style={{ backgroundColor: snapshot.isDraggingOver
display: "flex", ? "#f0f0f0"
flexDirection: "column", : "transparent",
gap: 8, borderRadius: "4px",
backgroundColor: snapshot.isDraggingOver padding: snapshot.isDraggingOver ? "8px" : "0",
? "#f0f0f0" transition: "background-color 0.2s ease",
: "transparent", }}
borderRadius: "4px", >
padding: snapshot.isDraggingOver ? "8px" : "0", {draft.items.map((item, index) => (
transition: "background-color 0.2s ease", <DraftItemRow
}} key={item.id}
> item={item}
{draft.items.map((item, index) => ( index={index}
<DraftItemRow onUpdate={handleItemUpdate}
key={item.id} onDelete={(itemId) => deleteItemMutation.mutate(itemId)}
item={item} isUpdating={updatingItems.has(item.id)}
index={index} recommendations={recommendationsQuery.data || []}
onUpdate={handleItemUpdate} />
onDelete={(itemId) => deleteItemMutation.mutate(itemId)} ))}
isUpdating={updatingItems.has(item.id)} {provided.placeholder}
recommendations={recommendationsQuery.data || []} </div>
/> )}
))} </Droppable>
{provided.placeholder} </DragDropContext>
</div>
)}
</Droppable>
</DragDropContext>
) : (
<div
style={{
display: "flex",
flexDirection: "column",
gap: 8,
}}
>
{draft.items.map((item, index) => (
<DraftItemRow
key={item.id}
item={item}
index={index}
onUpdate={handleItemUpdate}
onDelete={(itemId) => deleteItemMutation.mutate(itemId)}
isUpdating={updatingItems.has(item.id)}
recommendations={recommendationsQuery.data || []}
/>
))}
</div>
)}
{/* Кнопка добавления позиции */} {/* Кнопка добавления позиции */}
<Button <Button