fixed (hacky fix) bug to find payee by name due to onInputChange 'bug'

This commit is contained in:
Alex Phillips 2021-11-19 19:12:59 -05:00
parent a1a4dc0900
commit 37817d5679

View File

@ -114,7 +114,7 @@ export default function Account(props) {
memo: newRow.memo,
payeeId: newRow.payeeId,
categoryId: newRow.categoryId,
status: 0, // @TODO: fix
status: 0, // @TODO: implement transaction status
}
}))
@ -126,13 +126,15 @@ export default function Account(props) {
const onTransactionEdit = async (newData, oldData) => {
if (!payeesMap[newData.payeeId]) {
// Because of the 'onInputChange' autocomplete, the edited value gets subbed out for the 'text' value. Make sure this doesn't truly already exist.
const payee = Object.values(payeesMap).filter(payee => payee.name === newData.payeeId)
if (payee.length === 0) {
console.log(payeesMap)
console.log(newData.payeeId)
// @TODO: Fix : Because of the 'onInputChange' autocomplete, the edited value gets subbed out for the 'text' value. Make sure this doesn't truly already exist.
const payee = Object.keys(payeesMap).find(key => payeesMap[key] === newData.payeeId)
if (!payee) {
console.log('creating new payee')
newData.payeeId = (await createNewPayee(newData.payeeId)).id
} else {
newData.payeeId = payee[0].id
newData.payeeId = payee
}
}