diff --git a/frontend/src/components/AccountTable/AccountTable.js b/frontend/src/components/AccountTable/AccountTable.js index 91bf909..8d78b88 100644 --- a/frontend/src/components/AccountTable/AccountTable.js +++ b/frontend/src/components/AccountTable/AccountTable.js @@ -297,26 +297,26 @@ export default function Account(props) { (state, accountId) => state.accounts.entities[accountId] ? state.accounts.entities[accountId].transactions.entities : [], (state, accountId, reconciled) => reconciled, - (state, accountId, reconciled, addingTransaction) => addingTransaction, + // (state, accountId, reconciled, addingTransaction) => addingTransaction, ], (transactions, reconciled) => { const retval = [] - if (addingTransaction) { - const now = new Date().toISOString() - retval.push({ - id: 0, - accountId: props.accountId, - amount: 0, - categoryId: '', - created: now, - date: now, - filterField: '', - memo: '', - payeeId: '', - status: 0, - updated: now, - }) - } + // if (addingTransaction) { + // const now = new Date().toISOString() + // retval.push({ + // id: 0, + // accountId: props.accountId, + // amount: 0, + // categoryId: '', + // created: now, + // date: now, + // filterField: '', + // memo: '', + // payeeId: '', + // status: 0, + // updated: now, + // }) + // } if (!showReconciled) { return retval.concat( @@ -343,7 +343,35 @@ export default function Account(props) { ) }, ) - const transactions = useSelector(state => selectTransactions(state, props.accountId, showReconciled)) + // const transactions = useSelector(state => selectTransactions(state, props.accountId, showReconciled)) + + const selectTransactionsData = createSelector( + [selectTransactions, (state, accountId, reconciled, addingTransaction) => addingTransaction], + (transactions, addingTransaction) => { + if (addingTransaction) { + const now = new Date().toISOString() + transactions.push({ + id: 0, + accountId: props.accountId, + amount: 0, + categoryId: '', + created: now, + date: now, + filterField: '', + memo: '', + payeeId: '', + status: 0, + updated: now, + }) + } + + return transactions + }, + ) + + const transactions = useSelector(state => + selectTransactionsData(state, props.accountId, showReconciled, addingTransaction), + ) const data = useMemo(() => transactions, [transactions, account]) const cancelAddTransaction = () => { @@ -400,8 +428,6 @@ export default function Account(props) { return option }} - // renderOption={(props, option) =>