import React, { useCallback } from 'react'; import PropTypes from 'prop-types'; import { useTranslation } from 'react-i18next'; import { Menu } from 'semantic-ui-react'; import { withPopup } from '../../lib/popup'; import { Popup } from '../../lib/custom-ui'; import { useSteps } from '../../hooks'; import DeleteStep from '../DeleteStep'; import styles from './ActionsPopup.module.scss'; const StepTypes = { DELETE: 'DELETE', }; const ActionsStep = React.memo(({ onNameEdit, onCardAdd, onDelete, onClose }) => { const [t] = useTranslation(); const [step, openStep, handleBack] = useSteps(); const handleEditNameClick = useCallback(() => { onNameEdit(); onClose(); }, [onNameEdit, onClose]); const handleAddCardClick = useCallback(() => { onCardAdd(); onClose(); }, [onCardAdd, onClose]); const handleDeleteClick = useCallback(() => { openStep(StepTypes.DELETE); }, [openStep]); if (step && step.type === StepTypes.DELETE) { return ( ); } return ( <> {t('common.listActions', { context: 'title', })} {t('action.editTitle', { context: 'title', })} {t('action.addCard', { context: 'title', })} {onDelete && ( {t('action.deleteList', { context: 'title', })} )} ); }); ActionsStep.propTypes = { onNameEdit: PropTypes.func.isRequired, onCardAdd: PropTypes.func.isRequired, onDelete: PropTypes.func, onClose: PropTypes.func.isRequired, }; ActionsStep.defaultProps = { onDelete: undefined, }; export default withPopup(ActionsStep);