text: import React, { useContext } from 'react';
  import { useToast } from '@chakra-ui/react';
  import { useTranslation } from 'react-i18next';
  
  import { BulletinContext } from '../../context/BulletinContext';
  
  import ErrorButton from '../../common/ErrorButton';
  
  const RemoveCVEToBulletinButton = (props) => {
    const { t } = useTranslation();
    const removeFromBulletinT = t('cve-search-results.remove-from-bulletin');
    const couldNotBeDeletedFromBulletinT = t('cve-search-results.could-not-be-deleted-from-bulletin');
    const removedFromBulletinT = t('cve-search-results.removed-from-bulletin');
  
    const {
      isButtonDisabled, setButtonDisabled, cve, ...style
    } = props;
  
    const { removeCveFromBulletin } = useContext(BulletinContext);
    const toast = useToast();
  
    const handleRemoveFromBulletin = () => {
      const removedFromBulletin = removeCveFromBulletin(cve);
      if (removedFromBulletin) {
        toast({
          title: `${cve.cveId} ${removedFromBulletinT}`,
          status: 'info',
          duration: 2000,
          isClosable: true,
        });
        setButtonDisabled.off();
      } else {
        toast({
          title: `${cve.cveId} ${couldNotBeDeletedFromBulletinT}`,
          status: 'error',
          duration: 2000,
          isClosable: true,
        });
      }
    };
  
    return (
      <ErrorButton
        mt={[2, 2, 0]}
        p={2}
        flexBasis={['unset', 'unset', '30%', '20%']}
        disabled={!isButtonDisabled}
        onClick={handleRemoveFromBulletin}
        {...style}
      >
        {removeFromBulletinT}
      </ErrorButton>
    );
  };
  
  export default RemoveCVEToBulletinButton;
  