'use client'; import { Copy, Trash } from 'lucide-react'; import { useParams } from 'next/navigation'; import { toast } from 'sonner'; import { Skeleton } from '@/components/ui/skeleton'; import { deleteCard } from '@/actions/delete-card'; import { Button } from '@/components/ui/button'; import { useAction } from '@/hooks/use-action'; import { copyCard } from '@/actions/copy-card'; import { CardWithList } from '@/types'; import { useCardModal } from '@/hooks/use-card-modal'; import { DatePicker } from '@/components/ui/date-picker'; interface ActionsProps { data: CardWithList; } export const Actions = ({ data }: ActionsProps) => { const params = useParams(); const cardModal = useCardModal(); const { execute: executeDeleteCard, isLoading: isLoadingDelete } = useAction( deleteCard, { onSuccess: () => { toast.success(`Card "${data.title}" deleted`); cardModal.onClose(); }, onError: (error) => { toast.error(error); }, } ); const { execute: executeCopyCard, isLoading: isLoadingCopy } = useAction( copyCard, { onSuccess: () => { toast.success(`Card "${data.title}" copied`); cardModal.onClose(); }, onError: (error) => { toast.error(error); }, } ); const onCopy = () => { const boardId = params.boardId as string; executeCopyCard({ id: data.id, boardId, }); }; const onDelete = () => { const boardId = params.boardId as string; executeDeleteCard({ id: data.id, boardId, }); }; return (
Actions