import React, { useState } from 'react'; import { FormattedMessage } from 'react-intl'; import { HStack, IconButton, Text } from 'soapbox/components/ui'; interface IAuthorizeRejectButtons { onAuthorize(): Promise | unknown onReject(): Promise | unknown } /** Buttons to approve or reject a pending item, usually an account. */ const AuthorizeRejectButtons: React.FC = ({ onAuthorize, onReject }) => { const [state, setState] = useState<'authorized' | 'rejected' | 'pending'>('pending'); async function handleAuthorize() { try { await onAuthorize(); setState('authorized'); } catch (e) { console.error(e); } } async function handleReject() { try { await onReject(); setState('rejected'); } catch (e) { console.error(e); } } switch (state) { case 'pending': return ( ); case 'authorized': return (
); case 'rejected': return (
); } }; export { AuthorizeRejectButtons };