2021-02-27 22:03:51 +03:00
|
|
|
import { boundToMercureHub } from '../mercure/helpers/boundToMercureHub';
|
2021-02-28 12:12:30 +03:00
|
|
|
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:32:52 +03:00
|
|
|
import { NormalizedVisit, VisitsParams } from './types';
|
2021-06-13 12:07:32 +03:00
|
|
|
import { CommonVisitsProps } from './types/CommonVisitsProps';
|
2021-06-30 04:23:45 +03:00
|
|
|
import { toApiParams } from './types/helpers';
|
2022-05-28 12:16:59 +03:00
|
|
|
import { VisitsHeader } from './VisitsHeader';
|
2022-11-12 11:18:37 +03:00
|
|
|
import { VisitsInfo } from './reducers/types';
|
2022-11-12 11:32:52 +03:00
|
|
|
import { LoadOrphanVisits } from './reducers/orphanVisits';
|
2021-02-27 22:03:51 +03:00
|
|
|
|
2022-02-06 22:07:18 +03:00
|
|
|
export interface OrphanVisitsProps extends CommonVisitsProps {
|
2022-11-12 11:32:52 +03:00
|
|
|
getOrphanVisits: (params: LoadOrphanVisits) => void;
|
2021-02-28 12:36:56 +03:00
|
|
|
orphanVisits: VisitsInfo;
|
2021-02-27 22:03:51 +03:00
|
|
|
cancelGetOrphanVisits: () => void;
|
|
|
|
}
|
|
|
|
|
2022-03-13 20:56:42 +03:00
|
|
|
export const OrphanVisits = ({ exportVisits }: ReportExporter) => boundToMercureHub(({
|
2021-02-27 22:03:51 +03:00
|
|
|
getOrphanVisits,
|
|
|
|
orphanVisits,
|
|
|
|
cancelGetOrphanVisits,
|
2021-03-06 12:56:49 +03:00
|
|
|
settings,
|
2021-03-14 14:49:12 +03:00
|
|
|
}: OrphanVisitsProps) => {
|
2022-02-06 22:07:18 +03:00
|
|
|
const goBack = useGoBack();
|
2021-03-14 14:49:12 +03:00
|
|
|
const exportCsv = (visits: NormalizedVisit[]) => exportVisits('orphan_visits.csv', visits);
|
2022-11-12 11:32:52 +03:00
|
|
|
const loadVisits = (params: VisitsParams, doIntervalFallback?: boolean) => getOrphanVisits(
|
|
|
|
{ query: toApiParams(params), orphanVisitsType: params.filter?.orphanVisitsType, doIntervalFallback },
|
|
|
|
);
|
2021-03-14 14:49:12 +03:00
|
|
|
|
|
|
|
return (
|
|
|
|
<VisitsStats
|
2021-06-30 04:23:45 +03:00
|
|
|
getVisits={loadVisits}
|
2021-03-14 14:49:12 +03:00
|
|
|
cancelGetVisits={cancelGetOrphanVisits}
|
|
|
|
visitsInfo={orphanVisits}
|
|
|
|
settings={settings}
|
|
|
|
exportCsv={exportCsv}
|
2021-03-28 16:57:22 +03:00
|
|
|
isOrphanVisits
|
2021-03-14 14:49:12 +03:00
|
|
|
>
|
2022-04-30 12:00:12 +03:00
|
|
|
<VisitsHeader title="Orphan visits" goBack={goBack} visits={orphanVisits.visits} />
|
2021-03-14 14:49:12 +03:00
|
|
|
</VisitsStats>
|
|
|
|
);
|
2022-03-26 14:17:42 +03:00
|
|
|
}, () => [Topics.orphanVisits]);
|