import React, { useState } from 'react'; import { IconButton, Menu, MenuItem } from '@material-ui/core'; import MoreVertIcon from '@material-ui/icons/MoreVert'; import { useHistory } from 'react-router-dom'; import RemoveDialog from '../../common/components/RemoveDialog'; import { useTranslation } from '../../common/components/LocalizationProvider'; const CollectionActions = ({ itemId, editPath, endpoint, setTimestamp, }) => { const history = useHistory(); const t = useTranslation(); const [menuAnchorEl, setMenuAnchorEl] = useState(null); const [removing, setRemoving] = useState(false); const handleEdit = () => { history.push(`${editPath}/${itemId}`); setMenuAnchorEl(null); }; const handleRemove = () => { setRemoving(true); setMenuAnchorEl(null); }; const handleRemoveResult = (removed) => { setRemoving(false); if (removed) { setTimestamp(Date.now()); } }; return ( <> setMenuAnchorEl(event.currentTarget)}> setMenuAnchorEl(null)}> {t('sharedEdit')} {t('sharedRemove')} ); }; export default CollectionActions;