Files
new-phone-who-dis/phone/src/apps/twitter/components/buttons/ReportButton.tsx
T
Taso 0f61088999 refactor(events): Events are now tied to a common enum typings (#167)
* chore(scripts/twitter): Refactored twitter to use event enums

* chore(scripts/marketplace): Refactored marketplace to use event enums

* chore(scripts/messages): Refactored messages to use event enums

* chore(scripts/contacts): Refactored contacts to use event enums

* chore(scripts/calls): Refactored calls to use event enums

* chore(scripts/notes): Refactored notes to use event enums

* chore(scripts/photos): Refactored photos to use event enums

* chore(scripts/bank): Refactored bank to use event enums

* chore(scripts/phone): Refactored phone to use event enums

* chore(events): Removed old events object

* refactor(phone/nui-events): Attached NUI events to respective enum

* tweak(event-enums): Added npwd prefix to all events

* tweak(phone/serve): Added craco to override CRA without eject

Also bumped react-scripts to 4.0.1, with seemingly no issues

* fix(typings/twitter): Fixed method enums for twitter
2021-03-22 13:37:07 -04:00

45 lines
1.1 KiB
TypeScript

import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Button, CircularProgress, MenuItem } from '@material-ui/core';
import DoneIcon from '@material-ui/icons/Done';
import Nui from '../../../../os/nui-events/utils/Nui';
import { TwitterEvents } from '../../../../../../typings/twitter';
const LOADING_TIME = 1250;
function ReportButton({ handleClose, tweetId, isReported }) {
const { t } = useTranslation();
const [loading, setLoading] = useState(false);
const handleClick = () => {
Nui.send(TwitterEvents.REPORT, tweetId);
setLoading(true);
window.setTimeout(() => {
setLoading(false);
handleClose();
}, LOADING_TIME);
};
if (isReported) {
return (
<MenuItem onClick={handleClose}>
<DoneIcon />
<span style={{ marginLeft: '5px' }}>{t('APPS_TWITTER_REPORTED')}</span>
</MenuItem>
);
}
if (loading) {
return (
<Button disabled>
<CircularProgress id="twitter-report-progress" size={22} />
</Button>
);
}
return <MenuItem onClick={handleClick}>{t('APPS_TWITTER_REPORT')}</MenuItem>;
}
export default ReportButton;