mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 09:30:31 +03:00
Merge pull request #777 from acelaya-forks/feature/fix-visits-filters
Fixed bots filter getting reset when changing date
This commit is contained in:
commit
51283cc130
2 changed files with 8 additions and 9 deletions
|
@ -87,13 +87,11 @@ export const VisitsStats: FC<VisitsStatsProps> = ({
|
||||||
() => processStatsFromVisits(normalizedVisits),
|
() => processStatsFromVisits(normalizedVisits),
|
||||||
[normalizedVisits],
|
[normalizedVisits],
|
||||||
);
|
);
|
||||||
const mapLocations = values(citiesForMap);
|
const resolvedFilter = useMemo(() => ({
|
||||||
const resolvedFilter = useMemo(() => (
|
|
||||||
!isFirstLoad.current ? visitsFilter : {
|
|
||||||
...visitsFilter,
|
...visitsFilter,
|
||||||
excludeBots: visitsFilter.excludeBots ?? settings.visits?.excludeBots,
|
excludeBots: visitsFilter.excludeBots ?? settings.visits?.excludeBots,
|
||||||
}
|
}), [visitsFilter]);
|
||||||
), [visitsFilter]);
|
const mapLocations = values(citiesForMap);
|
||||||
|
|
||||||
const setSelectedVisits = (selectedVisits: NormalizedVisit[]) => {
|
const setSelectedVisits = (selectedVisits: NormalizedVisit[]) => {
|
||||||
selectedBar = undefined;
|
selectedBar = undefined;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { DateRange, datesToDateRange } from '../../utils/helpers/dateIntervals';
|
||||||
import { OrphanVisitType, VisitsFilter } from '../types';
|
import { OrphanVisitType, VisitsFilter } from '../types';
|
||||||
import { parseQuery, stringifyQuery } from '../../utils/helpers/query';
|
import { parseQuery, stringifyQuery } from '../../utils/helpers/query';
|
||||||
import { formatIsoDate } from '../../utils/helpers/date';
|
import { formatIsoDate } from '../../utils/helpers/date';
|
||||||
import { BooleanString } from '../../utils/utils';
|
import { BooleanString, parseBooleanToString } from '../../utils/utils';
|
||||||
|
|
||||||
interface VisitsQuery {
|
interface VisitsQuery {
|
||||||
startDate?: string;
|
startDate?: string;
|
||||||
|
@ -47,11 +47,12 @@ export const useVisitsQuery = (): [VisitsFiltering, UpdateFiltering] => {
|
||||||
);
|
);
|
||||||
const updateFiltering = (extra: DeepPartial<VisitsFiltering>) => {
|
const updateFiltering = (extra: DeepPartial<VisitsFiltering>) => {
|
||||||
const { dateRange, visitsFilter } = mergeDeepRight(filtering, extra);
|
const { dateRange, visitsFilter } = mergeDeepRight(filtering, extra);
|
||||||
|
const { excludeBots, orphanVisitsType } = visitsFilter;
|
||||||
const query: VisitsQuery = {
|
const query: VisitsQuery = {
|
||||||
startDate: (dateRange?.startDate && formatIsoDate(dateRange.startDate)) || '',
|
startDate: (dateRange?.startDate && formatIsoDate(dateRange.startDate)) || '',
|
||||||
endDate: (dateRange?.endDate && formatIsoDate(dateRange.endDate)) || '',
|
endDate: (dateRange?.endDate && formatIsoDate(dateRange.endDate)) || '',
|
||||||
excludeBots: visitsFilter.excludeBots ? 'true' : 'false',
|
excludeBots: excludeBots === undefined ? undefined : parseBooleanToString(excludeBots),
|
||||||
orphanVisitsType: visitsFilter.orphanVisitsType,
|
orphanVisitsType,
|
||||||
domain: theDomain,
|
domain: theDomain,
|
||||||
};
|
};
|
||||||
const stringifiedQuery = stringifyQuery(query);
|
const stringifiedQuery = stringifyQuery(query);
|
||||||
|
|
Loading…
Reference in a new issue