2022-02-05 15:53:07 +03:00
|
|
|
import { boundToMercureHub } from '../mercure/helpers/boundToMercureHub';
|
|
|
|
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-05-28 11:34:12 +03:00
|
|
|
import { VisitsStats } from './VisitsStats';
|
2022-11-12 11:18:37 +03:00
|
|
|
import { NormalizedVisit, VisitsParams } from './types';
|
2022-02-05 15:53:07 +03:00
|
|
|
import { CommonVisitsProps } from './types/CommonVisitsProps';
|
|
|
|
import { toApiParams } from './types/helpers';
|
2022-05-28 12:16:59 +03:00
|
|
|
import { VisitsHeader } from './VisitsHeader';
|
2022-11-12 11:21:23 +03:00
|
|
|
import { LoadVisits, VisitsInfo } from './reducers/types';
|
2022-02-05 15:53:07 +03:00
|
|
|
|
2022-02-06 22:07:18 +03:00
|
|
|
export interface NonOrphanVisitsProps extends CommonVisitsProps {
|
2022-11-12 11:21:23 +03:00
|
|
|
getNonOrphanVisits: (params: LoadVisits) => void;
|
2022-02-05 15:53:07 +03:00
|
|
|
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,
|
|
|
|
}: 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) =>
|
2022-11-12 11:21:23 +03:00
|
|
|
getNonOrphanVisits({ query: toApiParams(params), doIntervalFallback });
|
2022-02-05 15:53:07 +03:00
|
|
|
|
|
|
|
return (
|
|
|
|
<VisitsStats
|
|
|
|
getVisits={loadVisits}
|
|
|
|
cancelGetVisits={cancelGetNonOrphanVisits}
|
|
|
|
visitsInfo={nonOrphanVisits}
|
|
|
|
settings={settings}
|
|
|
|
exportCsv={exportCsv}
|
|
|
|
>
|
2022-04-30 12:00:12 +03:00
|
|
|
<VisitsHeader title="Non-orphan visits" goBack={goBack} visits={nonOrphanVisits.visits} />
|
2022-02-05 15:53:07 +03:00
|
|
|
</VisitsStats>
|
|
|
|
);
|
2022-03-26 14:17:42 +03:00
|
|
|
}, () => [Topics.visits]);
|