import { Trash } from 'iconsax-react'
import { type FC, useState } from 'react'
import ModalConfrim from './ModalConfrim'

interface Props {
    onDelete: () => void,
    isLoading?: boolean
}

const TrashWithConfrim: FC<Props> = ({ onDelete, isLoading = false }) => {
    const [isConfirm, setIsConfirm] = useState(false)
    return (
        <div>
            <Trash
                onClick={() => setIsConfirm(true)}
                className='size-5'
                color='#888'
            />

            <ModalConfrim
                isOpen={isConfirm}
                close={() => setIsConfirm(false)}
                onConfrim={() => onDelete()}
                isLoading={isLoading}
            />
        </div>
    )
}

export default TrashWithConfrim