import { useRef } from 'react'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faInfoCircle as infoIcon } from '@fortawesome/free-solid-svg-icons'; import { UncontrolledTooltip } from 'reactstrap'; import classNames from 'classnames'; import { prettify } from '../../utils/helpers/numbers'; import VisitStatsLink, { VisitStatsLinkProps } from './VisitStatsLink'; import './ShortUrlVisitsCount.scss'; interface ShortUrlVisitsCountProps extends VisitStatsLinkProps { visitsCount: number; active?: boolean; } const ShortUrlVisitsCount = ({ visitsCount, shortUrl, selectedServer, active = false }: ShortUrlVisitsCountProps) => { const maxVisits = shortUrl?.meta?.maxVisits; const visitsLink = ( {prettify(visitsCount)} ); if (!maxVisits) { return visitsLink; } const prettifiedMaxVisits = prettify(maxVisits); const tooltipRef = useRef(); return ( <> {visitsLink} { tooltipRef.current = el; }} > {' '}/ {prettifiedMaxVisits}{' '} tooltipRef.current) as any} placement="bottom"> This short URL will not accept more than {prettifiedMaxVisits} visits. ); }; export default ShortUrlVisitsCount;