Skip to content

Commit

Permalink
Fix bitshares#460 transfer qty validation issue (bitshares#466)
Browse files Browse the repository at this point in the history
* [460] fix transfer qty validation issue

* [460] fix transfer toaccount validation issue

* [460] refactor classnames instead of string superposition
  • Loading branch information
ariesjia authored and svk31 committed Sep 29, 2017
1 parent d4f4162 commit 0e435a5
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions app/components/Transfer/Transfer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import Immutable from "immutable";
import {ChainStore} from "bitsharesjs/es";
import {connect} from "alt-react";
import { checkFeeStatusAsync, checkBalance } from "common/trxHelper";
import { debounce } from "lodash";
import { debounce, isNaN } from "lodash";
import classnames from "classnames";
import { Asset } from "common/MarketClasses";

class Transfer extends React.Component {
Expand Down Expand Up @@ -358,10 +359,10 @@ class Transfer extends React.Component {
}

let propose_incomplete = propose && ! propose_account;
let submitButtonClass = "button float-right no-margin";
if(!from_account || !to_account || !amount || amount === "0"|| !asset || from_error || propose_incomplete || balanceError)
submitButtonClass += " disabled";

const amountValue = parseFloat(String.prototype.replace.call(amount, /,/g, ""));
const isAmountValid = amountValue && !isNaN(amountValue);
const isToAccountValid = to_account && to_account.get("name") === to_name;
const isSendNotValid = !from_account || !isToAccountValid || !isAmountValid || !asset || from_error || propose_incomplete || balanceError;
let accountsList = Immutable.Set();
accountsList = accountsList.add(from_account);
let tabIndex = 1;
Expand Down Expand Up @@ -440,10 +441,10 @@ class Transfer extends React.Component {
error={this.state.hasPoolBalance === false ? "transfer.errors.insufficient" : null}
/>
{propose ?
<button className={submitButtonClass} type="submit" value="Submit" tabIndex={tabIndex++}>
<button className={classnames("button float-right no-margin", {disabled: isSendNotValid})} type="submit" value="Submit" tabIndex={tabIndex++}>
<Translate component="span" content="propose" />
</button> :
<button className={submitButtonClass} type="submit" value="Submit" tabIndex={tabIndex++}>
<button className={classnames("button float-right no-margin", {disabled: isSendNotValid})} type="submit" value="Submit" tabIndex={tabIndex++}>
<Translate component="span" content="transfer.send" />
</button>
}
Expand Down

0 comments on commit 0e435a5

Please sign in to comment.