Fix redirect to accounts page when no accounts exists (#7007)

* Fix redirect to accounts page when no accounts exists

* Add release notes for PR #7007

* Use isFetching

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Joel Jeremy Marquez
2026-02-17 14:33:49 -08:00
committed by GitHub
parent 180a38890c
commit da0154a41b
2 changed files with 14 additions and 10 deletions

View File

@@ -92,7 +92,7 @@ export function FinancesApp() {
const { t } = useTranslation();
// TODO: Replace with `useAccounts` hook once it's updated to return the useQuery results.
const { data: accounts, isSuccess: isAccountsLoaded } = useQuery(
const { data: accounts, isFetching: isAccountsFetching } = useQuery(
accountQueries.list(),
);
@@ -245,16 +245,14 @@ export function FinancesApp() {
<Route
path="/"
element={
isAccountsLoaded ? (
accounts.length > 0 ? (
<Navigate to="/budget" replace />
) : (
// If there are no accounts, we want to redirect the user to
// the All Accounts screen which will prompt them to add an account
<Navigate to="/accounts" replace />
)
) : (
isAccountsFetching || !accounts ? (
<LoadingIndicator />
) : accounts.length > 0 ? (
<Navigate to="/budget" replace />
) : (
// If there are no accounts, we want to redirect the user to
// the All Accounts screen which will prompt them to add an account
<Navigate to="/accounts" replace />
)
}
/>

View File

@@ -0,0 +1,6 @@
---
category: Bugfixes
authors: [joel-jeremy]
---
Fix redirect to accounts page when no accounts exist, improving user experience.