2020-05-10 20:37:00 +03:00
|
|
|
import { Button, Card } from 'reactstrap';
|
2020-11-14 00:44:26 +03:00
|
|
|
import { FC, ReactNode } from 'react';
|
2020-04-26 11:43:00 +03:00
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
|
|
import { faArrowLeft } from '@fortawesome/free-solid-svg-icons';
|
2020-01-11 22:10:12 +03:00
|
|
|
import ShortUrlVisitsCount from '../short-urls/helpers/ShortUrlVisitsCount';
|
2020-09-04 20:33:16 +03:00
|
|
|
import { ShortUrl } from '../short-urls/data';
|
|
|
|
import { Visit } from './types';
|
2018-09-01 12:08:27 +03:00
|
|
|
|
2020-09-04 20:33:16 +03:00
|
|
|
interface VisitsHeaderProps {
|
|
|
|
visits: Visit[];
|
|
|
|
goBack: () => void;
|
|
|
|
title: ReactNode;
|
|
|
|
shortUrl?: ShortUrl;
|
|
|
|
}
|
2018-09-01 12:08:27 +03:00
|
|
|
|
2020-09-04 20:33:16 +03:00
|
|
|
const VisitsHeader: FC<VisitsHeaderProps> = ({ visits, goBack, shortUrl, children, title }) => (
|
2020-05-10 20:37:00 +03:00
|
|
|
<header>
|
2020-12-12 12:56:10 +03:00
|
|
|
<Card body>
|
2020-05-10 20:49:58 +03:00
|
|
|
<h2 className="d-flex justify-content-between align-items-center mb-0">
|
2020-05-10 20:37:00 +03:00
|
|
|
<Button color="link" size="lg" className="p-0 mr-3" onClick={goBack}>
|
|
|
|
<FontAwesomeIcon icon={faArrowLeft} />
|
|
|
|
</Button>
|
|
|
|
<span className="text-center d-none d-sm-block">
|
2020-05-10 20:49:58 +03:00
|
|
|
<small>{title}</small>
|
2020-05-10 20:37:00 +03:00
|
|
|
</span>
|
|
|
|
<span className="badge badge-main ml-3">
|
|
|
|
Visits:{' '}
|
|
|
|
<ShortUrlVisitsCount visitsCount={visits.length} shortUrl={shortUrl} />
|
|
|
|
</span>
|
|
|
|
</h2>
|
2020-05-10 21:17:17 +03:00
|
|
|
<h3 className="text-center d-block d-sm-none mb-0 mt-3">
|
2020-05-10 20:49:58 +03:00
|
|
|
<small>{title}</small>
|
|
|
|
</h3>
|
|
|
|
|
|
|
|
{children && <div className="mt-md-2">{children}</div>}
|
2020-05-10 20:37:00 +03:00
|
|
|
</Card>
|
|
|
|
</header>
|
|
|
|
);
|
2018-09-01 12:08:27 +03:00
|
|
|
|
2020-05-10 20:37:00 +03:00
|
|
|
export default VisitsHeader;
|