diff --git a/app/soapbox/components/authorize-reject-buttons.tsx b/app/soapbox/components/authorize-reject-buttons.tsx index 01a45ce8e..690f6a04f 100644 --- a/app/soapbox/components/authorize-reject-buttons.tsx +++ b/app/soapbox/components/authorize-reject-buttons.tsx @@ -4,25 +4,30 @@ 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 + onAuthorize(): Promise | unknown + onReject(): Promise | unknown } /** Buttons to approve or reject a pending item, usually an account. */ -const AuthorizeRejectButtons: React.FC = ({ id, onAuthorize, onReject }) => { +const AuthorizeRejectButtons: React.FC = ({ onAuthorize, onReject }) => { const [state, setState] = useState<'authorized' | 'rejected' | 'pending'>('pending'); - function handleAuthorize() { - onAuthorize(id) - .then(() => setState('authorized')) - .catch(console.error); + async function handleAuthorize() { + try { + await onAuthorize(); + setState('authorized'); + } catch (e) { + console.error(e); + } } - function handleReject() { - onReject(id) - .then(() => setState('rejected')) - .catch(console.error); + async function handleReject() { + try { + await onReject(); + setState('rejected'); + } catch (e) { + console.error(e); + } } switch (state) {