2022-02-05 15:53:07 +03:00
|
|
|
import { boundToMercureHub } from '../mercure/helpers/boundToMercureHub';
|
|
|
|
import { ShlinkVisitsParams } from '../api/types';
|
|
|
|
import { Topics } from '../mercure/helpers/Topics';
|
2022-02-06 22:07:18 +03:00
|
|
|
import { useGoBack } from '../utils/helpers/hooks';
|
2022-03-13 20:56:42 +03:00
|
|
|
import { ReportExporter } from '../common/services/ReportExporter';
|
2022-02-05 15:53:07 +03:00
|
|
|
import VisitsStats from './VisitsStats';
|
|
|
|
import { NormalizedVisit, VisitsInfo, VisitsParams } from './types';
|
|
|
|
import { CommonVisitsProps } from './types/CommonVisitsProps';
|
|
|
|
import { toApiParams } from './types/helpers';
|
|
|
|
import { NonOrphanVisitsHeader } from './NonOrphanVisitsHeader';
|
|
|
|
|
2022-02-06 22:07:18 +03:00
|
|
|
export interface NonOrphanVisitsProps extends CommonVisitsProps {
|
2022-02-05 15:53:07 +03:00
|
|
|
getNonOrphanVisits: (params?: ShlinkVisitsParams, doIntervalFallback?: boolean) => void;
|
|
|
|
nonOrphanVisits: VisitsInfo;
|
|
|
|
cancelGetNonOrphanVisits: () => void;
|
|
|
|
}
|
|
|
|
|
2022-03-13 20:56:42 +03:00
|
|
|
export const NonOrphanVisits = ({ exportVisits }: ReportExporter) => boundToMercureHub(({
|
2022-02-05 15:53:07 +03:00
|
|
|
getNonOrphanVisits,
|
|
|
|
nonOrphanVisits,
|
|
|
|
cancelGetNonOrphanVisits,
|
|
|
|
settings,
|
|
|
|
selectedServer,
|
|
|
|
}: NonOrphanVisitsProps) => {
|
2022-02-06 22:07:18 +03:00
|
|
|
const goBack = useGoBack();
|
2022-02-05 15:53:07 +03:00
|
|
|
const exportCsv = (visits: NormalizedVisit[]) => exportVisits('non_orphan_visits.csv', visits);
|
|
|
|
const loadVisits = (params: VisitsParams, doIntervalFallback?: boolean) =>
|
|
|
|
getNonOrphanVisits(toApiParams(params), doIntervalFallback);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<VisitsStats
|
|
|
|
getVisits={loadVisits}
|
|
|
|
cancelGetVisits={cancelGetNonOrphanVisits}
|
|
|
|
visitsInfo={nonOrphanVisits}
|
|
|
|
settings={settings}
|
|
|
|
exportCsv={exportCsv}
|
|
|
|
selectedServer={selectedServer}
|
|
|
|
>
|
|
|
|
<NonOrphanVisitsHeader nonOrphanVisits={nonOrphanVisits} goBack={goBack} />
|
|
|
|
</VisitsStats>
|
|
|
|
);
|
|
|
|
}, () => [ Topics.visits ]);
|