diff --git a/components/common/DateFilter.js b/components/common/DateFilter.js index e2fd00bd..8e50e95a 100644 --- a/components/common/DateFilter.js +++ b/components/common/DateFilter.js @@ -10,7 +10,7 @@ import { dateFormat } from 'lib/date'; import Calendar from 'assets/calendar-alt.svg'; import Icon from './Icon'; -const filterOptions = [ +export const filterOptions = [ { label: , value: '1day' }, { label: ( @@ -59,7 +59,7 @@ const filterOptions = [ }, ]; -function DateFilter({ value, startDate, endDate, onChange, className }) { +function DateFilter({ value, startDate, endDate, onChange, className, options }) { const [showPicker, setShowPicker] = useState(false); const displayValue = value === 'custom' ? ( @@ -86,7 +86,7 @@ function DateFilter({ value, startDate, endDate, onChange, className }) { {showPicker && ( diff --git a/components/metrics/WebsiteChart.js b/components/metrics/WebsiteChart.js index 63eb3e04..62a38694 100644 --- a/components/metrics/WebsiteChart.js +++ b/components/metrics/WebsiteChart.js @@ -65,7 +65,7 @@ export default function WebsiteChart({ }; } return { pageviews: [], sessions: [] }; - }, [data]); + }, [data, startDate, endDate, unit]); function handleCloseFilter(param) { router.push(resolve({ [param]: undefined })); @@ -77,8 +77,10 @@ export default function WebsiteChart({ if (ok) { setDateRange({ value, ...getDateRangeValues(new Date(data.created_at), Date.now()) }); } - } else { + } else if (typeof value === 'string') { setDateRange(getDateRange(value, locale)); + } else { + setDateRange(value); } } diff --git a/components/settings/DateRangeSetting.js b/components/settings/DateRangeSetting.js index 87cd3545..53dfe983 100644 --- a/components/settings/DateRangeSetting.js +++ b/components/settings/DateRangeSetting.js @@ -1,6 +1,6 @@ import React from 'react'; import { FormattedMessage } from 'react-intl'; -import DateFilter from 'components/common/DateFilter'; +import DateFilter, { filterOptions } from 'components/common/DateFilter'; import Button from 'components/common/Button'; import useDateRange from 'hooks/useDateRange'; import { DEFAULT_DATE_RANGE } from 'lib/constants'; @@ -12,6 +12,7 @@ export default function DateRangeSetting() { const { locale } = useLocale(); const [dateRange, setDateRange] = useDateRange(); const { startDate, endDate, value } = dateRange; + const options = filterOptions.filter(e => e.value !== 'all'); function handleReset() { setDateRange(getDateRange(DEFAULT_DATE_RANGE, locale)); @@ -19,7 +20,13 @@ export default function DateRangeSetting() { return ( <> - + diff --git a/package.json b/package.json index 5a0ab8a5..b8afc97f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "umami", "version": "1.25.0", - "description": "A simple, fast, website analytics alternative to Google Analytics. ", + "description": "A simple, fast, website analytics alternative to Google Analytics.", "author": "Mike Cao ", "license": "MIT", "homepage": "https://umami.is",