2022-09-13 01:21:56 -07:00
|
|
|
import React, { useCallback } from 'react';
|
2022-04-11 14:02:37 -07:00
|
|
|
|
|
|
|
import { authorizeFollowRequest, rejectFollowRequest } from 'soapbox/actions/accounts';
|
2022-12-26 08:34:55 -08:00
|
|
|
import Account from 'soapbox/components/account';
|
2023-03-20 17:23:11 -07:00
|
|
|
import { AuthorizeRejectButtons } from 'soapbox/components/authorize-reject-buttons';
|
2023-01-09 14:13:12 -08:00
|
|
|
import { useAppDispatch, useAppSelector } from 'soapbox/hooks';
|
2022-04-11 14:02:37 -07:00
|
|
|
import { makeGetAccount } from 'soapbox/selectors';
|
|
|
|
|
|
|
|
interface IAccountAuthorize {
|
2023-02-15 13:26:27 -08:00
|
|
|
id: string
|
2022-04-11 14:02:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
const AccountAuthorize: React.FC<IAccountAuthorize> = ({ id }) => {
|
2023-01-09 14:13:12 -08:00
|
|
|
const dispatch = useAppDispatch();
|
2022-10-11 11:22:54 -07:00
|
|
|
|
2022-09-13 01:21:56 -07:00
|
|
|
const getAccount = useCallback(makeGetAccount(), []);
|
2022-04-11 14:02:37 -07:00
|
|
|
const account = useAppSelector((state) => getAccount(state, id));
|
|
|
|
|
2023-03-20 17:23:11 -07:00
|
|
|
const onAuthorize = () => dispatch(authorizeFollowRequest(id));
|
|
|
|
const onReject = () => dispatch(rejectFollowRequest(id));
|
2022-04-11 14:02:37 -07:00
|
|
|
|
|
|
|
if (!account) return null;
|
|
|
|
|
|
|
|
return (
|
2023-03-12 15:12:10 -07:00
|
|
|
<div className='p-2.5'>
|
|
|
|
<Account
|
|
|
|
account={account}
|
|
|
|
action={
|
2023-03-20 17:23:11 -07:00
|
|
|
<AuthorizeRejectButtons
|
|
|
|
onAuthorize={onAuthorize}
|
|
|
|
onReject={onReject}
|
2023-03-27 15:13:44 -07:00
|
|
|
countdown={3000}
|
2023-03-20 17:23:11 -07:00
|
|
|
/>
|
2023-03-12 15:12:10 -07:00
|
|
|
}
|
|
|
|
/>
|
|
|
|
</div>
|
2022-04-11 14:02:37 -07:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default AccountAuthorize;
|