Skip to content

Commit

Permalink
Update balances on account edit
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Ferreira committed Dec 9, 2017
1 parent 2803647 commit ce92bd9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions application/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ def create_account():
return jsonify(message="Account with that IBAN already exists"), 409

return jsonify(
id=account.id
id=account.id,
balances=get_balances()
)


Expand All @@ -202,7 +203,7 @@ def edit_account():
return jsonify(message="Account with that IBAN already exists"), 409

return jsonify(
id=account.first().id
balances=get_balances()
)


Expand Down
6 changes: 5 additions & 1 deletion static/src/actions/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
edit_account,
delete_account
} from '../utils/http_functions'
import { receiveBalancesData } from './balances'
import { logoutAndRedirect } from './auth'

export function receiveAccountsData(data) {
Expand Down Expand Up @@ -66,6 +67,7 @@ export function createAccount(token, account) {
.then(parseJSON)
.then(response => {
dispatch(selectAccount(response.id))
dispatch(receiveBalancesData(response.balances))
})
.catch(error => {
if (error.status === 401) {
Expand All @@ -87,7 +89,9 @@ export function editAccount(token, account) {
account.projected_date
)
.then(parseJSON)
.then(response => {})
.then(response => {
dispatch(receiveBalancesData(response.balances))
})
.catch(error => {
if (error.status === 401) {
dispatch(logoutAndRedirect(error))
Expand Down
2 changes: 0 additions & 2 deletions static/src/components/AccountsSideList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,12 @@ export default class AccountsSideList extends React.Component {
createAccount(account) {
const token = this.props.token
this.props.createAccount(token, account)
this.props.updateBalance()
this.fetchData()
}

editAccount(account) {
const token = this.props.token
this.props.editAccount(token, account)
this.props.updateBalance()
this.fetchData()
}

Expand Down

0 comments on commit ce92bd9

Please sign in to comment.