2020-04-26 11:43:00 +03:00
|
|
|
import { faArrowLeft } from '@fortawesome/free-solid-svg-icons';
|
2023-02-18 13:11:01 +03:00
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
|
|
import type { FC, PropsWithChildren, ReactNode } from 'react';
|
|
|
|
import { Button, Card } from 'reactstrap';
|
2023-02-18 12:40:37 +03:00
|
|
|
import type { ShortUrl } from '../short-urls/data';
|
2023-02-18 13:11:01 +03:00
|
|
|
import { ShortUrlVisitsCount } from '../short-urls/helpers/ShortUrlVisitsCount';
|
2023-02-18 12:40:37 +03:00
|
|
|
import type { Visit } from './types';
|
2018-09-01 12:08:27 +03:00
|
|
|
|
2022-04-24 11:39:11 +03:00
|
|
|
type VisitsHeaderProps = PropsWithChildren<{
|
2020-09-04 20:33:16 +03:00
|
|
|
visits: Visit[];
|
|
|
|
goBack: () => void;
|
|
|
|
title: ReactNode;
|
|
|
|
shortUrl?: ShortUrl;
|
2022-04-24 11:39:11 +03:00
|
|
|
}>;
|
2018-09-01 12:08:27 +03:00
|
|
|
|
2022-05-28 12:16:59 +03:00
|
|
|
export 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">
|
2022-03-05 15:26:28 +03:00
|
|
|
<Button color="link" size="lg" className="p-0 me-3" onClick={goBack}>
|
2020-05-10 20:37:00 +03:00
|
|
|
<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>
|
2022-03-05 15:26:28 +03:00
|
|
|
<span className="badge badge-main ms-3">
|
2020-05-10 20:37:00 +03:00
|
|
|
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>
|
|
|
|
);
|