Skip to content

Commit

Permalink
Merge pull request #1042 from syucream/feature/reloadable-errorpage
Browse files Browse the repository at this point in the history
Allow the error page to reload
  • Loading branch information
userlocalhost authored Jan 11, 2024
2 parents 2b06e56 + 8f4cd3d commit 90a9c26
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions frontend/src/ErrorHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,16 @@ interface GenericErrorProps {
}

const GenericError: FC<GenericErrorProps> = ({ children }) => {
const history = useHistory();
const [open, setOpen] = useState(true);

const handleClickGoToTop = () => {
location.href = topPath();
};
const handleGoToTop = useCallback(() => {
history.replace(topPath());
}, [history]);

const handleReload = useCallback(() => {
history.go(0);
}, [history]);

return (
<Dialog open={open} onClose={() => setOpen(false)}>
Expand All @@ -65,11 +70,20 @@ const GenericError: FC<GenericErrorProps> = ({ children }) => {
<Buttons>
<Button
variant="outlined"
color="secondary"
onClick={handleClickGoToTop}
color="primary"
onClick={handleGoToTop}
sx={{ mx: 1 }}
>
トップページに戻る
</Button>
<Button
variant="outlined"
color="secondary"
onClick={handleReload}
sx={{ mx: 1 }}
>
リロードする
</Button>
</Buttons>
</DialogContent>
</Dialog>
Expand Down

0 comments on commit 90a9c26

Please sign in to comment.