diff --git a/worklenz-frontend/src/components/enhanced-kanban/EnhancedKanbanTaskCard.tsx b/worklenz-frontend/src/components/enhanced-kanban/EnhancedKanbanTaskCard.tsx index 855fb82a..1ba62614 100644 --- a/worklenz-frontend/src/components/enhanced-kanban/EnhancedKanbanTaskCard.tsx +++ b/worklenz-frontend/src/components/enhanced-kanban/EnhancedKanbanTaskCard.tsx @@ -1,9 +1,25 @@ -import React from 'react'; +import React, { useCallback, useMemo, useState } from 'react'; import { useSortable, defaultAnimateLayoutChanges } from '@dnd-kit/sortable'; import { CSS } from '@dnd-kit/utilities'; import { IProjectTask } from '@/types/project/projectTasksViewModel.types'; import { useAppSelector } from '@/hooks/useAppSelector'; import './EnhancedKanbanTaskCard.css'; +import Flex from 'antd/es/flex'; +import Tag from 'antd/es/tag'; +import Tooltip from 'antd/es/tooltip'; +import Progress from 'antd/es/progress'; +import Button from 'antd/es/button'; +import { useAppDispatch } from '@/hooks/useAppDispatch'; +import { setShowTaskDrawer, setSelectedTaskId } from '@/features/task-drawer/task-drawer.slice'; +import PrioritySection from '../board/taskCard/priority-section/priority-section'; +import Typography from 'antd/es/typography'; +import CustomAvatarGroup from '../board/custom-avatar-group'; +import CustomDueDatePicker from '../board/custom-due-date-picker'; +import { themeWiseColor } from '@/utils/themeWiseColor'; +import { ForkOutlined } from '@ant-design/icons'; +import { Dayjs } from 'dayjs'; +import dayjs from 'dayjs'; +import { CaretDownFilled, CaretRightFilled } from '@ant-design/icons'; interface EnhancedKanbanTaskCardProps { task: IProjectTask; @@ -18,8 +34,12 @@ const EnhancedKanbanTaskCard: React.FC = React.memo isDragOverlay = false, isDropTarget = false }) => { + const dispatch = useAppDispatch(); const themeMode = useAppSelector(state => state.themeReducer.mode); - + const [dueDate, setDueDate] = useState( + task?.end_date ? dayjs(task?.end_date) : null + ); + const [isSubTaskShow, setIsSubTaskShow] = useState(false); const { attributes, listeners, @@ -44,6 +64,39 @@ const EnhancedKanbanTaskCard: React.FC = React.memo backgroundColor: themeMode === 'dark' ? '#292929' : '#fafafa', }; + const handleCardClick = useCallback((e: React.MouseEvent, id: string) => { + // Prevent the event from propagating to parent elements + e.stopPropagation(); + + // Don't handle click if we're dragging + if (isDragging) return; + + // Add a small delay to ensure it's a click and not the start of a drag + const clickTimeout = setTimeout(() => { + dispatch(setSelectedTaskId(id)); + dispatch(setShowTaskDrawer(true)); + }, 50); + + return () => clearTimeout(clickTimeout); + }, [dispatch, isDragging]); + + const renderLabels = useMemo(() => { + if (!task?.labels?.length) return null; + + return ( + <> + {task.labels.slice(0, 2).map((label: any) => ( + + + {label.name} + + + ))} + {task.labels.length > 2 && + {task.labels.length - 2}} + + ); + }, [task.labels, themeMode]); + return (
= React.memo {...attributes} {...listeners} > -
-
{task.name}
- {/* {task.task_key &&
{task.task_key}
} */} - {task.assignees && task.assignees.length > 0 && ( -
- Assignees: {task.assignees.map(a => a.name).join(', ')} -
- )} +
handleCardClick(e, task.id || '')}> + + + {renderLabels} + + + + = 100 ? 9 : 7} /> + + + + {/* Action Icons */} + + + {task.name} + + + + {task && } + + + + + {/* Subtask Section */} + + +
);