mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-22 00:13:45 -05:00
Move redux state to react-query - account states (#6140)
* Fix typecheck errors * Move redux state to react-query - account states * TestProviders * Add release notes for PR #6140 * Fix lint error * Fix TestProviders * Coderabbit feedback * Cleanup * [autofix.ci] apply automated fixes * Fix TestProviders * Fix onbudget and offbudget displaying closed accounts * [skip ci] Change category to Maintenance and update migration text * Replace logger calls in desktop-client to console * Fix lint errors * Clear react query on closing of budget file similar to redux resetApp action * [autofix.ci] apply automated fixes * Remove sendThrow * Code review feedback * [autofix.ci] apply automated fixes * Fix import * Fix import * Coderabbit feedback --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
5062fa78a8
commit
465608c76b
@@ -31,7 +31,7 @@ export function generateAccount(
|
||||
return {
|
||||
...offlineAccount,
|
||||
balance_current: Math.floor(random() * 100000),
|
||||
bankId: Math.floor(random() * 10000),
|
||||
bankId: Math.floor(random() * 10000).toString(),
|
||||
bankName: 'boa',
|
||||
bank: Math.floor(random() * 10000).toString(),
|
||||
account_id: 'idx',
|
||||
|
||||
@@ -89,8 +89,31 @@ async function updateAccount({
|
||||
return {};
|
||||
}
|
||||
|
||||
async function getAccounts() {
|
||||
return db.getAccounts();
|
||||
async function getAccounts(): Promise<AccountEntity[]> {
|
||||
const dbAccounts = await db.getAccounts();
|
||||
return dbAccounts.map(
|
||||
dbAccount =>
|
||||
({
|
||||
id: dbAccount.id,
|
||||
name: dbAccount.name,
|
||||
offbudget: dbAccount.offbudget,
|
||||
closed: dbAccount.closed,
|
||||
sort_order: dbAccount.sort_order,
|
||||
last_reconciled: dbAccount.last_reconciled ?? null,
|
||||
tombstone: dbAccount.tombstone,
|
||||
account_id: dbAccount.account_id ?? null,
|
||||
bank: dbAccount.bank ?? null,
|
||||
bankName: dbAccount.bankName ?? null,
|
||||
bankId: dbAccount.bankId ?? null,
|
||||
mask: dbAccount.mask ?? null,
|
||||
official_name: dbAccount.official_name ?? null,
|
||||
balance_current: dbAccount.balance_current ?? null,
|
||||
balance_available: dbAccount.balance_available ?? null,
|
||||
balance_limit: dbAccount.balance_limit ?? null,
|
||||
account_sync_source: dbAccount.account_sync_source ?? null,
|
||||
last_sync: dbAccount.last_sync ?? null,
|
||||
}) as AccountEntity,
|
||||
);
|
||||
}
|
||||
|
||||
async function getAccountBalance({
|
||||
|
||||
@@ -571,8 +571,7 @@ handlers['api/transaction-delete'] = withMutation(async function ({ id }) {
|
||||
|
||||
handlers['api/accounts-get'] = async function () {
|
||||
checkFileOpen();
|
||||
// TODO: Force cast to AccountEntity. This should be updated to an AQL query.
|
||||
const accounts = (await db.getAccounts()) as AccountEntity[];
|
||||
const accounts: AccountEntity[] = await handlers['accounts-get']();
|
||||
return accounts.map(account => accountModel.toExternal(account));
|
||||
};
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ export type DbAccount = {
|
||||
subtype?: string | null;
|
||||
bank?: string | null;
|
||||
account_sync_source?: 'simpleFin' | 'goCardless' | null;
|
||||
last_reconciled?: string | null;
|
||||
last_sync?: string | null;
|
||||
};
|
||||
|
||||
export type DbBank = {
|
||||
|
||||
@@ -12,7 +12,7 @@ export type _SyncFields<T> = {
|
||||
account_id: T extends true ? string : null;
|
||||
bank: T extends true ? string : null;
|
||||
bankName: T extends true ? string : null;
|
||||
bankId: T extends true ? number : null;
|
||||
bankId: T extends true ? string : null;
|
||||
mask: T extends true ? string : null; // end of bank account number
|
||||
official_name: T extends true ? string : null;
|
||||
balance_current: T extends true ? number : null;
|
||||
|
||||
Reference in New Issue
Block a user