import { useParams, Link, useNavigate } from 'react-router-dom'; import { useCard } from '../hooks/useCard'; import { useCardDetailMutations } from '../hooks/useCardDetailMutations'; import { useChecklistMutations } from '../hooks/useChecklistMutations'; import { useLabels } from '../hooks/useLabels'; import { useLabelMutations, useCardLabelMutations } from '../hooks/useLabelMutations'; import { useModal } from '../context/modals/useModal'; import { CardSidebar } from '../components/CardSidebar'; import { CardComments } from '../components/CardComments'; import { CardChecklists } from '../components/CardChecklists'; import { CardLabels } from '../components/CardLabels'; import { EditCardModal } from '../components/EditCardModal'; import { DeleteCardModal } from '../components/DeleteCardModal'; import Trash2Icon from '../components/icons/Trash2Icon'; import ArrowLeftIcon from '../components/icons/ArrowLeftIcon'; import Edit2Icon from '../components/icons/Edit2Icon'; export function CardDetail() { const { id: boardId, cardId } = useParams<{ id: string; cardId: string }>(); const navigate = useNavigate(); const { card, fetchCard } = useCard(parseInt(cardId || '0')); const { updateCardNameAndDescription, deleteCardWithConfirmation, addComment, editComment, deleteCommentWithConfirmation, } = useCardDetailMutations(parseInt(cardId || '0'), card, fetchCard); const { openModal } = useModal(); const checklistMutations = useChecklistMutations(parseInt(cardId || '0'), fetchCard); // Labels functionality const { labels, refetch: refetchLabels } = useLabels(parseInt(boardId || '0')); const { addLabel } = useLabelMutations(parseInt(boardId || '0'), refetchLabels); const { addLabelToCardMutation, removeLabelFromCardMutation } = useCardLabelMutations( parseInt(cardId || '0'), fetchCard ); const handleEditCard = () => { if (!card) return; openModal((props) => ( { return await updateCardNameAndDescription(name, description); }} onClose={props.onClose} /> )); }; const handleDeleteCard = () => { if (!card) return; openModal((props) => ( { deleteCardWithConfirmation(() => { props.onClose(); navigate(`/boards/${boardId}`); }); }} onClose={props.onClose} /> )); }; if (!card) { return null; } const formatDate = (dateString: string) => { return new Date(dateString).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', }); }; return (
Back to Board

{card.name}

In list • Created {formatDate(card.created_at)}

{/* Description Section */}

Description

{card.description || 'No description added yet.'}

{/* Labels Section */} {/* Checklists Section */}
); }