feature(components): add locale for date ranges

This commit is contained in:
Alexander Klein 2021-03-10 10:38:35 +01:00
parent a48c33fcd6
commit a1edcecde7
2 changed files with 6 additions and 2 deletions

View File

@ -8,9 +8,11 @@ import Refresh from 'assets/redo.svg';
import Dots from 'assets/ellipsis-h.svg';
import useDateRange from 'hooks/useDateRange';
import { getDateRange } from '../../lib/date';
import useLocale from 'hooks/useLocale';
function RefreshButton({ websiteId }) {
const dispatch = useDispatch();
const [locale] = useLocale();
const [dateRange] = useDateRange(websiteId);
const [loading, setLoading] = useState(false);
const completed = useSelector(state => state.queries[`/api/website/${websiteId}/stats`]);
@ -18,7 +20,7 @@ function RefreshButton({ websiteId }) {
function handleClick() {
if (dateRange) {
setLoading(true);
dispatch(setDateRange(websiteId, getDateRange(dateRange.value)));
dispatch(setDateRange(websiteId, getDateRange(dateRange.value, locale)));
}
}

View File

@ -6,13 +6,15 @@ import useDateRange from 'hooks/useDateRange';
import { DEFAULT_DATE_RANGE } from 'lib/constants';
import { getDateRange } from 'lib/date';
import styles from './DateRangeSetting.module.css';
import useLocale from 'hooks/useLocale';
export default function DateRangeSetting() {
const [locale] = useLocale();
const [dateRange, setDateRange] = useDateRange();
const { startDate, endDate, value } = dateRange;
function handleReset() {
setDateRange(getDateRange(DEFAULT_DATE_RANGE));
setDateRange(getDateRange(DEFAULT_DATE_RANGE, locale));
}
return (