feat(enhanced-kanban): implement real-time task updates via socket integration

- Added a useEffect hook to handle incoming tasks through a socket connection.
- Implemented logic to differentiate between regular tasks and subtasks, updating the state accordingly.
- Enhanced the EnhancedKanbanBoardNativeDnD component to support real-time task management, improving user interactivity.
This commit is contained in:
shancds
2025-07-03 15:39:11 +05:30
parent 6c4bcbe300
commit aee09aeb0d

View File

@@ -244,6 +244,37 @@ const EnhancedKanbanBoardNativeDnD: React.FC<{ projectId: string }> = ({ project
setDragType(null);
};
useEffect(() => {
if (!socket) return;
// Handler for new task received via socket
const handleNewTaskReceived = (data: any) => {
if (!data) return;
if (data.parent_task_id) {
// Subtask: update subtasks in the correct group
dispatch({
type: 'enhancedKanbanReducer/updateEnhancedKanbanSubtask',
payload: { sectionId: '', subtask: data, mode: 'add' }
});
} else {
// Regular task: add to the correct group
let sectionId = '';
if (groupBy === 'status') sectionId = data.status;
else if (groupBy === 'priority') sectionId = data.priority;
else if (groupBy === 'phase') sectionId = data.phase_id;
dispatch({
type: 'enhancedKanbanReducer/addTaskToGroup',
payload: { sectionId, task: data }
});
}
};
socket.on(SocketEvents.QUICK_TASK.toString(), handleNewTaskReceived);
return () => {
socket.off(SocketEvents.QUICK_TASK.toString(), handleNewTaskReceived);
};
}, [socket, groupBy, dispatch]);
if (error) {
return (
<Card>