mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-22 18:00:17 +01:00
Merge branch 'master' into analytics
This commit is contained in:
commit
4bbfb05255
@ -12,11 +12,10 @@ import { startOfMonth, endOfMonth } from 'date-fns';
|
|||||||
import Icons from 'components/icons';
|
import Icons from 'components/icons';
|
||||||
import { useLocale } from 'components/hooks';
|
import { useLocale } from 'components/hooks';
|
||||||
import { formatDate } from 'lib/date';
|
import { formatDate } from 'lib/date';
|
||||||
import { getDateLocale } from 'lib/lang';
|
|
||||||
import styles from './MonthSelect.module.css';
|
import styles from './MonthSelect.module.css';
|
||||||
|
|
||||||
export function MonthSelect({ date = new Date(), onChange }) {
|
export function MonthSelect({ date = new Date(), onChange }) {
|
||||||
const { locale } = useLocale();
|
const { locale, dateLocale } = useLocale();
|
||||||
const month = formatDate(date, 'MMMM', locale);
|
const month = formatDate(date, 'MMMM', locale);
|
||||||
const year = date.getFullYear();
|
const year = date.getFullYear();
|
||||||
const ref = useRef();
|
const ref = useRef();
|
||||||
@ -40,7 +39,7 @@ export function MonthSelect({ date = new Date(), onChange }) {
|
|||||||
{close => (
|
{close => (
|
||||||
<CalendarMonthSelect
|
<CalendarMonthSelect
|
||||||
date={date}
|
date={date}
|
||||||
locale={getDateLocale(locale)}
|
locale={dateLocale}
|
||||||
onSelect={handleChange.bind(null, close)}
|
onSelect={handleChange.bind(null, close)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@ -57,7 +56,7 @@ export function MonthSelect({ date = new Date(), onChange }) {
|
|||||||
{close => (
|
{close => (
|
||||||
<CalendarYearSelect
|
<CalendarYearSelect
|
||||||
date={date}
|
date={date}
|
||||||
locale={getDateLocale(locale)}
|
locale={dateLocale}
|
||||||
onSelect={handleChange.bind(null, close)}
|
onSelect={handleChange.bind(null, close)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { Button, ButtonGroup, Calendar } from 'react-basics';
|
import { Button, ButtonGroup, Calendar } from 'react-basics';
|
||||||
import { isAfter, isBefore, isSameDay } from 'date-fns';
|
import { isAfter, isBefore, isSameDay, startOfDay, endOfDay } from 'date-fns';
|
||||||
import useLocale from 'components/hooks/useLocale';
|
import useLocale from 'components/hooks/useLocale';
|
||||||
import { getDateLocale } from 'lib/lang';
|
|
||||||
import { FILTER_DAY, FILTER_RANGE } from 'lib/constants';
|
import { FILTER_DAY, FILTER_RANGE } from 'lib/constants';
|
||||||
import useMessages from 'components/hooks/useMessages';
|
import useMessages from 'components/hooks/useMessages';
|
||||||
import styles from './DatePickerForm.module.css';
|
import styles from './DatePickerForm.module.css';
|
||||||
@ -21,7 +20,7 @@ export function DatePickerForm({
|
|||||||
const [singleDate, setSingleDate] = useState(defaultStartDate);
|
const [singleDate, setSingleDate] = useState(defaultStartDate);
|
||||||
const [startDate, setStartDate] = useState(defaultStartDate);
|
const [startDate, setStartDate] = useState(defaultStartDate);
|
||||||
const [endDate, setEndDate] = useState(defaultEndDate);
|
const [endDate, setEndDate] = useState(defaultEndDate);
|
||||||
const { locale } = useLocale();
|
const { dateLocale } = useLocale();
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
|
|
||||||
const disabled =
|
const disabled =
|
||||||
@ -31,9 +30,9 @@ export function DatePickerForm({
|
|||||||
|
|
||||||
const handleSave = () => {
|
const handleSave = () => {
|
||||||
if (selected === FILTER_DAY) {
|
if (selected === FILTER_DAY) {
|
||||||
onChange(`range:${singleDate.getTime()}:${singleDate.getTime()}`);
|
onChange(`range:${startOfDay(singleDate).getTime()}:${endOfDay(singleDate).getTime()}`);
|
||||||
} else {
|
} else {
|
||||||
onChange(`range:${startDate.getTime()}:${endDate.getTime()}`);
|
onChange(`range:${startOfDay(startDate).getTime()}:${endOfDay(endDate).getTime()}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -51,6 +50,7 @@ export function DatePickerForm({
|
|||||||
date={singleDate}
|
date={singleDate}
|
||||||
minDate={minDate}
|
minDate={minDate}
|
||||||
maxDate={maxDate}
|
maxDate={maxDate}
|
||||||
|
locale={dateLocale}
|
||||||
onChange={setSingleDate}
|
onChange={setSingleDate}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@ -60,14 +60,14 @@ export function DatePickerForm({
|
|||||||
date={startDate}
|
date={startDate}
|
||||||
minDate={minDate}
|
minDate={minDate}
|
||||||
maxDate={endDate}
|
maxDate={endDate}
|
||||||
locale={getDateLocale(locale)}
|
locale={dateLocale}
|
||||||
onChange={setStartDate}
|
onChange={setStartDate}
|
||||||
/>
|
/>
|
||||||
<Calendar
|
<Calendar
|
||||||
date={endDate}
|
date={endDate}
|
||||||
minDate={startDate}
|
minDate={startDate}
|
||||||
maxDate={maxDate}
|
maxDate={maxDate}
|
||||||
locale={getDateLocale(locale)}
|
locale={dateLocale}
|
||||||
onChange={setEndDate}
|
onChange={setEndDate}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
@ -78,7 +78,9 @@ export function parseDateRange(value, locale = 'en-US') {
|
|||||||
const endDate = new Date(+endTime);
|
const endDate = new Date(+endTime);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...getDateRangeValues(startDate, endDate),
|
startDate,
|
||||||
|
endDate,
|
||||||
|
unit: getMinimumUnit(startDate, endDate),
|
||||||
value,
|
value,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -255,14 +257,6 @@ export function getMinimumUnit(startDate, endDate) {
|
|||||||
return 'year';
|
return 'year';
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDateRangeValues(startDate, endDate) {
|
|
||||||
return {
|
|
||||||
startDate: startOfDay(startDate),
|
|
||||||
endDate: endOfDay(endDate),
|
|
||||||
unit: getMinimumUnit(startDate, endDate),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getDateFromString(str) {
|
export function getDateFromString(str) {
|
||||||
const [ymd, hms] = str.split(' ');
|
const [ymd, hms] = str.split(' ');
|
||||||
const [year, month, day] = ymd.split('-');
|
const [year, month, day] = ymd.split('-');
|
||||||
|
@ -187,7 +187,8 @@
|
|||||||
headers,
|
headers,
|
||||||
})
|
})
|
||||||
.then(res => res.text())
|
.then(res => res.text())
|
||||||
.then(text => (cache = text));
|
.then(text => (cache = text))
|
||||||
|
.catch(() => {}); // no-op, gulp error
|
||||||
};
|
};
|
||||||
|
|
||||||
const track = (obj, data) => {
|
const track = (obj, data) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user