diff --git a/src/pages/Today.tsx b/src/pages/Today.tsx index 86346dca..5eecf859 100644 --- a/src/pages/Today.tsx +++ b/src/pages/Today.tsx @@ -23,7 +23,7 @@ function Today() { // Task 목록 Get const { data: stagingData, isError: isStagingError } = useGetTasks({ isTotal, sortOrder }); const { data: targetData, isError: isTargetError } = useGetTasks({ targetDate }); - const { mutate } = useUpdateTaskStatus(); + const { mutate, queryClient } = useUpdateTaskStatus(); console.log('targetData', targetData); @@ -75,6 +75,19 @@ function Today() { const [movedTask] = sourceTasks.splice(source.index, 1); destinationTasks.splice(destination.index, 0, movedTask); + // 상태 업데이트 + if (source.droppableId === 'target') { + queryClient.setQueryData(['tasks'], { + target: { ...targetData, data: { ...targetData.data, tasks: sourceTasks } }, + staging: { ...stagingData, data: { ...stagingData.data, tasks: destinationTasks } }, + }); + } else { + queryClient.setQueryData(['tasks'], { + target: { ...targetData, data: { ...targetData.data, tasks: destinationTasks } }, + staging: { ...stagingData, data: { ...stagingData.data, tasks: sourceTasks } }, + }); + } + // API 호출 if (destination.droppableId === 'target') { mutate({