From 2ebaa527be9330e48850758fa88c59ace5c57d48 Mon Sep 17 00:00:00 2001 From: Joel Jeremy Marquez Date: Thu, 21 Nov 2024 16:01:26 -0800 Subject: [PATCH] Convert mobile Accounts.jsx to tsx (#3862) * Convert mobile Accounts.jsx to TS * Release notes * Fix lint --- .../src/components/accounts/Account.tsx | 8 +- .../accounts/{Accounts.jsx => Accounts.tsx} | 103 ++++++++++++------ .../loot-core/src/client/reducers/queries.ts | 1 - .../src/client/state-types/queries.d.ts | 19 ++-- upcoming-release-notes/3862.md | 6 + 5 files changed, 91 insertions(+), 46 deletions(-) rename packages/desktop-client/src/components/mobile/accounts/{Accounts.jsx => Accounts.tsx} (73%) create mode 100644 upcoming-release-notes/3862.md diff --git a/packages/desktop-client/src/components/accounts/Account.tsx b/packages/desktop-client/src/components/accounts/Account.tsx index 65783c08914..fc21cfe093a 100644 --- a/packages/desktop-client/src/components/accounts/Account.tsx +++ b/packages/desktop-client/src/components/accounts/Account.tsx @@ -266,8 +266,8 @@ type AccountInternalProps = { accounts: AccountEntity[]; getPayees: () => Promise; updateAccount: (newAccount: AccountEntity) => void; - newTransactions: string[]; - matchedTransactions: string[]; + newTransactions: Array; + matchedTransactions: Array; splitsExpandedDispatch: ReturnType['dispatch']; expandSplits?: boolean; savedFilters: TransactionFilterEntity[]; @@ -870,11 +870,11 @@ class AccountInternal extends PureComponent< return amount; }; - isNew = (id: string) => { + isNew = (id: TransactionEntity['id']) => { return this.props.newTransactions.includes(id); }; - isMatched = (id: string) => { + isMatched = (id: TransactionEntity['id']) => { return this.props.matchedTransactions.includes(id); }; diff --git a/packages/desktop-client/src/components/mobile/accounts/Accounts.jsx b/packages/desktop-client/src/components/mobile/accounts/Accounts.tsx similarity index 73% rename from packages/desktop-client/src/components/mobile/accounts/Accounts.jsx rename to packages/desktop-client/src/components/mobile/accounts/Accounts.tsx index 396cead5b2e..f17806dc4a8 100644 --- a/packages/desktop-client/src/components/mobile/accounts/Accounts.jsx +++ b/packages/desktop-client/src/components/mobile/accounts/Accounts.tsx @@ -1,10 +1,11 @@ -import React from 'react'; +import React, { type CSSProperties, useCallback } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { t } from 'i18next'; import { replaceModal, syncAndDownload } from 'loot-core/src/client/actions'; import * as queries from 'loot-core/src/client/queries'; +import { type AccountEntity } from 'loot-core/types/models'; import { useAccounts } from '../../../hooks/useAccounts'; import { useFailedAccounts } from '../../../hooks/useFailedAccounts'; @@ -18,11 +19,22 @@ import { Text } from '../../common/Text'; import { TextOneLine } from '../../common/TextOneLine'; import { View } from '../../common/View'; import { MobilePageHeader, Page } from '../../Page'; +import { type Binding, type SheetFields } from '../../spreadsheet'; import { CellValue, CellValueText } from '../../spreadsheet/CellValue'; import { MOBILE_NAV_HEIGHT } from '../MobileNavTabs'; import { PullToRefresh } from '../PullToRefresh'; -function AccountHeader({ name, amount, style = {} }) { +type AccountHeaderProps> = { + name: string; + amount: Binding<'account', SheetFieldName>; + style?: CSSProperties; +}; + +function AccountHeader>({ + name, + amount, + style = {}, +}: AccountHeaderProps) { return ( {props => ( - + + {...props} + style={{ ...styles.text, fontSize: 14 }} + /> )} ); } +type AccountCardProps = { + account: AccountEntity; + updated: boolean; + connected: boolean; + pending: boolean; + failed: boolean; + getBalanceQuery: (account: AccountEntity) => Binding<'account', 'balance'>; + onSelect: (id: string) => void; +}; + function AccountCard({ account, updated, @@ -63,7 +88,7 @@ function AccountCard({ failed, getBalanceQuery, onSelect, -}) { +}: AccountCardProps) { return (