Skip to content

Commit

Permalink
Show a toast when restarting the device
Browse files Browse the repository at this point in the history
  • Loading branch information
mairas committed Aug 13, 2024
1 parent 4bbe689 commit 818bb30
Show file tree
Hide file tree
Showing 2 changed files with 1,908 additions and 1,899 deletions.
11 changes: 10 additions & 1 deletion frontend/src/pages/System/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ function AuthCard(): JSX.Element {
*/
function RestartCard(): JSX.Element {
const [httpErrorText, setHttpErrorText] = useState("");
const [showRestartToast, setShowRestartToast] = useState(false);

const id = useId();

Expand All @@ -336,6 +337,7 @@ function RestartCard(): JSX.Element {
setTimeout(() => {
window.location.reload();
}, 5000);
setShowRestartToast(true);
} catch (e) {
setHttpErrorText(`Error restarting the device: ${e}`);
}
Expand All @@ -344,12 +346,19 @@ function RestartCard(): JSX.Element {
return (
<>
<ToastMessage
color="text-bg-warning"
color="text-bg-danger"
show={httpErrorText !== ""}
onHide={() => setHttpErrorText("")}
>
<p>Failed to restart: {httpErrorText}</p>
</ToastMessage>
<ToastMessage
color="text-bg-warning"
show={showRestartToast}
onHide={() => {setShowRestartToast(false)}}
>
<p>Restarting the device...</p>
</ToastMessage>
<ButtonCard
title="Restart the device"
buttonText="Restart"
Expand Down
Loading

0 comments on commit 818bb30

Please sign in to comment.