mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 12:47:13 +01:00
Move date range selection into redux.
This commit is contained in:
parent
d06c077019
commit
c5cb19a3bf
21 changed files with 141 additions and 138 deletions
|
|
@ -1,7 +1,18 @@
|
|||
import React from 'react';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { setDateRange } from 'redux/actions/websites';
|
||||
import Button from './Button';
|
||||
import Refresh from 'assets/redo.svg';
|
||||
|
||||
export default function RefreshButton({ onClick }) {
|
||||
return <Button icon={<Refresh />} size="small" onClick={onClick} />;
|
||||
export default function RefreshButton({ websiteId }) {
|
||||
const dispatch = useDispatch();
|
||||
const dateRange = useSelector(state => state.websites[websiteId]?.dateRange);
|
||||
|
||||
function handleClick() {
|
||||
if (dateRange) {
|
||||
dispatch(setDateRange(websiteId, { ...dateRange }));
|
||||
}
|
||||
}
|
||||
|
||||
return <Button icon={<Refresh />} size="small" onClick={handleClick} />;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue