diff --git a/src/app/components/board/board.component.ts b/src/app/components/board/board.component.ts index a6939db..32f770e 100644 --- a/src/app/components/board/board.component.ts +++ b/src/app/components/board/board.component.ts @@ -111,8 +111,8 @@ export class BoardComponent { * - `itemMovedFrom`: Sets `taskMovedFrom` to the status. */ private subscribeToDragDropEvents(): void { - this.dragDropService.itemDropped.subscribe(({ id, status }) => { - this.handleItemDropped(id, status); + this.dragDropService.itemDropped.subscribe(({ task, status }) => { + this.handleItemDropped(task, status); }); this.dragDropService.itemMovedTo.subscribe(({ status }) => { @@ -139,11 +139,13 @@ export class BoardComponent { * @param taskId The id of the task being moved. * @param status The status of the column where the task was dropped. */ - handleItemDropped(taskId: string, status: string): void { - this.apiService.updateTaskStatus(taskId, status).subscribe({ + handleItemDropped(task: Task, status: string): void { + if (!task || task.status === status) return; + + this.apiService.updateTaskStatus(task.id!, status).subscribe({ next: () => { this.toastNotificationService.taskStatusUpdatedToast(); - this.updateTaskStatus(taskId, status); + this.updateTaskStatus(task.id!, status); }, error: (error) => console.error('Error updating task:', error), }); diff --git a/src/app/components/board/task/task.component.html b/src/app/components/board/task/task.component.html index 43a2351..d8333df 100644 --- a/src/app/components/board/task/task.component.html +++ b/src/app/components/board/task/task.component.html @@ -4,7 +4,7 @@