import { Card, UncontrolledTooltip } from 'reactstrap'; import Moment from 'react-moment'; import React from 'react'; import PropTypes from 'prop-types'; import ExternalLink from '../utils/ExternalLink'; import './VisitsHeader.scss'; import { shortUrlDetailType } from './reducers/shortUrlDetail'; import { shortUrlVisitsType } from './reducers/shortUrlVisits'; const propTypes = { shortUrlDetail: shortUrlDetailType.isRequired, shortUrlVisits: shortUrlVisitsType.isRequired, shortLink: PropTypes.string, }; export function VisitsHeader({ shortUrlDetail, shortUrlVisits, shortLink }) { const { shortUrl, loading } = shortUrlDetail; const { visits } = shortUrlVisits; const renderDate = () => ( {shortUrl.dateCreated} {shortUrl.dateCreated} ); return ( Visits: {visits.length} Visit stats for {shortLink} {shortUrl.dateCreated && ( Created: {renderDate()} )} Long URL: {loading && Loading...} {!loading && {shortUrl.longUrl}} ); } VisitsHeader.propTypes = propTypes;