'use client'; import {useState} from 'react'; import {FontAwesomeIcon} from '@fortawesome/react-fontawesome'; import {faTrash} from '@fortawesome/free-solid-svg-icons'; import AlertBox from '@/components/AlertBox'; interface DeleteButtonProps { onDelete: () => void | Promise; confirmTitle: string; confirmMessage: string; confirmButtonText: string; cancelButtonText: string; disabled?: boolean; className?: string; } export default function DeleteButton( { onDelete, confirmTitle, confirmMessage, confirmButtonText, cancelButtonText, disabled = false, className = '' }: DeleteButtonProps ) { const [showConfirm, setShowConfirm] = useState(false); function handlePress(): void { if (disabled) return; setShowConfirm(true); } async function handleConfirm(): Promise { setShowConfirm(false); await onDelete(); } function handleCancel(): void { setShowConfirm(false); } return ( <> {showConfirm && ( )} ); }