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

Function MyTasksSidebar

src/components/MyTasksSidebar.jsx:6–89  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4import { Link } from 'react-router-dom';
5
6function MyTasksSidebar() {
7
8 const user = { id: 'user_1' }
9
10 const { currentWorkspace } = useSelector((state) => state.workspace);
11 const [showMyTasks, setShowMyTasks] = useState(false);
12 const [myTasks, setMyTasks] = useState([]);
13
14 const toggleMyTasks = () => setShowMyTasks(prev => !prev);
15
16 const getTaskStatusColor = (status) => {
17 switch (status) {
18 case 'DONE':
19 return 'bg-green-500';
20 case 'IN_PROGRESS':
21 return 'bg-yellow-500';
22 case 'TODO':
23 return 'bg-gray-500 dark:bg-zinc-500';
24 default:
25 return 'bg-gray-400 dark:bg-zinc-400';
26 }
27 };
28
29 const fetchUserTasks = () => {
30 const userId = user?.id || '';
31 if (!userId || !currentWorkspace) return;
32 const currentWorkspaceTasks = currentWorkspace.projects.flatMap((project) => {
33 return project.tasks.filter((task) => task?.assignee?.id === userId);
34 });
35
36 setMyTasks(currentWorkspaceTasks);
37 }
38
39 useEffect(() => {
40 fetchUserTasks()
41 }, [currentWorkspace])
42
43 return (
44 <div className="mt-6 px-3">
45 <div onClick={toggleMyTasks} className="flex items-center justify-between px-3 py-2 rounded-lg cursor-pointer hover:bg-gray-100 dark:hover:bg-zinc-800" >
46 <div className="flex items-center gap-2">
47 <CheckSquareIcon className="w-4 h-4 text-gray-500 dark:text-zinc-400" />
48 <h3 className="text-sm font-medium text-gray-700 dark:text-zinc-300">My Tasks</h3>
49 <span className="bg-gray-200 dark:bg-zinc-700 text-gray-700 dark:text-zinc-300 text-xs px-2 py-0.5 rounded">
50 {myTasks.length}
51 </span>
52 </div>
53 {showMyTasks ? (
54 <ChevronDownIcon className="w-4 h-4 text-gray-500 dark:text-zinc-400" />
55 ) : (
56 <ChevronRightIcon className="w-4 h-4 text-gray-500 dark:text-zinc-400" />
57 )}
58 </div>
59
60 {showMyTasks && (
61 <div className="mt-2 pl-2">
62 <div className="space-y-1">
63 {myTasks.length === 0 ? (

Callers

nothing calls this directly

Calls 2

fetchUserTasksFunction · 0.85
getTaskStatusColorFunction · 0.85

Tested by

no test coverage detected