'use client' import { useState } from 'react' import { useRouter } from 'next/navigation' import { deleteItem } from '@/lib/actions' import { Trash2 } from 'lucide-react' interface DeleteItemButtonProps { itemId: string listId: string } export default function DeleteItemButton({ itemId, listId }: DeleteItemButtonProps) { const router = useRouter() const [isDeleting, setIsDeleting] = useState(false) const [showConfirm, setShowConfirm] = useState(false) const handleDelete = async () => { setIsDeleting(true) try { await deleteItem(itemId) router.push(`/list/${listId}`) } catch (error) { console.error('Error deleting item:', error) setIsDeleting(false) setShowConfirm(false) } } if (showConfirm) { return (
) } return ( ) }