From 5f3a1743ab3c63d0edb233e275c4c9d421755e9e Mon Sep 17 00:00:00 2001 From: Joel Jeremy Marquez Date: Thu, 4 Apr 2024 22:20:22 -0700 Subject: [PATCH] Fix AccountName component --- .../mobile/accounts/AccountTransactions.jsx | 109 +++++++++++++----- 1 file changed, 81 insertions(+), 28 deletions(-) diff --git a/packages/desktop-client/src/components/mobile/accounts/AccountTransactions.jsx b/packages/desktop-client/src/components/mobile/accounts/AccountTransactions.jsx index 8aa3ae6d6c7..69a036571cc 100644 --- a/packages/desktop-client/src/components/mobile/accounts/AccountTransactions.jsx +++ b/packages/desktop-client/src/components/mobile/accounts/AccountTransactions.jsx @@ -13,19 +13,24 @@ import { useDebounceCallback } from 'usehooks-ts'; import { getPayees, markAccountRead, + openAccountCloseModal, + pushModal, + reopenAccount, syncAndDownload, + updateAccount, } from 'loot-core/client/actions'; import { SchedulesProvider } from 'loot-core/client/data-hooks/schedules'; import * as queries from 'loot-core/client/queries'; import { pagedQuery } from 'loot-core/client/query-helpers'; -import { listen } from 'loot-core/platform/client/fetch'; +import { listen, send } from 'loot-core/platform/client/fetch'; import { isPreviewId } from 'loot-core/shared/transactions'; import { useDateFormat } from '../../../hooks/useDateFormat'; import { useLocalPref } from '../../../hooks/useLocalPref'; import { useNavigate } from '../../../hooks/useNavigate'; import { usePreviewTransactions } from '../../../hooks/usePreviewTransactions'; -import { theme } from '../../../style'; +import { styles, theme } from '../../../style'; +import { Text } from '../../common/Text'; import { View } from '../../common/View'; import { Page } from '../../Page'; import { MobileBackButton } from '../MobileBackButton'; @@ -36,32 +41,7 @@ export function AccountTransactions({ account, pending, failed }) { return ( -
- {account.name} - - ) + } headerLeftContent={} headerRightContent={} @@ -78,6 +58,79 @@ export function AccountTransactions({ account, pending, failed }) { ); } +function AccountName({ account, pending, failed }) { + const dispatch = useDispatch(); + + const onSave = account => { + dispatch(updateAccount(account)); + }; + + const onSaveNotes = async (id, notes) => { + await send('notes-save', { id, note: notes }); + }; + + const onEditNotes = () => { + dispatch( + pushModal('notes', { + id: account.id, + name: account.name, + onSave: onSaveNotes, + }), + ); + }; + + const onCloseAccount = () => { + dispatch(openAccountCloseModal(account.id)); + }; + + const onReopenAccount = () => { + dispatch(reopenAccount(account.id)); + }; + + const onClick = () => { + dispatch( + pushModal('account-menu', { + accountId: account.id, + onSave, + onEditNotes, + onCloseAccount, + onReopenAccount, + }), + ); + }; + return ( + + {account.bankId && ( +
+ )} + + {`${account.closed ? 'Closed: ' : ''}${account.name}`} + + + ); +} + const getSchedulesTransform = memoizeOne(id => { const filter = queries.getAccountFilter(id, '_account');