diff --git a/packages/desktop-client/src/components/FeatureErrorFallback.tsx b/packages/desktop-client/src/components/FeatureErrorFallback.tsx new file mode 100644 index 0000000000..39ad484f2a --- /dev/null +++ b/packages/desktop-client/src/components/FeatureErrorFallback.tsx @@ -0,0 +1,51 @@ +import React, { useEffect } from 'react'; +import type { FallbackProps } from 'react-error-boundary'; +import { Trans } from 'react-i18next'; + +import { Button } from '@actual-app/components/button'; +import { styles } from '@actual-app/components/styles'; +import { Text } from '@actual-app/components/text'; +import { theme } from '@actual-app/components/theme'; +import { View } from '@actual-app/components/view'; + +export function FeatureErrorFallback({ + error, + resetErrorBoundary, +}: FallbackProps) { + useEffect(() => { + console.error(error); + }, [error]); + + return ( + + + Something went wrong loading this section. + + {error?.message && ( + + {error.message} + + )} + + + ); +} diff --git a/packages/desktop-client/src/components/FinancesApp.tsx b/packages/desktop-client/src/components/FinancesApp.tsx index 561984c9a6..75ebf2161e 100644 --- a/packages/desktop-client/src/components/FinancesApp.tsx +++ b/packages/desktop-client/src/components/FinancesApp.tsx @@ -1,5 +1,6 @@ import React, { useEffect, useEffectEvent, useRef } from 'react'; import type { ReactElement } from 'react'; +import { ErrorBoundary } from 'react-error-boundary'; import { useTranslation } from 'react-i18next'; import { Navigate, Route, Routes, useHref, useLocation } from 'react-router'; @@ -23,6 +24,7 @@ import { useDispatch, useSelector } from '#redux'; import { UserAccessPage } from './admin/UserAccess/UserAccessPage'; import { BankSyncStatus } from './BankSyncStatus'; import { CommandBar } from './CommandBar'; +import { FeatureErrorFallback } from './FeatureErrorFallback'; import { GlobalKeys } from './GlobalKeys'; import { MobileBankSyncAccountEditPage } from './mobile/banksync/MobileBankSyncAccountEditPage'; import { MobileNavTabs } from './mobile/MobileNavTabs'; @@ -86,6 +88,7 @@ export function FinancesApp() { const { isNarrowWidth } = useResponsive(); useMetaThemeColor(isNarrowWidth ? theme.mobileViewTheme : undefined); + const location = useLocation(); const dispatch = useDispatch(); const { t } = useTranslation(); @@ -286,11 +289,25 @@ export function FinancesApp() { /> } + element={ + + + + } /> } + element={ + + + + } />