mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-30 07:48:11 +01:00
29 lines
802 B
JavaScript
29 lines
802 B
JavaScript
import { LoadingButton, Icon, TooltipPopup } from 'react-basics';
|
|
import { setWebsiteDateRange } from 'store/websites';
|
|
import useDateRange from 'hooks/useDateRange';
|
|
import Icons from 'components/icons';
|
|
import useMessages from 'hooks/useMessages';
|
|
|
|
export function RefreshButton({ websiteId, isLoading }) {
|
|
const { formatMessage, labels } = useMessages();
|
|
const [dateRange] = useDateRange(websiteId);
|
|
|
|
function handleClick() {
|
|
if (!isLoading && dateRange) {
|
|
setWebsiteDateRange(websiteId, dateRange);
|
|
}
|
|
}
|
|
|
|
return (
|
|
<TooltipPopup label={formatMessage(labels.refresh)}>
|
|
<LoadingButton loading={isLoading} onClick={handleClick}>
|
|
<Icon>
|
|
<Icons.Refresh />
|
|
</Icon>
|
|
</LoadingButton>
|
|
</TooltipPopup>
|
|
);
|
|
}
|
|
|
|
export default RefreshButton;
|