umami/components/common/RefreshButton.js

20 lines
570 B
JavaScript
Raw Normal View History

import React from 'react';
2020-09-01 00:02:32 +02:00
import { useDispatch } from 'react-redux';
2020-08-31 23:11:30 +02:00
import { setDateRange } from 'redux/actions/websites';
import Button from './Button';
import Refresh from 'assets/redo.svg';
2020-09-01 00:02:32 +02:00
import { useDateRange } from 'hooks/useDateRange';
2020-08-31 23:11:30 +02:00
export default function RefreshButton({ websiteId }) {
const dispatch = useDispatch();
2020-09-01 00:02:32 +02:00
const dateRange = useDateRange(websiteId);
2020-08-31 23:11:30 +02:00
function handleClick() {
if (dateRange) {
2020-09-01 00:02:32 +02:00
dispatch(setDateRange(websiteId, dateRange));
2020-08-31 23:11:30 +02:00
}
}
return <Button icon={<Refresh />} size="small" onClick={handleClick} />;
}