2020-05-10 20:37:00 +03:00
|
|
|
import { Button, Card } from 'reactstrap';
|
2018-09-01 12:08:27 +03:00
|
|
|
import React from 'react';
|
2020-04-26 11:43:00 +03:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
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-05-10 20:37:00 +03:00
|
|
|
import { shortUrlType } from '../short-urls/reducers/shortUrlsList';
|
|
|
|
import { VisitType } from './types';
|
2018-09-01 12:08:27 +03:00
|
|
|
|
|
|
|
const propTypes = {
|
2020-05-10 20:37:00 +03:00
|
|
|
visits: PropTypes.arrayOf(VisitType).isRequired,
|
2020-04-26 11:43:00 +03:00
|
|
|
goBack: PropTypes.func.isRequired,
|
2020-05-10 20:37:00 +03:00
|
|
|
title: PropTypes.node.isRequired,
|
|
|
|
children: PropTypes.node,
|
|
|
|
shortUrl: shortUrlType,
|
2018-09-01 12:08:27 +03:00
|
|
|
};
|
|
|
|
|
2020-05-10 20:37:00 +03:00
|
|
|
const VisitsHeader = ({ visits, goBack, shortUrl, children, title }) => (
|
|
|
|
<header>
|
|
|
|
<Card className="bg-light" 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 20:49:58 +03:00
|
|
|
<h3 className="text-center d-block d-sm-none mb-0 mt-2">
|
|
|
|
<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
|
|
|
|
|
|
|
VisitsHeader.propTypes = propTypes;
|
2020-05-10 20:37:00 +03:00
|
|
|
|
|
|
|
export default VisitsHeader;
|