mirror of
https://github.com/umami-software/umami.git
synced 2026-02-13 17:15:37 +01:00
Fix date filter.
This commit is contained in:
parent
f62d23c9bc
commit
84236c0cd9
2 changed files with 23 additions and 13 deletions
|
|
@ -9,7 +9,8 @@ export function WebsiteDateFilter({ websiteId }) {
|
||||||
const [dateRange, setDateRange] = useDateRange(websiteId);
|
const [dateRange, setDateRange] = useDateRange(websiteId);
|
||||||
const { value, startDate, endDate, selectedUnit } = dateRange;
|
const { value, startDate, endDate, selectedUnit } = dateRange;
|
||||||
|
|
||||||
const isFutureDate = isAfter(incrementDateRange(dateRange, -1).startDate, new Date());
|
const isFutureDate =
|
||||||
|
value !== 'all' && isAfter(incrementDateRange(dateRange, -1).startDate, new Date());
|
||||||
|
|
||||||
const handleChange = async value => {
|
const handleChange = async value => {
|
||||||
setDateRange(value);
|
setDateRange(value);
|
||||||
|
|
@ -32,19 +33,21 @@ export function WebsiteDateFilter({ websiteId }) {
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
showAllTime={true}
|
showAllTime={true}
|
||||||
/>
|
/>
|
||||||
<Flexbox justifyContent="center" gap={10} className={styles.container}>
|
{value !== 'all' && (
|
||||||
<Button onClick={() => handleIncrement(1)}>
|
<Flexbox justifyContent="center" gap={10} className={styles.container}>
|
||||||
<Icon rotate={90}>
|
<Button onClick={() => handleIncrement(1)}>
|
||||||
<Icons.ChevronDown />
|
<Icon rotate={90}>
|
||||||
</Icon>
|
<Icons.ChevronDown />
|
||||||
</Button>
|
</Icon>
|
||||||
|
</Button>
|
||||||
|
|
||||||
<Button onClick={() => handleIncrement(-1)} disabled={isFutureDate}>
|
<Button onClick={() => handleIncrement(-1)} disabled={isFutureDate}>
|
||||||
<Icon rotate={270}>
|
<Icon rotate={270}>
|
||||||
<Icons.ChevronDown />
|
<Icons.ChevronDown />
|
||||||
</Icon>
|
</Icon>
|
||||||
</Button>
|
</Button>
|
||||||
</Flexbox>
|
</Flexbox>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -195,6 +195,13 @@ export function incrementDateRange(value, increment) {
|
||||||
const sub = num * increment;
|
const sub = num * increment;
|
||||||
|
|
||||||
switch (unit) {
|
switch (unit) {
|
||||||
|
case 'hour':
|
||||||
|
return {
|
||||||
|
...value,
|
||||||
|
startDate: subHours(startDate, sub),
|
||||||
|
endDate: subHours(endDate, sub),
|
||||||
|
value: 'range',
|
||||||
|
};
|
||||||
case 'day':
|
case 'day':
|
||||||
return {
|
return {
|
||||||
...value,
|
...value,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue