import { FC } from 'react'; import { DropdownItem } from 'reactstrap'; import { Link } from 'react-router-dom'; import { faChartPie as pieChartIcon, faEdit as editIcon } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { useToggle } from '../../utils/helpers/hooks'; import { DropdownBtnMenu } from '../../utils/DropdownBtnMenu'; import { EditDomainRedirectsModal } from './EditDomainRedirectsModal'; import { Domain } from '../data'; import { ShlinkDomainRedirects } from '../../api/types'; import { supportsDefaultDomainRedirectsEdition, supportsDomainVisits } from '../../utils/helpers/features'; import { getServerId, SelectedServer } from '../../servers/data'; import { DEFAULT_DOMAIN } from '../../visits/reducers/domainVisits'; interface DomainDropdownProps { domain: Domain; editDomainRedirects: (domain: string, redirects: Partial) => Promise; selectedServer: SelectedServer; } export const DomainDropdown: FC = ({ domain, editDomainRedirects, selectedServer }) => { const [isOpen, toggle] = useToggle(); const [isModalOpen, toggleModal] = useToggle(); const { isDefault } = domain; const canBeEdited = !isDefault || supportsDefaultDomainRedirectsEdition(selectedServer); const withVisits = supportsDomainVisits(selectedServer); const serverId = getServerId(selectedServer); return ( {withVisits && ( Visit stats )} Edit redirects ); };