File tree Expand file tree Collapse file tree
client/src/features/tasks Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,7 +56,11 @@ const SortableList = () => {
5656 const overIndex = previousTasks . findIndex ( ( { id } ) => id === over . id ) ;
5757 const newOrder = arrayMove ( previousTasks , activeIndex , overIndex ) ;
5858 queryClient . setQueryData < TaskProps [ ] > ( [ 'tasks' , listId ] , newOrder ) ;
59- const items = newOrder . map ( ( task , index ) => ( { id : task . id , position : index } ) ) ;
59+ const minIndex = Math . min ( activeIndex , overIndex ) ;
60+ const maxIndex = Math . max ( activeIndex , overIndex ) ;
61+ const items = newOrder
62+ . slice ( minIndex , maxIndex + 1 )
63+ . map ( ( task , i ) => ( { id : task . id , position : minIndex + i } ) ) ;
6064 reorderTasks . mutate ( { items, listId, previousTasks } ) ;
6165 }
6266 setActive ( null ) ;
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ export const deleteTask = async (taskId: string): Promise<void> => {
4040} ;
4141
4242export const reorderTasks = async ( items : { id : string ; position : number } [ ] ) : Promise < void > => {
43- await api . patch ( 'api/tasks/reorder' , items ) ;
43+ await api . put ( 'api/tasks/reorder' , items ) ;
4444} ;
4545
4646export const duplicateTask = async ( taskId : string ) : Promise < TaskProps [ ] > => {
You can’t perform that action at this time.
0 commit comments