import { faCircle as toggleOnIcon } from '@fortawesome/free-regular-svg-icons'; import { faBan as toggleOffIcon, faEdit as editIcon, faMinusCircle as deleteIcon, faPlug as connectIcon, } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { RowDropdownBtn, useToggle } from '@shlinkio/shlink-frontend-kit'; import type { FC } from 'react'; import { Link } from 'react-router-dom'; import { DropdownItem } from 'reactstrap'; import type { FCWithDeps } from '../container/utils'; import { componentFactory, useDependencies } from '../container/utils'; import type { ServerWithId } from './data'; import type { DeleteServerModalProps } from './DeleteServerModal'; export type ManageServersRowDropdownProps = { server: ServerWithId; }; type ManageServersRowDropdownConnectProps = ManageServersRowDropdownProps & { setAutoConnect: (server: ServerWithId, autoConnect: boolean) => void; }; type ManageServersRowDropdownDeps = { DeleteServerModal: FC }; const ManageServersRowDropdown: FCWithDeps = ( { server, setAutoConnect }, ) => { const { DeleteServerModal } = useDependencies(ManageServersRowDropdown); const [isModalOpen,, showModal, hideModal] = useToggle(); const serverUrl = `/server/${server.id}`; const { autoConnect: isAutoConnect } = server; const autoConnectIcon = isAutoConnect ? toggleOffIcon : toggleOnIcon; return ( Connect Edit server setAutoConnect(server, !isAutoConnect)}> {isAutoConnect ? 'Do not a' : 'A'}uto-connect Remove server ); }; export const ManageServersRowDropdownFactory = componentFactory(ManageServersRowDropdown, ['DeleteServerModal']);