diff --git a/packages/desktop-client/src/components/accounts/MobileAccounts.jsx b/packages/desktop-client/src/components/accounts/MobileAccounts.jsx index 158dbec52fa..731466ca6eb 100644 --- a/packages/desktop-client/src/components/accounts/MobileAccounts.jsx +++ b/packages/desktop-client/src/components/accounts/MobileAccounts.jsx @@ -1,7 +1,27 @@ import React, { useEffect, useState } from 'react'; import { useSelector } from 'react-redux'; +import { + DndContext, + MouseSensor, + TouchSensor, + closestCenter, + useSensor, + useSensors, +} from '@dnd-kit/core'; +import { + restrictToParentElement, + restrictToVerticalAxis, +} from '@dnd-kit/modifiers'; +import { + SortableContext, + useSortable, + verticalListSortingStrategy, +} from '@dnd-kit/sortable'; +import { CSS } from '@dnd-kit/utilities'; + import * as queries from 'loot-core/src/client/queries'; +import { send } from 'loot-core/src/platform/client/fetch'; import { useActions } from '../../hooks/useActions'; import { useCategories } from '../../hooks/useCategories'; @@ -16,6 +36,7 @@ import { View } from '../common/View'; import { Page } from '../Page'; import { PullToRefresh } from '../responsive/PullToRefresh'; import { CellValue } from '../spreadsheet/CellValue'; +import { findSortDown, getDropPosition } from '../util/sort'; function AccountHeader({ name, amount, style = {} }) { return ( @@ -52,8 +73,26 @@ function AccountHeader({ name, amount, style = {} }) { } function AccountCard({ account, updated, getBalanceQuery, onSelect }) { + const { + isDragging, + attributes, + listeners, + setNodeRef, + transform, + transition, + } = useSortable({ id: account.id }); + + const dndStyle = { + opacity: isDragging ? 0.5 : undefined, + transform: CSS.Transform.toString(transform), + transition, + }; + return (