Add follow+notify to actions menu and refactor how those modals are displayed. Closes #2247

This commit is contained in:
Gabe Kangas
2022-10-23 21:59:25 -07:00
parent dd5d24d3d2
commit 77369a3cbe
4 changed files with 112 additions and 45 deletions

View File

@@ -1,40 +1,22 @@
import { Button, ButtonProps } from 'antd';
import { HeartFilled } from '@ant-design/icons';
import { FC, useState } from 'react';
import { useRecoilValue } from 'recoil';
import { Modal } from '../ui/Modal/Modal';
import { FollowModal } from '../modals/FollowModal/FollowModal';
import { FC } from 'react';
import styles from './ActionButton/ActionButton.module.scss';
import { clientConfigStateAtom } from '../stores/ClientConfigStore';
import { ClientConfig } from '../../interfaces/client-config.model';
export type FollowButtonProps = ButtonProps;
export const FollowButton: FC<FollowButtonProps> = props => {
const [showModal, setShowModal] = useState(false);
const clientConfig = useRecoilValue<ClientConfig>(clientConfigStateAtom);
const { name, federation } = clientConfig;
const { account } = federation;
return (
<>
<Button
{...props}
type="primary"
className={styles.button}
icon={<HeartFilled />}
onClick={() => setShowModal(true)}
>
Follow
</Button>
<Modal
title={`Follow ${name}`}
open={showModal}
handleCancel={() => setShowModal(false)}
width="550px"
>
<FollowModal account={account} name={name} handleClose={() => setShowModal(false)} />
</Modal>
</>
);
export type FollowButtonProps = ButtonProps & {
onClick?: () => void;
props?: ButtonProps;
};
export const FollowButton: FC<FollowButtonProps> = ({ onClick, props }) => (
<Button
{...props}
type="primary"
className={styles.button}
icon={<HeartFilled />}
onClick={onClick}
>
Follow
</Button>
);