Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions client/src/components/board/KanbanBoard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
if (projectId) {
fetchTasks();
}
}, [projectId]);

Check warning on line 56 in client/src/components/board/KanbanBoard.jsx

View workflow job for this annotation

GitHub Actions / test-frontend (18.x)

React Hook useEffect has a missing dependency: 'fetchTasks'. Either include it or remove the dependency array

// Socket.io real-time effects
useEffect(() => {
Expand Down Expand Up @@ -128,7 +128,7 @@
leaveProject(projectId);
};
}
}, [projectId, isConnected]);

Check warning on line 131 in client/src/components/board/KanbanBoard.jsx

View workflow job for this annotation

GitHub Actions / test-frontend (18.x)

React Hook useEffect has missing dependencies: 'addEventListener', 'joinProject', 'leaveProject', and 'removeEventListener'. Either include them or remove the dependency array

const fetchTasks = async () => {
try {
Expand Down Expand Up @@ -187,7 +187,7 @@
}

const sourceColumn = columns[source.droppableId];
const destinationColumn = columns[destination.droppableId];

Check failure on line 190 in client/src/components/board/KanbanBoard.jsx

View workflow job for this annotation

GitHub Actions / test-frontend (18.x)

'destinationColumn' is assigned a value but never used. Allowed unused vars must match /^[A-Z_]/u
const task = sourceColumn.tasks.find(t => t._id === draggableId);

if (!task) return;
Expand Down Expand Up @@ -247,11 +247,9 @@
const response = await taskService.createTask(newTask);
const createdTask = response.data?.task || response.data;

// Update local state
const newColumns = { ...columns };
newColumns[columnId].tasks.push(createdTask);
setColumns(newColumns);

// Don't update local state here - let socket event handle it to avoid duplicates
// The handleTaskCreated socket event will add the task to the UI

// Emit real-time event
emitTaskCreated(projectId, createdTask);

Expand Down
42 changes: 38 additions & 4 deletions client/src/components/board/TaskCreateForm.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import { Button, Input, Textarea, Select } from '../common';
import { useToast } from '../../hooks/useToast';
import { userService } from '../../services/userService';
import { Calendar, Flag, User } from 'lucide-react';

const TaskCreateForm = ({ onSubmit, onCancel }) => {
Expand All @@ -9,11 +10,27 @@ const TaskCreateForm = ({ onSubmit, onCancel }) => {
description: '',
priority: 'medium',
dueDate: '',
assignee: ''
assignedTo: ''
});
const [users, setUsers] = useState([]);
const [loading, setLoading] = useState(false);
const { toast } = useToast();

useEffect(() => {
fetchUsers();
}, []);

const fetchUsers = async () => {
try {
const response = await userService.getUsers();
const usersData = response.data?.users || response.users || response.data || [];
setUsers(Array.isArray(usersData) ? usersData : []);
} catch (error) {
console.error('Error fetching users:', error);
setUsers([]);
}
};

const priorityOptions = [
{ value: 'low', label: 'Low Priority', color: 'text-green-600' },
{ value: 'medium', label: 'Medium Priority', color: 'text-yellow-600' },
Expand All @@ -34,7 +51,7 @@ const TaskCreateForm = ({ onSubmit, onCancel }) => {
title: formData.title.trim(),
description: formData.description.trim(),
dueDate: formData.dueDate || null,
assignee: formData.assignee || null
assignedTo: formData.assignedTo || null
};

await onSubmit(taskData);
Expand All @@ -46,7 +63,7 @@ const TaskCreateForm = ({ onSubmit, onCancel }) => {
description: '',
priority: 'medium',
dueDate: '',
assignee: ''
assignedTo: ''
});
} catch (error) {
const errorMessage = error.response?.data?.message || error.message || 'Failed to create task';
Expand Down Expand Up @@ -113,6 +130,23 @@ const TaskCreateForm = ({ onSubmit, onCancel }) => {
className="border-0 shadow-none p-0 text-xs focus:ring-0 text-gray-600"
/>
</div>

{/* Assignee */}
<div className="flex items-center space-x-2">
<User className="h-4 w-4 text-gray-400" />
<Select
value={formData.assignedTo}
onChange={(e) => handleChange('assignedTo', e.target.value)}
className="border-0 shadow-none p-0 text-xs focus:ring-0"
>
<option value="">Unassigned</option>
{users.map(user => (
<option key={user._id} value={user._id}>
{user.name || user.email}
</option>
))}
</Select>
</div>
</div>

{/* Actions */}
Expand Down
Loading