shlink-web-client/src/visits/OrphanVisits.tsx

41 lines
1.4 KiB
TypeScript
Raw Normal View History

import { RouteComponentProps } from 'react-router';
import { boundToMercureHub } from '../mercure/helpers/boundToMercureHub';
import { ShlinkVisitsParams } from '../api/types';
import { Topics } from '../mercure/helpers/Topics';
2021-03-06 12:56:49 +03:00
import { Settings } from '../settings/reducers/settings';
import VisitsStats from './VisitsStats';
import { OrphanVisitsHeader } from './OrphanVisitsHeader';
2021-03-14 14:49:12 +03:00
import { NormalizedVisit, VisitsInfo } from './types';
import { VisitsExporter } from './services/VisitsExporter';
2021-02-28 12:36:56 +03:00
export interface OrphanVisitsProps extends RouteComponentProps {
getOrphanVisits: (params: ShlinkVisitsParams) => void;
2021-02-28 12:36:56 +03:00
orphanVisits: VisitsInfo;
cancelGetOrphanVisits: () => void;
2021-03-06 12:56:49 +03:00
settings: Settings;
}
2021-03-14 14:49:12 +03:00
export const OrphanVisits = ({ exportVisits }: VisitsExporter) => boundToMercureHub(({
history: { goBack },
match: { url },
getOrphanVisits,
orphanVisits,
cancelGetOrphanVisits,
2021-03-06 12:56:49 +03:00
settings,
2021-03-14 14:49:12 +03:00
}: OrphanVisitsProps) => {
const exportCsv = (visits: NormalizedVisit[]) => exportVisits('orphan_visits.csv', visits);
return (
<VisitsStats
getVisits={getOrphanVisits}
cancelGetVisits={cancelGetOrphanVisits}
visitsInfo={orphanVisits}
baseUrl={url}
settings={settings}
exportCsv={exportCsv}
>
<OrphanVisitsHeader orphanVisits={orphanVisits} goBack={goBack} />
</VisitsStats>
);
}, () => [ Topics.orphanVisits() ]);