diff --git a/packages/desktop-client/src/components/Modals.tsx b/packages/desktop-client/src/components/Modals.tsx index 429768aec48..be05395cd3f 100644 --- a/packages/desktop-client/src/components/Modals.tsx +++ b/packages/desktop-client/src/components/Modals.tsx @@ -4,7 +4,6 @@ import { useSelector } from 'react-redux'; import { send } from 'loot-core/src/platform/client/fetch'; import { useActions } from '../hooks/useActions'; -import useFeatureFlag from '../hooks/useFeatureFlag'; import useSyncServerStatus from '../hooks/useSyncServerStatus'; import BudgetSummary from './modals/BudgetSummary'; @@ -26,6 +25,7 @@ import PlaidExternalMsg from './modals/PlaidExternalMsg'; import SelectLinkedAccounts from './modals/SelectLinkedAccounts'; export default function Modals() { + useSelector(state => console.log(state)); const modalStack = useSelector(state => state.modals.modalStack); const isHidden = useSelector(state => state.modals.isHidden); const accounts = useSelector(state => state.queries.accounts); @@ -34,7 +34,6 @@ export default function Modals() { const budgetId = useSelector( state => state.prefs.local && state.prefs.local.id, ); - const isGoalTemplatesEnabled = useFeatureFlag('goalTemplatesEnabled'); const actions = useActions(); const syncServerStatus = useSyncServerStatus(); diff --git a/packages/loot-core/src/client/state-types/queries.d.ts b/packages/loot-core/src/client/state-types/queries.d.ts index e2b379417fa..ba884cb36d1 100644 --- a/packages/loot-core/src/client/state-types/queries.d.ts +++ b/packages/loot-core/src/client/state-types/queries.d.ts @@ -6,7 +6,7 @@ export type QueriesState = { matchedTransactions: unknown[]; lastTransaction: unknown | null; updatedAccounts: string[]; - accounts: unknown[]; + accounts: AccountEntity[]; categories: Awaited>; payees: unknown[]; earliestTransaction: unknown | null; @@ -36,7 +36,7 @@ type MarkAccountReadAction = { type LoadAccountsAction = { type: typeof constants.LOAD_ACCOUNTS; - accounts: unknown[]; + accounts: AccountEntity[]; }; type UpdateAccountAction = { diff --git a/packages/loot-core/src/mocks/budget.ts b/packages/loot-core/src/mocks/budget.ts index 56f7c894df2..ccfb3e60850 100644 --- a/packages/loot-core/src/mocks/budget.ts +++ b/packages/loot-core/src/mocks/budget.ts @@ -10,7 +10,6 @@ import { batchMessages, setSyncingMode } from '../server/sync'; import * as monthUtils from '../shared/months'; import q from '../shared/query'; import type { - AccountEntity, CategoryGroupEntity, PayeeEntity, TransactionEntity, @@ -563,7 +562,7 @@ export async function createTestBudget(handlers) { await db.runQuery('DELETE FROM categories;'); await db.runQuery('DELETE FROM category_groups'); - let accounts: AccountEntity[] = [ + let accounts: { name: string; offBudget?: 1; id?: string }[] = [ { name: 'Bank of America' }, { name: 'Ally Savings' }, { name: 'Capital One Checking' }, diff --git a/packages/loot-core/src/types/models/account.d.ts b/packages/loot-core/src/types/models/account.d.ts index 5d062d8a4cd..3bb86d4cb95 100644 --- a/packages/loot-core/src/types/models/account.d.ts +++ b/packages/loot-core/src/types/models/account.d.ts @@ -1,10 +1,19 @@ -export interface AccountEntity { - id?: string; +export type AccountEntity = { + id: string; name: string; - offbudget?: boolean; - closed?: boolean; - sort_order?: number; - tombstone?: boolean; - // TODO: remove once properly typed - [k: string]: unknown; -} + offbudget: 0 | 1; + closed: 0 | 1; + sort_order: number; + tombstone: 0 | 1; + subtype: string | null; // TODO: remove? +} & (_SyncFields | _SyncFields); + +type _SyncFields = { + account_id: T extends true ? string : null; + bank: 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; + balance_available: T extends true ? number : null; + balance_limit: T extends true ? number : null; +}; diff --git a/packages/loot-core/src/types/server-handlers.d.ts b/packages/loot-core/src/types/server-handlers.d.ts index 09e5acaa797..07cea002265 100644 --- a/packages/loot-core/src/types/server-handlers.d.ts +++ b/packages/loot-core/src/types/server-handlers.d.ts @@ -3,6 +3,7 @@ import { batchUpdateTransactions } from '../server/accounts/transactions'; import { Backup } from '../server/backups'; import { RemoteFile } from '../server/cloud-storage'; import { Message } from '../server/sync'; +import { AccountEntity } from './models'; import { EmptyObject } from './util'; @@ -134,7 +135,7 @@ export interface ServerHandlers { 'account-update': (arg: { id; name }) => Promise; - 'accounts-get': () => Promise; + 'accounts-get': () => Promise; 'account-properties': (arg: { id; @@ -168,10 +169,10 @@ export interface ServerHandlers { }) => Promise; 'account-create': (arg: { - name; - balance; - offBudget; - closed?; + name: string; + balance: number; + offBudget?: boolean; + closed?: 0 | 1; }) => Promise; 'account-close': (arg: {