From b2b6b3af18d63f6254fdbf0388a1afaae908cd1a Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 17 Dec 2022 09:28:42 +0100 Subject: [PATCH] Fixed visits query being lost when switching between sub-sections --- src/visits/ShortUrlVisits.tsx | 1 - src/visits/VisitsStats.tsx | 10 +++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/visits/ShortUrlVisits.tsx b/src/visits/ShortUrlVisits.tsx index 3e17ae46..0d94f87a 100644 --- a/src/visits/ShortUrlVisits.tsx +++ b/src/visits/ShortUrlVisits.tsx @@ -55,7 +55,6 @@ export const ShortUrlVisits = ({ exportVisits }: ReportExporter) => boundToMercu getVisits={loadVisits} cancelGetVisits={cancelGetShortUrlVisits} visitsInfo={shortUrlVisits} - domain={domain} settings={settings} exportCsv={exportCsv} selectedServer={selectedServer} diff --git a/src/visits/VisitsStats.tsx b/src/visits/VisitsStats.tsx index ff3e74c2..639d8858 100644 --- a/src/visits/VisitsStats.tsx +++ b/src/visits/VisitsStats.tsx @@ -4,7 +4,7 @@ import { Button, Progress, Row } from 'reactstrap'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faCalendarAlt, faMapMarkedAlt, faList, faChartPie } from '@fortawesome/free-solid-svg-icons'; import { IconDefinition } from '@fortawesome/fontawesome-common-types'; -import { Route, Routes, Navigate } from 'react-router-dom'; +import { Route, Routes, Navigate, useLocation } from 'react-router-dom'; import classNames from 'classnames'; import { DateRangeSelector } from '../utils/dates/DateRangeSelector'; import { Message } from '../utils/Message'; @@ -35,7 +35,6 @@ export type VisitsStatsProps = PropsWithChildren<{ settings: Settings; selectedServer: SelectedServer; cancelGetVisits: () => void; - domain?: string; exportCsv: (visits: NormalizedVisit[]) => void; isOrphanVisits?: boolean; }>; @@ -62,7 +61,6 @@ export const VisitsStats: FC = ({ visitsInfo, getVisits, cancelGetVisits, - domain, settings, exportCsv, selectedServer, @@ -86,11 +84,9 @@ export const VisitsStats: FC = ({ const [highlightedLabel, setHighlightedLabel] = useState(); const botsSupported = supportsBotVisits(selectedServer); const isFirstLoad = useRef(true); + const { search } = useLocation(); - const buildSectionUrl = (subPath?: string) => { - const query = domain ? `?domain=${domain}` : ''; - return !subPath ? `${query}` : `${subPath}${query}`; - }; + const buildSectionUrl = (subPath?: string) => (!subPath ? search : `${subPath}${search}`); const normalizedVisits = useMemo(() => normalizeVisits(visits), [visits]); const { os, browsers, referrers, countries, cities, citiesForMap, visitedUrls } = useMemo( () => processStatsFromVisits(normalizedVisits),