Skip to content

Commit

Permalink
Handle dashboard loading error (#697)
Browse files Browse the repository at this point in the history
We weren't handling an error loading the dashboard. Show an unhandled error if the dashboard fails to load.
  • Loading branch information
DeeTheDev authored Sep 4, 2024
1 parent 730b05e commit 834ba61
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions webapp/src/pages/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,22 @@ import Stack from "react-bootstrap/Stack";
import { Link } from "react-router-dom";

export default function Dashboard() {
const { state: dashboard, loading: dashboardLoading } = useAsyncFetch(api.dashboard, {
const {
state: dashboard,
loading: dashboardLoading,
error: dashboardError,
} = useAsyncFetch(api.dashboard, {
default: {},
pickData: true,
});
if (dashboardError) {
return (
<LayoutContainer top>
<h2>{t("errors:something_went_wrong_title")}</h2>
<p>{t("errors:unhandled_error")}</p>
</LayoutContainer>
);
}
return (
<>
<TopAlerts />
Expand All @@ -42,7 +54,7 @@ export default function Dashboard() {
<PageLoader buffered />
) : (
<LayoutContainer top gutters>
<Stack gap={3}>
<Stack gap="3">
{dashboard.vendibleGroupings.map(({ name, vendibles }) => (
<HamburgerSection key={name} name={name}>
{vendibles.map((v) => (
Expand Down

0 comments on commit 834ba61

Please sign in to comment.