2023-07-16 09:47:10 +03:00
|
|
|
import type { ReportExporter } from '../../common/services/ReportExporter';
|
|
|
|
import { useGoBack } from '../../utils/helpers/hooks';
|
2023-07-23 11:14:58 +03:00
|
|
|
import { boundToMercureHub } from '../mercure/helpers/boundToMercureHub';
|
|
|
|
import { Topics } from '../mercure/helpers/Topics';
|
2023-02-18 13:11:01 +03:00
|
|
|
import type { LoadVisits, VisitsInfo } from './reducers/types';
|
2023-02-18 12:40:37 +03:00
|
|
|
import type { NormalizedVisit, VisitsParams } from './types';
|
|
|
|
import type { CommonVisitsProps } from './types/CommonVisitsProps';
|
2022-02-05 15:53:07 +03:00
|
|
|
import { toApiParams } from './types/helpers';
|
2022-05-28 12:16:59 +03:00
|
|
|
import { VisitsHeader } from './VisitsHeader';
|
2023-02-18 13:11:01 +03:00
|
|
|
import { VisitsStats } from './VisitsStats';
|
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]);
|