tasko/app/(platform)/(dashboard)/board/[boardId]/_components/card-item.tsx

39 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-02-16 01:49:19 +00:00
'use client';
2024-02-15 02:30:10 +00:00
2024-02-16 01:49:19 +00:00
import { Draggable } from '@hello-pangea/dnd';
import { Card } from '@prisma/client';
import { format } from 'date-fns';
2024-02-15 02:30:10 +00:00
2024-02-16 01:49:19 +00:00
import { useCardModal } from '@/hooks/use-card-modal';
import { Calendar } from 'lucide-react';
2024-02-15 02:30:10 +00:00
interface CardItemProps {
index: number;
data: Card;
}
export const CardItem = ({ index, data }: CardItemProps) => {
const cardModal = useCardModal();
return (
<Draggable draggableId={data.id} index={index}>
{(provided) => (
<div
{...provided.draggableProps}
{...provided.dragHandleProps}
ref={provided.innerRef}
2024-02-16 01:49:19 +00:00
role='button'
2024-02-15 02:30:10 +00:00
onClick={() => cardModal.onOpen(data.id)}
2024-02-16 01:49:19 +00:00
className='truncate rounded-md border-2 border-transparent bg-white px-3 py-2 text-sm shadow-sm hover:border-black'
2024-02-15 02:30:10 +00:00
>
{data.title}
<div className='flex w-fit rounded-md border-2 border-transparent bg-slate-100 px-0.5 pb-0.5 pt-0.5 text-sm'>
<Calendar className='ml-0.5 mr-0.5 h-4 w-4' />
{data?.dueDate ? 'Due: ' + format(data.dueDate, 'PP') : 'No Due Date'}
</div>
2024-02-15 02:30:10 +00:00
</div>
)}
</Draggable>
);
};