import { FC, useEffect } from 'react'; import { Card, CardBody, CardHeader, CardText, CardTitle } from 'reactstrap'; import { Link } from 'react-router-dom'; import { ShortUrlsListParams } from '../short-urls/reducers/shortUrlsListParams'; import { ShortUrlsList as ShortUrlsListState } from '../short-urls/reducers/shortUrlsList'; import { prettify } from '../utils/helpers/numbers'; import { TagsList } from '../tags/reducers/tagsList'; import { ShortUrlsTableProps } from '../short-urls/ShortUrlsTable'; import { boundToMercureHub } from '../mercure/helpers/boundToMercureHub'; import { isServerWithId, SelectedServer } from './data'; import './Overview.scss'; interface OverviewConnectProps { shortUrlsList: ShortUrlsListState; listShortUrls: (params: ShortUrlsListParams) => void; listTags: Function; tagsList: TagsList; selectedServer: SelectedServer; } export const Overview = (ShortUrlsTable: FC) => boundToMercureHub(( { shortUrlsList, listShortUrls, listTags, tagsList, selectedServer }: OverviewConnectProps, ) => { const { loading, error, shortUrls } = shortUrlsList; const { loading: loadingTags } = tagsList; const serverId = !isServerWithId(selectedServer) ? '' : selectedServer.id; useEffect(() => { listShortUrls({ itemsPerPage: 5, orderBy: { dateCreated: 'DESC' } }); listTags(); }, []); return ( <>
Visits ?
Short URLs {loading && !error && 'Loading...'} {error && !loading && 'Failed :('} {!error && !loading && prettify(shortUrls?.pagination.totalItems ?? 0)}
Tags {loadingTags ? 'Loading... ' : prettify(tagsList.tags.length)}
Create short URL More options » Create Recently created URLs See all » ); }, () => 'https://shlink.io/new-visit');