mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-11 10:47:27 +03:00
31 lines
1 KiB
TypeScript
31 lines
1 KiB
TypeScript
import { FC } from 'react';
|
|
import { faMinusCircle as deleteIcon } from '@fortawesome/free-solid-svg-icons';
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
import { useToggle } from '../utils/helpers/hooks';
|
|
import { DeleteServerModalProps } from './DeleteServerModal';
|
|
import { ServerWithId } from './data';
|
|
|
|
export interface DeleteServerButtonProps {
|
|
server: ServerWithId;
|
|
className?: string;
|
|
textClassName?: string;
|
|
}
|
|
|
|
const DeleteServerButton = (DeleteServerModal: FC<DeleteServerModalProps>): FC<DeleteServerButtonProps> => (
|
|
{ server, className, children, textClassName },
|
|
) => {
|
|
const [ isModalOpen, , showModal, hideModal ] = useToggle();
|
|
|
|
return (
|
|
<>
|
|
<span className={className} onClick={showModal}>
|
|
{!children && <FontAwesomeIcon icon={deleteIcon} />}
|
|
<span className={textClassName}>{children ?? 'Remove this server'}</span>
|
|
</span>
|
|
|
|
<DeleteServerModal server={server} isOpen={isModalOpen} toggle={hideModal} />
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default DeleteServerButton;
|