import { useEffect } from 'react'; import { Card, CardText, CardTitle } from 'reactstrap'; 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'; interface OverviewConnectProps { shortUrlsList: ShortUrlsListState; listShortUrls: (params: ShortUrlsListParams) => void; listTags: Function; tagsList: TagsList; } export const Overview = ({ shortUrlsList, listShortUrls, listTags, tagsList }: OverviewConnectProps) => { const { loading, error, shortUrls } = shortUrlsList; const { loading: loadingTags } = tagsList; useEffect(() => { listShortUrls({ itemsPerPage: 5 }); 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)}
); };