import React, { useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import Dialog from '../Dialog'; import Button from '../Button'; import useKeyPress from '../../hooks/useKeyPress'; import { TextWrapper, BtnWrapper } from './styled'; type Props = { onCancel: () => void; onDelete: () => void; }; const index: React.FC = ({ onCancel, onDelete }: Props) => { const { t } = useTranslation('dialog'); const enterKeyPress = useKeyPress('Enter'); const escKeyPress = useKeyPress('Escape'); useEffect(() => { if (enterKeyPress) { onDelete(); } if (escKeyPress) { onCancel(); } }, [enterKeyPress, escKeyPress]); return ( {t('deleteAnnotationAlert')} ); }; export default index;