Used visits count component in short URL visits view

This commit is contained in:
Alejandro Celaya
2020-01-11 20:10:12 +01:00
parent 3f2162fe62
commit 595858ac4b
3 changed files with 12 additions and 16 deletions

View File

@@ -134,7 +134,7 @@ const ShortUrlVisits = (
return (
<div className="shlink-container">
<VisitsHeader shortUrlDetail={shortUrlDetail} shortUrlVisits={shortUrlVisits} />
<VisitsHeader shortUrlDetail={shortUrlDetail} />
<section className="mt-4">
<div className="row">

View File

@@ -2,18 +2,16 @@ import { Card, UncontrolledTooltip } from 'reactstrap';
import Moment from 'react-moment';
import React from 'react';
import ExternalLink from '../utils/ExternalLink';
import './VisitsHeader.scss';
import ShortUrlVisitsCount from '../short-urls/helpers/ShortUrlVisitsCount';
import { shortUrlDetailType } from './reducers/shortUrlDetail';
import { shortUrlVisitsType } from './reducers/shortUrlVisits';
import './VisitsHeader.scss';
const propTypes = {
shortUrlDetail: shortUrlDetailType.isRequired,
shortUrlVisits: shortUrlVisitsType.isRequired,
};
export default function VisitsHeader({ shortUrlDetail, shortUrlVisits }) {
export default function VisitsHeader({ shortUrlDetail }) {
const { shortUrl, loading } = shortUrlDetail;
const { visits } = shortUrlVisits;
const shortLink = shortUrl && shortUrl.shortUrl ? shortUrl.shortUrl : '';
const longLink = shortUrl && shortUrl.longUrl ? shortUrl.longUrl : '';
@@ -30,14 +28,16 @@ export default function VisitsHeader({ shortUrlDetail, shortUrlVisits }) {
<header>
<Card className="bg-light" body>
<h2>
<span className="badge badge-main float-right">Visits: {visits.length}</span>
<span className="badge badge-main float-right">
Visits:{' '}
<ShortUrlVisitsCount shortUrl={shortUrl} />
</span>
Visit stats for <ExternalLink href={shortLink} />
</h2>
<hr />
<div>Created: {renderDate()}</div>
<div>
Long URL:
&nbsp;
Long URL:{' '}
{loading && <small>Loading...</small>}
{!loading && <ExternalLink href={longLink} />}
</div>