Skip to content

Commit

Permalink
feature(components): add locale for date ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
gnarlex committed Mar 10, 2021
1 parent a48c33f commit a1edcec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion components/common/RefreshButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ 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`]);

function handleClick() {
if (dateRange) {
setLoading(true);
dispatch(setDateRange(websiteId, getDateRange(dateRange.value)));
dispatch(setDateRange(websiteId, getDateRange(dateRange.value, locale)));
}
}

Expand Down
4 changes: 3 additions & 1 deletion components/settings/DateRangeSetting.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit a1edcec

Please sign in to comment.