import { FC, useRef } from 'react'; import { Button, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap'; import { useNavigate } from 'react-router-dom'; import { ServerWithId } from './data'; export interface DeleteServerModalProps { server: ServerWithId; toggle: () => void; isOpen: boolean; redirectHome?: boolean; } interface DeleteServerModalConnectProps extends DeleteServerModalProps { deleteServer: (server: ServerWithId) => void; } export const DeleteServerModal: FC = ( { server, toggle, isOpen, deleteServer, redirectHome = true }, ) => { const navigate = useNavigate(); const doDelete = useRef(false); const toggleAndDelete = () => { doDelete.current = true; toggle(); }; const onClosed = () => { if (!doDelete.current) { return; } deleteServer(server); redirectHome && navigate('/'); }; return ( Remove server

Are you sure you want to remove {server ? server.name : ''}?

No data will be deleted, only the access to this server will be removed from this device. You can create it again at any moment.

); };