import { faInfoCircle as infoIcon } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import classNames from 'classnames'; import { UncontrolledTooltip } from 'reactstrap'; import { formatHumanFriendly, parseISO } from '../../utils/dates/helpers/date'; import { useElementRef } from '../../utils/helpers/hooks'; import { prettify } from '../../utils/helpers/numbers'; import type { ShortUrl } from '../data'; import { ShortUrlDetailLink } from './ShortUrlDetailLink'; import './ShortUrlVisitsCount.scss'; interface ShortUrlVisitsCountProps { shortUrl?: ShortUrl | null; visitsCount: number; active?: boolean; asLink?: boolean; } export const ShortUrlVisitsCount = ( { visitsCount, shortUrl, active = false, asLink = false }: ShortUrlVisitsCountProps, ) => { const { maxVisits, validSince, validUntil } = shortUrl?.meta ?? {}; const hasLimit = !!maxVisits || !!validSince || !!validUntil; const visitsLink = ( {prettify(visitsCount)} ); if (!hasLimit) { return visitsLink; } const tooltipRef = useElementRef(); return ( <> {visitsLink} {maxVisits && <> / {prettify(maxVisits)}} ); };