MCPcopy Create free account
hub / github.com/GreatStackDev/project-management / ProjectTasks

Function ProjectTasks

src/components/ProjectTasks.jsx:23–281  ·  view source on GitHub ↗
({ tasks })

Source from the content-addressed store, hash-verified

21};
22
23const ProjectTasks = ({ tasks }) => {
24 const dispatch = useDispatch();
25 const navigate = useNavigate();
26 const [selectedTasks, setSelectedTasks] = useState([]);
27
28 const [filters, setFilters] = useState({
29 status: "",
30 type: "",
31 priority: "",
32 assignee: "",
33 });
34
35 const assigneeList = useMemo(
36 () => Array.from(new Set(tasks.map((t) => t.assignee?.name).filter(Boolean))),
37 [tasks]
38 );
39
40 const filteredTasks = useMemo(() => {
41 return tasks.filter((task) => {
42 const { status, type, priority, assignee } = filters;
43 return (
44 (!status || task.status === status) &&
45 (!type || task.type === type) &&
46 (!priority || task.priority === priority) &&
47 (!assignee || task.assignee?.name === assignee)
48 );
49 });
50 }, [filters, tasks]);
51
52 const handleFilterChange = (e) => {
53 const { name, value } = e.target;
54 setFilters((prev) => ({ ...prev, [name]: value }));
55 };
56
57 const handleStatusChange = async (taskId, newStatus) => {
58 try {
59 toast.loading("Updating status...");
60
61 // Simulate API call
62 await new Promise((resolve) => setTimeout(resolve, 2000));
63
64 let updatedTask = structuredClone(tasks.find((t) => t.id === taskId));
65 updatedTask.status = newStatus;
66 dispatch(updateTask(updatedTask));
67
68 toast.dismissAll();
69 toast.success("Task status updated successfully");
70 } catch (error) {
71 toast.dismissAll();
72 toast.error(error?.response?.data?.message || error.message);
73 }
74 };
75
76 const handleDelete = async () => {
77 try {
78 const confirm = window.confirm("Are you sure you want to delete the selected tasks?");
79 if (!confirm) return;
80

Callers

nothing calls this directly

Calls 1

handleStatusChangeFunction · 0.85

Tested by

no test coverage detected