Skip to content

Commit

Permalink
#3567 Update collateral amount in case user tries to add duplicated c…
Browse files Browse the repository at this point in the history
…ollateral
  • Loading branch information
ihorml authored and sschiessl-bcp committed Nov 28, 2022
1 parent e9706fd commit edc22e6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
21 changes: 14 additions & 7 deletions app/components/Account/CreditOffer/CreateModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,20 @@ class CreateModal extends React.Component {
if (typeof pawn_asset !== "object") {
pawn_asset = ChainStore.getAsset(pawn_asset);
}
pawn_assets.push(
new Asset({
real: pawn_price,
asset_id: pawn_asset.get("id"),
precision: pawn_asset.get("precision")
})
);
let found = pawn_assets.find((asset) => {
return asset.asset_id === pawn_asset.get('id')
})
if(found) {
found.setAmount({ real: pawn_price })
} else {
pawn_assets.push(
new Asset({
real: pawn_price,
asset_id: pawn_asset.get("id"),
precision: pawn_asset.get("precision")
})
);
}
this.setState({pawn_assets: pawn_assets, showModal: 1});
} else {
this.setState({showModal: 1});
Expand Down
21 changes: 14 additions & 7 deletions app/components/Account/CreditOffer/EditModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,20 @@ class EditModal extends React.Component {
if (typeof pawn_asset !== "object") {
pawn_asset = ChainStore.getAsset(pawn_asset);
}
pawn_assets.push(
new Asset({
real: pawn_price,
asset_id: pawn_asset.get("id"),
precision: pawn_asset.get("precision")
})
);
let found = pawn_assets.find((asset) => {
return asset.asset_id === pawn_asset.get('id')
})
if(found) {
found.setAmount({ real: pawn_price })
} else {
pawn_assets.push(
new Asset({
real: pawn_price,
asset_id: pawn_asset.get("id"),
precision: pawn_asset.get("precision")
})
);
}
this.setState({pawn_assets: pawn_assets, showModal: 1});
} else {
this.setState({showModal: 1});
Expand Down

0 comments on commit edc22e6

Please sign in to comment.