Skip to content

A local-first personal finance app

Update useAccounts to return react query states (#7009)

Joel Jeremy Marquez5ac294734265
diff --git a/packages/desktop-client/src/accounts/mutations.ts b/packages/desktop-client/src/accounts/mutations.ts
index be75f7f5e0..e6d353f4d7 100644
--- a/packages/desktop-client/src/accounts/mutations.ts
+++ b/packages/desktop-client/src/accounts/mutations.ts
@@ -511,7 +511,7 @@ export function useSyncAccountsMutation() {
const dispatch = useDispatch();
const { t } = useTranslation();
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const store = useStore();
return useMutation({
diff --git a/packages/desktop-client/src/components/CommandBar.tsx b/packages/desktop-client/src/components/CommandBar.tsx
index d7f4f3ea79..27965aa241 100644
--- a/packages/desktop-client/src/components/CommandBar.tsx
+++ b/packages/desktop-client/src/components/CommandBar.tsx
@@ -142,7 +142,7 @@ export function CommandBar() {
if (!open) setSearch('');
}, [open]);
- const allAccounts = useAccounts();
+ const { data: allAccounts = [] } = useAccounts();
const { data: customReports = [] } = useReports();
const { data: dashboardPages = [] } = useDashboardPages();
diff --git a/packages/desktop-client/src/components/ManageRules.tsx b/packages/desktop-client/src/components/ManageRules.tsx
index 6bda42336b..0895db0f31 100644
--- a/packages/desktop-client/src/components/ManageRules.tsx
+++ b/packages/desktop-client/src/components/ManageRules.tsx
@@ -136,7 +136,7 @@ export function ManageRules({
});
const { data: { list: categories } = { list: [] } } = useCategories();
const payees = usePayees();
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const filterData = useMemo(
() => ({
payees,
diff --git a/packages/desktop-client/src/components/accounts/Account.tsx b/packages/desktop-client/src/components/accounts/Account.tsx
index 397639efcd..0c2f2ea47e 100644
--- a/packages/desktop-client/src/components/accounts/Account.tsx
+++ b/packages/desktop-client/src/components/accounts/Account.tsx
@@ -1965,7 +1965,7 @@ export function Account() {
const matchedTransactions = useSelector(
state => state.transactions.matchedTransactions,
);
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const payees = usePayees();
const failedAccounts = useFailedAccounts();
const dateFormat = useDateFormat() || 'MM/dd/yyyy';
diff --git a/packages/desktop-client/src/components/accounts/AccountSyncCheck.tsx b/packages/desktop-client/src/components/accounts/AccountSyncCheck.tsx
index 0c49be9a24..ca147e0d5b 100644
--- a/packages/desktop-client/src/components/accounts/AccountSyncCheck.tsx
+++ b/packages/desktop-client/src/components/accounts/AccountSyncCheck.tsx
@@ -86,7 +86,7 @@ function useErrorMessage() {
}
export function AccountSyncCheck() {
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const failedAccounts = useFailedAccounts();
const dispatch = useDispatch();
const { id } = useParams();
diff --git a/packages/desktop-client/src/components/autocomplete/AccountAutocomplete.tsx b/packages/desktop-client/src/components/autocomplete/AccountAutocomplete.tsx
index 4982ba8d13..85e80bea04 100644
--- a/packages/desktop-client/src/components/autocomplete/AccountAutocomplete.tsx
+++ b/packages/desktop-client/src/components/autocomplete/AccountAutocomplete.tsx
@@ -174,7 +174,7 @@ export function AccountAutocomplete({
}: AccountAutocompleteProps) {
const { t } = useTranslation();
- const accounts = useAccounts() || [];
+ const { data: accounts = [] } = useAccounts();
//remove closed accounts if needed
//then sort by closed, then offbudget
diff --git a/packages/desktop-client/src/components/autocomplete/PayeeAutocomplete.tsx b/packages/desktop-client/src/components/autocomplete/PayeeAutocomplete.tsx
index cdf329804e..c7824e6bf1 100644
--- a/packages/desktop-client/src/components/autocomplete/PayeeAutocomplete.tsx
+++ b/packages/desktop-client/src/components/autocomplete/PayeeAutocomplete.tsx
@@ -353,7 +353,7 @@ export function PayeeAutocomplete({
payees = retrievedPayees;
}
- const cachedAccounts = useAccounts();
+ const { data: cachedAccounts = [] } = useAccounts();
if (!accounts) {
accounts = cachedAccounts;
}
diff --git a/packages/desktop-client/src/components/banksync/index.tsx b/packages/desktop-client/src/components/banksync/index.tsx
index d095052ac9..44321c65e5 100644
--- a/packages/desktop-client/src/components/banksync/index.tsx
+++ b/packages/desktop-client/src/components/banksync/index.tsx
@@ -39,7 +39,7 @@ export function BankSync() {
const { syncSourceReadable } = useSyncSourceReadable();
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const dispatch = useDispatch();
const { isNarrowWidth } = useResponsive();
diff --git a/packages/desktop-client/src/components/mobile/accounts/AccountsPage.tsx b/packages/desktop-client/src/components/mobile/accounts/AccountsPage.tsx
index 6ba3f121a8..3f653b6503 100644
--- a/packages/desktop-client/src/components/mobile/accounts/AccountsPage.tsx
+++ b/packages/desktop-client/src/components/mobile/accounts/AccountsPage.tsx
@@ -506,7 +506,7 @@ AccountList.displayName = 'AccountList';
export function AccountsPage() {
const dispatch = useDispatch();
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const [_numberFormat] = useSyncedPref('numberFormat');
const numberFormat = _numberFormat || 'comma-dot';
const [hideFraction] = useSyncedPref('hideFraction');
diff --git a/packages/desktop-client/src/components/mobile/banksync/MobileBankSyncPage.tsx b/packages/desktop-client/src/components/mobile/banksync/MobileBankSyncPage.tsx
index 97d0e14c29..99335d1b0d 100644
--- a/packages/desktop-client/src/components/mobile/banksync/MobileBankSyncPage.tsx
+++ b/packages/desktop-client/src/components/mobile/banksync/MobileBankSyncPage.tsx
@@ -37,7 +37,7 @@ export function MobileBankSyncPage() {
const navigate = useNavigate();
const dispatch = useDispatch();
const { syncSourceReadable } = useSyncSourceReadable();
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const [filter, setFilter] = useState('');
const openAccounts = useMemo(
diff --git a/packages/desktop-client/src/components/mobile/rules/MobileRulesPage.tsx b/packages/desktop-client/src/components/mobile/rules/MobileRulesPage.tsx
index 9d6aaccc98..368b4d3c02 100644
--- a/packages/desktop-client/src/components/mobile/rules/MobileRulesPage.tsx
+++ b/packages/desktop-client/src/components/mobile/rules/MobileRulesPage.tsx
@@ -42,7 +42,7 @@ export function MobileRulesPage() {
});
const { data: { list: categories } = { list: [] } } = useCategories();
const payees = usePayees();
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const filterData = useMemo(
() => ({
payees,
diff --git a/packages/desktop-client/src/components/mobile/schedules/MobileSchedulesPage.tsx b/packages/desktop-client/src/components/mobile/schedules/MobileSchedulesPage.tsx
index 8a5a560226..b82f4d0788 100644
--- a/packages/desktop-client/src/components/mobile/schedules/MobileSchedulesPage.tsx
+++ b/packages/desktop-client/src/components/mobile/schedules/MobileSchedulesPage.tsx
@@ -46,7 +46,7 @@ export function MobileSchedulesPage() {
} = useSchedules({ query: schedulesQuery });
const payees = usePayees();
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const filterIncludes = (str: string | null | undefined) =>
str
diff --git a/packages/desktop-client/src/components/mobile/transactions/TransactionEdit.tsx b/packages/desktop-client/src/components/mobile/transactions/TransactionEdit.tsx
index db5e3a4c0b..446c12bbcc 100644
--- a/packages/desktop-client/src/components/mobile/transactions/TransactionEdit.tsx
+++ b/packages/desktop-client/src/components/mobile/transactions/TransactionEdit.tsx
@@ -1685,7 +1685,7 @@ export const TransactionEdit = (props: TransactionEditProps) => {
const lastTransaction = useSelector(
state => state.transactions.lastTransaction,
);
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const dateFormat = useDateFormat() || 'MM/dd/yyyy';
return (
diff --git a/packages/desktop-client/src/components/mobile/transactions/TransactionList.tsx b/packages/desktop-client/src/components/mobile/transactions/TransactionList.tsx
index 7ffdceb0b4..178d609b5f 100644
--- a/packages/desktop-client/src/components/mobile/transactions/TransactionList.tsx
+++ b/packages/desktop-client/src/components/mobile/transactions/TransactionList.tsx
@@ -334,7 +334,7 @@ function SelectedTransactionsFloatingActionBar({
} = useTransactionBatchActions();
const navigate = useNavigate();
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const accountsById = useMemo(() => groupById(accounts), [accounts]);
const payees = usePayees();
diff --git a/packages/desktop-client/src/components/modals/AccountMenuModal.tsx b/packages/desktop-client/src/components/modals/AccountMenuModal.tsx
index 2e0b783904..cb8073e992 100644
--- a/packages/desktop-client/src/components/modals/AccountMenuModal.tsx
+++ b/packages/desktop-client/src/components/modals/AccountMenuModal.tsx
@@ -48,7 +48,7 @@ export function AccountMenuModal({
}: AccountMenuModalProps) {
const { t } = useTranslation();
const account = useAccount(accountId);
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const originalNotes = useNotes(`account-${accountId}`);
const [accountNameError, setAccountNameError] = useState('');
const [currentAccountName, setCurrentAccountName] = useState(
diff --git a/packages/desktop-client/src/components/modals/CloseAccountModal.tsx b/packages/desktop-client/src/components/modals/CloseAccountModal.tsx
index 2c623e33ea..a462db5e32 100644
--- a/packages/desktop-client/src/components/modals/CloseAccountModal.tsx
+++ b/packages/desktop-client/src/components/modals/CloseAccountModal.tsx
@@ -56,7 +56,8 @@ export function CloseAccountModal({
canDelete,
}: CloseAccountModalProps) {
const { t } = useTranslation(); // Initialize translation hook
- const accounts = useAccounts().filter(a => a.closed === 0);
+ const { data: allAccounts = [] } = useAccounts();
+ const accounts = allAccounts.filter(a => a.closed === 0);
const {
data: { grouped: categoryGroups, list: categories } = {
grouped: [],
diff --git a/packages/desktop-client/src/components/modals/CreateLocalAccountModal.tsx b/packages/desktop-client/src/components/modals/CreateLocalAccountModal.tsx
index 704e807f0d..3a259ecc8b 100644
--- a/packages/desktop-client/src/components/modals/CreateLocalAccountModal.tsx
+++ b/packages/desktop-client/src/components/modals/CreateLocalAccountModal.tsx
@@ -35,7 +35,7 @@ export function CreateLocalAccountModal() {
const { t } = useTranslation();
const navigate = useNavigate();
const dispatch = useDispatch();
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const [name, setName] = useState('');
const [offbudget, setOffbudget] = useState(false);
const [balance, setBalance] = useState('0');
diff --git a/packages/desktop-client/src/components/modals/PayeeAutocompleteModal.tsx b/packages/desktop-client/src/components/modals/PayeeAutocompleteModal.tsx
index bdfdce2d70..bf8af6c1ec 100644
--- a/packages/desktop-client/src/components/modals/PayeeAutocompleteModal.tsx
+++ b/packages/desktop-client/src/components/modals/PayeeAutocompleteModal.tsx
@@ -27,7 +27,7 @@ export function PayeeAutocompleteModal({
}: PayeeAutocompleteModalProps) {
const { t } = useTranslation();
const payees = usePayees() || [];
- const accounts = useAccounts() || [];
+ const { data: accounts = [] } = useAccounts();
const navigate = useNavigate();
const { isNarrowWidth } = useResponsive();
diff --git a/packages/desktop-client/src/components/modals/SelectLinkedAccountsModal.tsx b/packages/desktop-client/src/components/modals/SelectLinkedAccountsModal.tsx
index a4983ac900..75d4711684 100644
--- a/packages/desktop-client/src/components/modals/SelectLinkedAccountsModal.tsx
+++ b/packages/desktop-client/src/components/modals/SelectLinkedAccountsModal.tsx
@@ -135,7 +135,8 @@ export function SelectLinkedAccountsModal({
const { t } = useTranslation();
const { isNarrowWidth } = useResponsive();
const dispatch = useDispatch();
- const localAccounts = useAccounts().filter(a => a.closed === 0);
+ const { data: allAccounts = [] } = useAccounts();
+ const localAccounts = allAccounts.filter(a => a.closed === 0);
const [draftLinkAccounts, setDraftLinkAccounts] = useState<
Map<string, 'linking' | 'unlinking'>
>(new Map());
diff --git a/packages/desktop-client/src/components/reports/Overview.tsx b/packages/desktop-client/src/components/reports/Overview.tsx
index 4ad147ff13..f0b5a4b050 100644
--- a/packages/desktop-client/src/components/reports/Overview.tsx
+++ b/packages/desktop-client/src/components/reports/Overview.tsx
@@ -449,7 +449,7 @@ export function Overview({ dashboard }: OverviewProps) {
);
};
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
if (isLoading) {
return <LoadingIndicator message={t('Loading reports...')} />;
diff --git a/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx b/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx
index 1b14117f1a..a362d30959 100644
--- a/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx
@@ -196,7 +196,7 @@ export function BarGraph({
const animationProps = useRechartsAnimation();
const navigate = useNavigate();
const { data: categories = { grouped: [], list: [] } } = useCategories();
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const privacyMode = usePrivacyMode();
const format = useFormat();
diff --git a/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx b/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx
index cb34bb7c85..d76dd34aa9 100644
--- a/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx
@@ -252,7 +252,7 @@ export function DonutGraph({
const navigate = useNavigate();
const { data: categories = { grouped: [], list: [] } } = useCategories();
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const [pointer, setPointer] = useState('');
const getVal = (obj: GroupedEntity | IntervalEntity) => {
diff --git a/packages/desktop-client/src/components/reports/graphs/LineGraph.tsx b/packages/desktop-client/src/components/reports/graphs/LineGraph.tsx
index a84d230aa6..ee46a3c4a7 100644
--- a/packages/desktop-client/src/components/reports/graphs/LineGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/LineGraph.tsx
@@ -169,7 +169,7 @@ export function LineGraph({
const animationProps = useRechartsAnimation();
const navigate = useNavigate();
const { data: categories = { grouped: [], list: [] } } = useCategories();
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const privacyMode = usePrivacyMode();
const format = useFormat();
diff --git a/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx b/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx
index b19fc9642d..80a87cb820 100644
--- a/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx
@@ -200,7 +200,7 @@ export function StackedBarGraph({
const animationProps = useRechartsAnimation();
const navigate = useNavigate();
const { data: categories = { grouped: [], list: [] } } = useCategories();
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const privacyMode = usePrivacyMode();
const format = useFormat();
diff --git a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx
index e6894cff67..1b8b7d4f26 100644
--- a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx
@@ -75,7 +75,7 @@ export const ReportTableRow = memo(
const navigate = useNavigate();
const { isNarrowWidth } = useResponsive();
const { data: categories = { grouped: [], list: [] } } = useCategories();
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const pointer =
!isNarrowWidth &&
diff --git a/packages/desktop-client/src/components/reports/reports/Calendar.tsx b/packages/desktop-client/src/components/reports/reports/Calendar.tsx
index c0ddffd5b8..13f0b3767a 100644
--- a/packages/desktop-client/src/components/reports/reports/Calendar.tsx
+++ b/packages/desktop-client/src/components/reports/reports/Calendar.tsx
@@ -121,7 +121,7 @@ function CalendarInner({ widget, parameters }: CalendarInnerProps) {
[transactionsGrouped],
);
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const payees = usePayees();
const { data: { grouped: categoryGroups } = { grouped: [] } } =
useCategories();
diff --git a/packages/desktop-client/src/components/reports/reports/Crossover.tsx b/packages/desktop-client/src/components/reports/reports/Crossover.tsx
index a8baad2a53..0a51718ebf 100644
--- a/packages/desktop-client/src/components/reports/reports/Crossover.tsx
+++ b/packages/desktop-client/src/components/reports/reports/Crossover.tsx
@@ -80,7 +80,7 @@ function CrossoverInner({ widget }: CrossoverInnerProps) {
const locale = useLocale();
const { t } = useTranslation();
const dispatch = useDispatch();
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const {
data: categories = { grouped: [], list: [] },
isPending: isCategoriesLoading,
diff --git a/packages/desktop-client/src/components/reports/reports/CustomReport.tsx b/packages/desktop-client/src/components/reports/reports/CustomReport.tsx
index 633f3510cf..ff7585c773 100644
--- a/packages/desktop-client/src/components/reports/reports/CustomReport.tsx
+++ b/packages/desktop-client/src/components/reports/reports/CustomReport.tsx
@@ -474,7 +474,7 @@ function CustomReportInner({ report: initialReport }: CustomReportInnerProps) {
ReportOptions.balanceTypeMap.get(balanceType) || 'totalDebts';
const sortByOp: sortByOpType = sortBy || 'desc';
const payees = usePayees();
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const hasWarning = calculateHasWarning(conditions, {
categories: categories.list,
diff --git a/packages/desktop-client/src/components/reports/reports/CustomReportListCards.tsx b/packages/desktop-client/src/components/reports/reports/CustomReportListCards.tsx
index 30d92899a9..e53d223d27 100644
--- a/packages/desktop-client/src/components/reports/reports/CustomReportListCards.tsx
+++ b/packages/desktop-client/src/components/reports/reports/CustomReportListCards.tsx
@@ -81,7 +81,7 @@ function CustomReportListCardsInner({
useDashboardWidgetCopyMenu(onCopy);
const payees = usePayees();
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const { data: categories = { list: [], grouped: [] } } = useCategories();
const hasWarning = calculateHasWarning(report.conditions ?? [], {
diff --git a/packages/desktop-client/src/components/reports/reports/NetWorth.tsx b/packages/desktop-client/src/components/reports/reports/NetWorth.tsx
index ffd9893fe8..e4f8eb1cb7 100644
--- a/packages/desktop-client/src/components/reports/reports/NetWorth.tsx
+++ b/packages/desktop-client/src/components/reports/reports/NetWorth.tsx
@@ -86,7 +86,7 @@ function NetWorthInner({ widget }: NetWorthInnerProps) {
[],
);
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const {
conditions,
conditionsOp,
diff --git a/packages/desktop-client/src/components/rules/Value.tsx b/packages/desktop-client/src/components/rules/Value.tsx
index f0d50f4345..fc09efd0d7 100644
--- a/packages/desktop-client/src/components/rules/Value.tsx
+++ b/packages/desktop-client/src/components/rules/Value.tsx
@@ -49,7 +49,7 @@ export function Value<T>({
grouped: [],
},
} = useCategories();
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const valueStyle = {
color: theme.pageTextPositive,
...style,
diff --git a/packages/desktop-client/src/components/schedules/SchedulesTable.tsx b/packages/desktop-client/src/components/schedules/SchedulesTable.tsx
index 697e9fbf6c..4db49c1053 100644
--- a/packages/desktop-client/src/components/schedules/SchedulesTable.tsx
+++ b/packages/desktop-client/src/components/schedules/SchedulesTable.tsx
@@ -340,7 +340,7 @@ export function SchedulesTable({
const [showCompleted, setShowCompleted] = useState(false);
const payees = usePayees();
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const filteredSchedules = useMemo(() => {
if (!filter) {
diff --git a/packages/desktop-client/src/components/sidebar/Accounts.tsx b/packages/desktop-client/src/components/sidebar/Accounts.tsx
index 53beff3fc0..8bb0c1178a 100644
--- a/packages/desktop-client/src/components/sidebar/Accounts.tsx
+++ b/packages/desktop-client/src/components/sidebar/Accounts.tsx
@@ -25,7 +25,7 @@ const fontWeight = 600;
export function Accounts() {
const { t } = useTranslation();
const [isDragging, setIsDragging] = useState(false);
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const failedAccounts = useFailedAccounts();
const updatedAccounts = useUpdatedAccounts();
const offbudgetAccounts = useOffBudgetAccounts();
diff --git a/packages/desktop-client/src/hooks/useAccountPreviewTransactions.ts b/packages/desktop-client/src/hooks/useAccountPreviewTransactions.ts
index 85a4271ecd..0424e9855d 100644
--- a/packages/desktop-client/src/hooks/useAccountPreviewTransactions.ts
+++ b/packages/desktop-client/src/hooks/useAccountPreviewTransactions.ts
@@ -34,7 +34,7 @@ type UseAccountPreviewTransactionsResult = ReturnType<
export function useAccountPreviewTransactions({
accountId,
}: UseAccountPreviewTransactionsProps): UseAccountPreviewTransactionsResult {
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const accountsById = useMemo(() => groupById(accounts), [accounts]);
const payees = usePayees();
const payeesById = useMemo(() => groupById(payees), [payees]);
diff --git a/packages/desktop-client/src/hooks/useAccounts.ts b/packages/desktop-client/src/hooks/useAccounts.ts
index 2bd521dace..2ef67e75ee 100644
--- a/packages/desktop-client/src/hooks/useAccounts.ts
+++ b/packages/desktop-client/src/hooks/useAccounts.ts
@@ -3,8 +3,5 @@ import { useQuery } from '@tanstack/react-query';
import { accountQueries } from '@desktop-client/accounts';
export function useAccounts() {
- const query = useQuery(accountQueries.list());
- // TODO: Update to return query states (e.g. isFetching, isError, etc)
- // so clients can handle loading and error states appropriately.
- return query.data ?? [];
+ return useQuery(accountQueries.list());
}
diff --git a/packages/desktop-client/src/hooks/useDisplayPayee.tsx b/packages/desktop-client/src/hooks/useDisplayPayee.tsx
index d3552a5066..4008aa71ab 100644
--- a/packages/desktop-client/src/hooks/useDisplayPayee.tsx
+++ b/packages/desktop-client/src/hooks/useDisplayPayee.tsx
@@ -43,7 +43,7 @@ export function DisplayPayeeProvider({
options: { pageSize: transactions.length * 5 },
});
- const accounts = useAccounts();
+ const { data: accounts = [] } = useAccounts();
const payeesById = usePayeesById();
const displayPayees = useMemo(() => {
diff --git a/upcoming-release-notes/7009.md b/upcoming-release-notes/7009.md
new file mode 100644
index 0000000000..562435bff5
--- /dev/null
+++ b/upcoming-release-notes/7009.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [joel-jeremy]
+---
+
+Refactor `useAccounts` to return full query states, enhancing data handling across components.