mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-18 15:23:38 +01:00
feature(components): add locale for date ranges
This commit is contained in:
parent
a48c33fcd6
commit
a1edcecde7
@ -8,9 +8,11 @@ import Refresh from 'assets/redo.svg';
|
|||||||
import Dots from 'assets/ellipsis-h.svg';
|
import Dots from 'assets/ellipsis-h.svg';
|
||||||
import useDateRange from 'hooks/useDateRange';
|
import useDateRange from 'hooks/useDateRange';
|
||||||
import { getDateRange } from '../../lib/date';
|
import { getDateRange } from '../../lib/date';
|
||||||
|
import useLocale from 'hooks/useLocale';
|
||||||
|
|
||||||
function RefreshButton({ websiteId }) {
|
function RefreshButton({ websiteId }) {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
const [locale] = useLocale();
|
||||||
const [dateRange] = useDateRange(websiteId);
|
const [dateRange] = useDateRange(websiteId);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const completed = useSelector(state => state.queries[`/api/website/${websiteId}/stats`]);
|
const completed = useSelector(state => state.queries[`/api/website/${websiteId}/stats`]);
|
||||||
@ -18,7 +20,7 @@ function RefreshButton({ websiteId }) {
|
|||||||
function handleClick() {
|
function handleClick() {
|
||||||
if (dateRange) {
|
if (dateRange) {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
dispatch(setDateRange(websiteId, getDateRange(dateRange.value)));
|
dispatch(setDateRange(websiteId, getDateRange(dateRange.value, locale)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,13 +6,15 @@ import useDateRange from 'hooks/useDateRange';
|
|||||||
import { DEFAULT_DATE_RANGE } from 'lib/constants';
|
import { DEFAULT_DATE_RANGE } from 'lib/constants';
|
||||||
import { getDateRange } from 'lib/date';
|
import { getDateRange } from 'lib/date';
|
||||||
import styles from './DateRangeSetting.module.css';
|
import styles from './DateRangeSetting.module.css';
|
||||||
|
import useLocale from 'hooks/useLocale';
|
||||||
|
|
||||||
export default function DateRangeSetting() {
|
export default function DateRangeSetting() {
|
||||||
|
const [locale] = useLocale();
|
||||||
const [dateRange, setDateRange] = useDateRange();
|
const [dateRange, setDateRange] = useDateRange();
|
||||||
const { startDate, endDate, value } = dateRange;
|
const { startDate, endDate, value } = dateRange;
|
||||||
|
|
||||||
function handleReset() {
|
function handleReset() {
|
||||||
setDateRange(getDateRange(DEFAULT_DATE_RANGE));
|
setDateRange(getDateRange(DEFAULT_DATE_RANGE, locale));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user