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