Skip to content

Commit

Permalink
bitshares#3575 Display error thrown during credit offer create
Browse files Browse the repository at this point in the history
  • Loading branch information
ihorml committed Nov 17, 2022
1 parent 2436807 commit a200215
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion app/components/Account/CreditOffer/CreateModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import AccountStore from "stores/AccountStore";
import SettingsStore from "stores/SettingsStore";
import {ChainStore} from "bitsharesjs";
import {
Alert,
Tooltip,
Table,
Modal,
Expand Down Expand Up @@ -46,6 +47,7 @@ class CreateModal extends React.Component {

getInitialState(props) {
return {
createOfferError: null,
showModal: 0, // 1: create modal 2: add pawn modal 3: add whitelist modal
account: props.account,
amount: "",
Expand Down Expand Up @@ -323,6 +325,9 @@ class CreateModal extends React.Component {
}

_onSubmit() {
this.setState({
createOfferError: null,
});
let {
account,
asset_id,
Expand All @@ -336,7 +341,10 @@ class CreateModal extends React.Component {
feeAmount
} = this.state;
let asset = ChainStore.getAsset(asset_id);
let opData = {
let opData;

try {
opData = {
owner_account: account.get("id"),
asset_type: asset_id,
balance: new Asset({
Expand Down Expand Up @@ -380,6 +388,12 @@ class CreateModal extends React.Component {
}),
fee_asset: feeAmount
};
} catch (err) {
this.setState({
createOfferError: err.toString()
})
return;
}
console.log("obj: ", opData);
CreditOfferActions.create(opData)
.then(() => {
Expand All @@ -388,6 +402,9 @@ class CreateModal extends React.Component {
.catch(err => {
// todo: visualize error somewhere
console.error(err);
this.setState({
createOfferError: err.toString()
})
});
}

Expand Down Expand Up @@ -670,6 +687,9 @@ class CreateModal extends React.Component {
onChange={this.onFeeChanged.bind(this)}
tabIndex={tabIndex++}
/>
{ this.state.createOfferError && (
<Alert message={this.state.createOfferError} type="warning"/>
)}
</Form>
</div>
</Modal>
Expand Down

0 comments on commit a200215

Please sign in to comment.