update budget on account add and transaction remove

This commit is contained in:
Alex Phillips 2021-11-25 14:27:39 -05:00
parent af359bec50
commit ef54c3a448
2 changed files with 5 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import { createAccount } from '../redux/slices/Accounts';
import { useSelector, useDispatch } from 'react-redux'
import MenuItem from '@mui/material/MenuItem';
import { fetchCategories } from '../redux/slices/Categories';
import { refreshBudget } from '../redux/slices/Budgets';
const accountTypes = ['Bank', 'Credit Card'];
@ -31,13 +32,14 @@ export default function AddAccountDialog(props) {
const budgetId = useSelector(state => state.budgets.activeBudget.id)
const handleCreateAccount = async () => {
console.log('here')
await dispatch(createAccount({
name,
accountType,
balance,
}))
dispatch(refreshBudget())
// If adding a credit card, update all categories since we have added a payment category for it
if (accountType === accountTypes[1]) {
dispatch(fetchCategories())

View File

@ -182,7 +182,7 @@ export default function Account(props) {
memo: newRow.memo,
payeeId: newRow.payeeId,
categoryId: newRow.categoryId,
status: 0, // @TODO: implement transaction status
status: 0,
}
}))
@ -252,6 +252,7 @@ export default function Account(props) {
await dispatch(fetchBudgetMonth({ month: formatMonthFromDateString(transaction.date) }))
dispatch(fetchCategoryMonths({ categoryId: transaction.categoryId }))
dispatch(fetchAccounts())
dispatch(refreshBudget())
}
return (