mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-18 07:13:37 +01:00
Fix refresh button issue, closes #840
This commit is contained in:
parent
7b7557ec90
commit
504b5f10d9
@ -117,8 +117,6 @@ const DaySelector = ({ date, minDate, maxDate, locale, onSelect }) => {
|
||||
const month = date.getMonth();
|
||||
const year = date.getFullYear();
|
||||
|
||||
console.log({ dateLocale, startDay, startWeek, startMonth, month, year });
|
||||
|
||||
const daysOfWeek = [];
|
||||
for (let i = 0; i < 7; i++) {
|
||||
daysOfWeek.push(addDays(startWeek, i));
|
||||
|
@ -7,12 +7,9 @@ import Button from './Button';
|
||||
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`]);
|
||||
@ -20,7 +17,7 @@ function RefreshButton({ websiteId }) {
|
||||
function handleClick() {
|
||||
if (dateRange) {
|
||||
setLoading(true);
|
||||
dispatch(setDateRange(websiteId, getDateRange(dateRange.value, locale)));
|
||||
dispatch(setDateRange(websiteId, dateRange));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,11 @@ export function getDateRange(value, locale = 'en-US') {
|
||||
const now = new Date();
|
||||
const dateLocale = getDateLocale(locale);
|
||||
|
||||
const { num, unit } = value.match(/^(?<num>[0-9]+)(?<unit>hour|day|week|month|year)$/).groups;
|
||||
const match = value.match(/^(?<num>[0-9]+)(?<unit>hour|day|week|month|year)$/);
|
||||
|
||||
if (!match) return;
|
||||
|
||||
const { num, unit } = match.groups;
|
||||
|
||||
if (+num === 1) {
|
||||
switch (unit) {
|
||||
|
Loading…
Reference in New Issue
Block a user