2023-06-16 05:15:31 +02:00
|
|
|
import { LoadingButton, Icon, TooltipPopup } from 'react-basics';
|
2023-03-09 01:37:43 +01:00
|
|
|
import { setWebsiteDateRange } from 'store/websites';
|
2020-09-18 07:52:20 +02:00
|
|
|
import useDateRange from 'hooks/useDateRange';
|
2023-01-31 06:44:07 +01:00
|
|
|
import Icons from 'components/icons';
|
2023-03-22 22:05:55 +01:00
|
|
|
import useMessages from 'hooks/useMessages';
|
2020-08-31 12:53:39 +02:00
|
|
|
|
2023-04-21 17:00:42 +02:00
|
|
|
export function RefreshButton({ websiteId, isLoading }) {
|
2023-03-22 22:05:55 +01:00
|
|
|
const { formatMessage, labels } = useMessages();
|
2020-09-19 19:35:05 +02:00
|
|
|
const [dateRange] = useDateRange(websiteId);
|
2020-08-31 23:11:30 +02:00
|
|
|
|
|
|
|
function handleClick() {
|
2023-02-15 02:23:20 +01:00
|
|
|
if (!isLoading && dateRange) {
|
2023-07-26 22:42:55 +02:00
|
|
|
setWebsiteDateRange(websiteId, dateRange);
|
2020-08-31 23:11:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-16 05:34:30 +02:00
|
|
|
return (
|
2023-06-16 05:15:31 +02:00
|
|
|
<TooltipPopup label={formatMessage(labels.refresh)}>
|
2023-02-15 02:23:20 +01:00
|
|
|
<LoadingButton loading={isLoading} onClick={handleClick}>
|
2023-02-04 17:59:52 +01:00
|
|
|
<Icon>
|
|
|
|
<Icons.Refresh />
|
|
|
|
</Icon>
|
2023-02-15 02:23:20 +01:00
|
|
|
</LoadingButton>
|
2023-06-16 05:15:31 +02:00
|
|
|
</TooltipPopup>
|
2020-09-16 05:34:30 +02:00
|
|
|
);
|
2020-08-31 12:53:39 +02:00
|
|
|
}
|
2021-02-16 13:35:16 +01:00
|
|
|
|
|
|
|
export default RefreshButton;
|