import RemoveCircleOutlineIcon from '@mui/icons-material/RemoveCircleOutline';
import { IconButton } from '@mui/material';
import { useIntl } from 'react-intl';
import { handleActionKeyDown } from 'utils/CommonFunction';

export default function FileDeleteButton({ onDelete, icon: IconComponent = RemoveCircleOutlineIcon, color = 'error' }) {
    const intl = useIntl();
    const label = intl.formatMessage({ id: 'ariaDeleteFile' });

    const handleDelete = (event) => {
        onDelete(event);
    };

    return (
        <IconButton
            size="small"
            color={color}
            tabIndex={0}
            aria-label={label}
            title={label}
            onClick={handleDelete}
            onKeyDown={(event) => handleActionKeyDown(event, handleDelete)}
        >
            <IconComponent fontSize="small" />
        </IconButton>
    );
}
