2023-04-13 15:49:15 +03:00
|
|
|
import React, { useCallback } from 'react';
|
|
|
|
|
import { useDispatch } from 'react-redux';
|
|
|
|
|
import { makeStyles } from 'tss-react/mui';
|
2017-03-08 18:16:53 -06:00
|
|
|
|
2023-04-04 10:21:53 +03:00
|
|
|
import { reloadNow } from '../../../app/actions.web';
|
2023-04-13 15:49:15 +03:00
|
|
|
import Button from '../../../base/ui/components/web/Button';
|
2017-03-08 18:16:53 -06:00
|
|
|
|
|
|
|
|
/**
|
2018-10-29 22:02:23 -07:00
|
|
|
* The type of the React {@code Component} props of {@link ReloadButton}.
|
2017-03-08 18:16:53 -06:00
|
|
|
*/
|
2023-04-13 15:49:15 +03:00
|
|
|
interface IProps {
|
2017-03-08 18:16:53 -06:00
|
|
|
|
2018-10-29 22:02:23 -07:00
|
|
|
/**
|
|
|
|
|
* The translation key for the text in the button.
|
|
|
|
|
*/
|
2023-04-04 10:21:53 +03:00
|
|
|
textKey: string;
|
|
|
|
|
}
|
2017-03-08 18:16:53 -06:00
|
|
|
|
2023-04-13 15:49:15 +03:00
|
|
|
const useStyles = makeStyles()(theme => {
|
2017-05-31 00:31:00 -05:00
|
|
|
return {
|
2023-04-13 15:49:15 +03:00
|
|
|
button: {
|
|
|
|
|
margin: `${theme.spacing(2)} auto 0`
|
2017-05-31 00:31:00 -05:00
|
|
|
}
|
|
|
|
|
};
|
2023-04-13 15:49:15 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const ReloadButton = ({ textKey }: IProps) => {
|
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
|
const { classes } = useStyles();
|
|
|
|
|
|
|
|
|
|
const onClick = useCallback(() => {
|
|
|
|
|
dispatch(reloadNow());
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Button
|
|
|
|
|
className = { classes.button }
|
|
|
|
|
labelKey = { textKey }
|
|
|
|
|
onClick = { onClick } />
|
|
|
|
|
);
|
|
|
|
|
};
|
2017-03-08 18:16:53 -06:00
|
|
|
|
2023-04-13 15:49:15 +03:00
|
|
|
export default ReloadButton;
|