Fixed tags filtering from overview page

This commit is contained in:
Alejandro Celaya 2020-12-19 22:49:11 +01:00
parent 79f7459d77
commit 7da634e772
3 changed files with 10 additions and 4 deletions

View file

@ -1,6 +1,6 @@
import { FC, useEffect } from 'react'; import { FC, useEffect } from 'react';
import { Card, CardBody, CardHeader, CardText, CardTitle } from 'reactstrap'; import { Card, CardBody, CardHeader, CardText, CardTitle } from 'reactstrap';
import { Link } from 'react-router-dom'; import { Link, useHistory } from 'react-router-dom';
import { ShortUrlsListParams } from '../short-urls/reducers/shortUrlsListParams'; import { ShortUrlsListParams } from '../short-urls/reducers/shortUrlsListParams';
import { ShortUrlsList as ShortUrlsListState } from '../short-urls/reducers/shortUrlsList'; import { ShortUrlsList as ShortUrlsListState } from '../short-urls/reducers/shortUrlsList';
import { prettify } from '../utils/helpers/numbers'; import { prettify } from '../utils/helpers/numbers';
@ -40,6 +40,7 @@ export const Overview = (
const { loading: loadingTags } = tagsList; const { loading: loadingTags } = tagsList;
const { loading: loadingVisits, visitsCount } = visitsOverview; const { loading: loadingVisits, visitsCount } = visitsOverview;
const serverId = isServerWithId(selectedServer) ? selectedServer.id : ''; const serverId = isServerWithId(selectedServer) ? selectedServer.id : '';
const history = useHistory();
useEffect(() => { useEffect(() => {
listShortUrls({ itemsPerPage: 5, orderBy: { dateCreated: 'DESC' } }); listShortUrls({ itemsPerPage: 5, orderBy: { dateCreated: 'DESC' } });
@ -95,7 +96,12 @@ export const Overview = (
<Link className="float-right" to={`/server/${serverId}/list-short-urls/1`}>See all &raquo;</Link> <Link className="float-right" to={`/server/${serverId}/list-short-urls/1`}>See all &raquo;</Link>
</CardHeader> </CardHeader>
<CardBody> <CardBody>
<ShortUrlsTable shortUrlsList={shortUrlsList} selectedServer={selectedServer} className="mb-0" /> <ShortUrlsTable
shortUrlsList={shortUrlsList}
selectedServer={selectedServer}
className="mb-0"
refreshList={({ tags }) => tags?.[0] && history.push(`/server/${serverId}/list-short-urls/1?tag=${tags[0]}`)}
/>
</CardBody> </CardBody>
</Card> </Card>
</> </>

View file

@ -12,7 +12,7 @@ export interface ShortUrlsTableProps {
renderOrderIcon?: (column: OrderableFields) => ReactNode; renderOrderIcon?: (column: OrderableFields) => ReactNode;
shortUrlsList: ShortUrlsListState; shortUrlsList: ShortUrlsListState;
selectedServer: SelectedServer; selectedServer: SelectedServer;
refreshList?: Function; refreshList?: (params: ShortUrlsListParams) => void;
shortUrlsListParams?: ShortUrlsListParams; shortUrlsListParams?: ShortUrlsListParams;
className?: string; className?: string;
} }

View file

@ -16,7 +16,7 @@ import { ShortUrlsRowMenuProps } from './ShortUrlsRowMenu';
import './ShortUrlsRow.scss'; import './ShortUrlsRow.scss';
export interface ShortUrlsRowProps { export interface ShortUrlsRowProps {
refreshList?: Function; refreshList?: (params: ShortUrlsListParams) => void;
shortUrlsListParams?: ShortUrlsListParams; shortUrlsListParams?: ShortUrlsListParams;
selectedServer: SelectedServer; selectedServer: SelectedServer;
shortUrl: ShortUrl; shortUrl: ShortUrl;