mirror of
https://github.com/TurTaskProject/TurTaskWeb.git
synced 2025-12-19 22:14:07 +01:00
Fix move task over task error
This commit is contained in:
parent
b331fd97c3
commit
2b013cda45
@ -9,7 +9,7 @@ export function ColumnContainer({ column, createTask, tasks, deleteTask, updateT
|
|||||||
return tasks.map((task) => task.id);
|
return tasks.map((task) => task.id);
|
||||||
}, [tasks]);
|
}, [tasks]);
|
||||||
|
|
||||||
const { setNodeRef, attributes, listeners, transform, transition, isDragging } = useSortable({
|
const { setNodeRef, attributes, listeners } = useSortable({
|
||||||
id: column.id,
|
id: column.id,
|
||||||
data: {
|
data: {
|
||||||
type: "Column",
|
type: "Column",
|
||||||
|
|||||||
@ -221,17 +221,37 @@ export function KanbanBoard() {
|
|||||||
|
|
||||||
const activeId = active.id;
|
const activeId = active.id;
|
||||||
const isActiveATask = active.data.current?.type === "Task";
|
const isActiveATask = active.data.current?.type === "Task";
|
||||||
|
const isOverATask = over.data.current?.type === "Task";
|
||||||
const isOverAColumn = over.data.current?.type === "Column";
|
const isOverAColumn = over.data.current?.type === "Column";
|
||||||
|
|
||||||
|
if (isActiveATask && isOverATask) {
|
||||||
|
setTasks((tasks) => {
|
||||||
|
const activeIndex = tasks.findIndex((t) => t.id === activeId);
|
||||||
|
const columnId = over.data.current.task.columnId;
|
||||||
|
tasks[activeIndex].columnId = columnId;
|
||||||
|
// API call to update task's columnId
|
||||||
|
axiosInstance
|
||||||
|
.put(`todo/change_task_list_board/`, {
|
||||||
|
todo_id: activeId,
|
||||||
|
new_list_board_id: columnId,
|
||||||
|
new_index: 0,
|
||||||
|
})
|
||||||
|
.then((response) => {})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("Error updating task columnId:", error);
|
||||||
|
});
|
||||||
|
|
||||||
|
return arrayMove(tasks, activeIndex, activeIndex);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Move tasks between columns and update columnId
|
// Move tasks between columns and update columnId
|
||||||
if (isActiveATask && isOverAColumn) {
|
if (isActiveATask && isOverAColumn) {
|
||||||
setTasks((tasks) => {
|
setTasks((tasks) => {
|
||||||
const activeIndex = tasks.findIndex((t) => t.id === activeId);
|
const activeIndex = tasks.findIndex((t) => t.id === activeId);
|
||||||
|
|
||||||
const columnId = over.data.current.column.id;
|
const columnId = over.data.current.column.id;
|
||||||
|
|
||||||
tasks[activeIndex].columnId = columnId;
|
tasks[activeIndex].columnId = columnId;
|
||||||
|
|
||||||
// API call to update task's columnId
|
// API call to update task's columnId
|
||||||
axiosInstance
|
axiosInstance
|
||||||
.put(`todo/change_task_list_board/`, {
|
.put(`todo/change_task_list_board/`, {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user