Skip to content

Commit d08c6c2

Browse files
committed
Add reload button on page error
1 parent 4458d61 commit d08c6c2

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

src/App/PageError/index.tsx

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { useEffect } from 'react';
1+
import { useCallback, useEffect } from 'react';
22
import { useRouteError } from 'react-router-dom';
33

44
import useBooleanState from '#hooks/useBooleanState';
5-
import Button, { useButtonFeatures } from '#components/Button';
5+
import Button from '#components/Button';
6+
import Link from '#components/Link';
67

78
import styles from './styles.module.css';
89

@@ -24,9 +25,15 @@ function PageError() {
2425
toggle: toggleFullErrorVisibility,
2526
},
2627
] = useBooleanState(false);
27-
const {
28-
className: containerClassName,
29-
} = useButtonFeatures({});
28+
29+
const handleReloadButtonClick = useCallback(
30+
() => {
31+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
32+
// @ts-ignore
33+
window.location.reload(true);
34+
},
35+
[],
36+
);
3037

3138
return (
3239
<div className={styles.pageError}>
@@ -66,13 +73,21 @@ function PageError() {
6673
</div>
6774
<div className={styles.footer}>
6875
{/* NOTE: using the anchor element as it will refresh the page */}
69-
<a
70-
className={containerClassName}
76+
<Link
7177
href="/"
78+
external
79+
variant="secondary"
7280
>
7381
{/* FIXME: use translations */}
7482
Go back to homepage
75-
</a>
83+
</Link>
84+
<Button
85+
name={undefined}
86+
onClick={handleReloadButtonClick}
87+
>
88+
{/* FIXME: use translations */}
89+
Reload
90+
</Button>
7691
</div>
7792
</div>
7893
</div>

src/App/PageError/styles.module.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
display: flex;
4444
align-items: center;
4545
justify-content: flex-end;
46+
gap: var(--go-ui-spacing-md);
4647
}
4748
}
4849
}

0 commit comments

Comments
 (0)