mirror of
https://github.com/linuxserver/budge.git
synced 2026-02-05 12:47:16 +08:00
update budget on account add and transaction remove
This commit is contained in:
parent
af359bec50
commit
ef54c3a448
@ -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())
|
||||
|
||||
@ -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 (
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user