chore: move row into other block

This commit is contained in:
ascarbek 2023-03-16 18:59:05 +06:00
parent ab5b40fa51
commit fa427fe650

View File

@ -82,12 +82,18 @@ export const useDatabase = (viewId: string, type?: ViewLayoutTypePB) => {
};
const onDragEnd: OnDragEndResponder = async (result) => {
if (!controller) return;
const { source, destination } = result;
// move inside the block (group)
const group = groups.find((g) => g.groupId === source.droppableId);
if (!group) return;
if (source.droppableId === destination?.droppableId) {
const group = groups.find((g) => g.groupId === source.droppableId);
if (!group || !controller) return;
// move inside the block (group)
await controller.exchangeRow(group.rows[source.index].id, group.rows[destination.index].id);
} else {
// move to different block (group)
if (!destination?.droppableId) return;
await controller.moveRow(group.rows[source.index].id, destination.droppableId);
}
};