'use client' import { useState } from 'react' import { useRouter } from 'next/navigation' import { deleteProject } from '@/app/actions/projects' import { Trash2, Loader2 } from 'lucide-react' interface DeleteProjectButtonProps { projectId: string projectName: string } export default function DeleteProjectButton({ projectId, projectName }: DeleteProjectButtonProps) { const router = useRouter() const [isDeleting, setIsDeleting] = useState(false) const [showConfirm, setShowConfirm] = useState(false) const handleDelete = async () => { setIsDeleting(true) const result = await deleteProject(projectId) if (!result.success) { alert(`Failed to delete project: ${result.error}`) setIsDeleting(false) setShowConfirm(false) return } // Success - redirect to projects list router.push('/projects') router.refresh() } if (showConfirm) { return (
Are you sure you want to delete {projectName}? This will permanently delete the project from Supabase and cannot be undone.