2022-09-07 10:00:28 +03:00
|
|
|
import { Button, ButtonProps } from 'antd';
|
2022-05-30 07:52:38 +03:00
|
|
|
import { HeartFilled } from '@ant-design/icons';
|
2022-09-07 10:00:28 +03:00
|
|
|
import { FC, useState } from 'react';
|
2022-06-25 01:55:53 +03:00
|
|
|
import { useRecoilValue } from 'recoil';
|
2022-09-07 10:00:28 +03:00
|
|
|
import { Modal } from '../ui/Modal/Modal';
|
|
|
|
import { FollowModal } from '../modals/FollowModal/FollowModal';
|
|
|
|
import styles from './ActionButton/ActionButton.module.scss';
|
2022-06-25 01:55:53 +03:00
|
|
|
import { clientConfigStateAtom } from '../stores/ClientConfigStore';
|
|
|
|
import { ClientConfig } from '../../interfaces/client-config.model';
|
2022-05-30 07:52:38 +03:00
|
|
|
|
2022-09-07 10:00:28 +03:00
|
|
|
export type FollowButtonProps = ButtonProps;
|
|
|
|
|
|
|
|
export const FollowButton: FC<FollowButtonProps> = props => {
|
2022-05-30 07:52:38 +03:00
|
|
|
const [showModal, setShowModal] = useState(false);
|
2022-06-25 01:55:53 +03:00
|
|
|
const clientConfig = useRecoilValue<ClientConfig>(clientConfigStateAtom);
|
2022-08-23 04:27:47 +03:00
|
|
|
const { name, federation } = clientConfig;
|
|
|
|
const { account } = federation;
|
2022-05-30 07:52:38 +03:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Button
|
2022-07-08 10:10:18 +03:00
|
|
|
{...props}
|
2022-05-30 07:52:38 +03:00
|
|
|
type="primary"
|
2022-09-07 10:00:28 +03:00
|
|
|
className={styles.button}
|
2022-05-30 07:52:38 +03:00
|
|
|
icon={<HeartFilled />}
|
2022-09-07 10:00:28 +03:00
|
|
|
onClick={() => setShowModal(true)}
|
2022-05-30 07:52:38 +03:00
|
|
|
>
|
|
|
|
Follow
|
|
|
|
</Button>
|
2022-08-23 04:27:47 +03:00
|
|
|
<Modal
|
|
|
|
title={`Follow ${name}`}
|
|
|
|
visible={showModal}
|
|
|
|
handleCancel={() => setShowModal(false)}
|
|
|
|
width="550px"
|
|
|
|
height="200px"
|
|
|
|
>
|
|
|
|
<FollowModal account={account} name={name} handleClose={() => setShowModal(false)} />
|
2022-06-25 01:55:53 +03:00
|
|
|
</Modal>
|
2022-05-30 07:52:38 +03:00
|
|
|
</>
|
|
|
|
);
|
2022-09-07 10:00:28 +03:00
|
|
|
};
|