import React, { useState } from 'react'; import { useTranslation } from 'react-i18next'; import { Button, Menu, MenuItem } from '@material-ui/core'; import MoreIcon from '@material-ui/icons/MoreVert'; import { usePhone } from '../../../../os/phone/hooks/usePhone'; import Nui from '../../../../os/nui-events/utils/Nui'; import ReportButton from '../buttons/ReportButton'; import { TwitterEvents } from '../../../../../../typings/twitter'; export const ShowMore = ({ id, isReported, isMine }) => { const [anchorEl, setAnchorEl] = useState(null); const { t } = useTranslation(); const { config } = usePhone(); if (!config) return null; const handleClick = (event: React.MouseEvent) => { const element = event.currentTarget; setAnchorEl(element); }; const handleClose = () => { setAnchorEl(null); }; const handleDeleteTweet = () => { Nui.send(TwitterEvents.DELETE_TWEET, id); handleClose(); }; const allowedToDelete = config.twitter.allowDeleteTweets && isMine; const allowedToReport = config.twitter.allowReportTweets && !isMine; // if the user cannot perform any actions in show more then don't // allow them to interact with it let _handleClick = allowedToDelete || allowedToReport ? handleClick : () => null; return ( <> {allowedToDelete && ( {t('APPS_TWITTER_DELETE')} )} {allowedToReport && ( )} ); }; export default ShowMore;