diff --git a/src/common/components/suggestion-list/_index.scss b/src/common/components/suggestion-list/_index.scss index a7dcaa3320f..11003543997 100644 --- a/src/common/components/suggestion-list/_index.scss +++ b/src/common/components/suggestion-list/_index.scss @@ -72,7 +72,6 @@ &:hover, &:focus { - background: $metallic-blue; color: $white; } } @@ -143,7 +142,6 @@ display: flex; align-items: center; white-space: nowrap; - width: 20px; &:last-child { border-bottom-left-radius: $border-radius; @@ -165,7 +163,6 @@ &:hover, &:focus { - background: $metallic-blue; color: $white; } } diff --git a/src/common/components/transfer/index.tsx b/src/common/components/transfer/index.tsx index 88556d2d370..554857690ce 100644 --- a/src/common/components/transfer/index.tsx +++ b/src/common/components/transfer/index.tsx @@ -155,7 +155,7 @@ interface State { to: string; toData: Account | null; toError: string; - toExchangeError: string; + exchangeWarning: string; memoError: string; toWarning: string; amount: string; @@ -189,7 +189,7 @@ const pureState = (props: Props): State => { to: props.to || _to, toData: props.to ? { name: props.to } : _toData, toError: "", - toExchangeError: "", + exchangeWarning: "", memoError: "", toWarning: "", amount: props.amount || "0.001", @@ -221,30 +221,38 @@ export class Transfer extends BaseComponent { } assetChanged = (asset: TransferAsset) => { + const { to, memo } = this.state; this.stateSet({ asset }, () => { this.checkAmount(); + this.exchangeHandler(to, memo); }); }; + exchangeHandler = (to: string, memo: string) => { + const { asset } = this.state; + + if (exchangeAccounts.includes(to)) { + if (asset !== "HIVE") { + this.stateSet({ exchangeWarning: _t("transfer.invalid-asset") }); + } else if (asset === "HIVE" && !memo) { + this.stateSet({ exchangeWarning: _t("transfer.memo-required") }); + } else { + this.stateSet({ exchangeWarning: "" }); + } + } + }; + toChanged = (e: React.ChangeEvent) => { const { value: to } = e.target; + const { memo } = this.state; this.stateSet({ to }, this.handleTo); - // Check memo if to is an exchange account - if (exchangeAccounts.includes(to)) { - this.stateSet({ toExchangeError: _t("transfer.memo-required") }); - } else { - this.stateSet({ toExchangeError: "" }); - } + this.exchangeHandler(to, memo); }; toSelected = (to: string) => { this.stateSet({ to }, this.handleTo); - // Check memo if selected is an exchange account - if (exchangeAccounts.includes(to)) { - this.stateSet({ toExchangeError: _t("transfer.memo-required") }); - } else { - this.stateSet({ toExchangeError: "" }); - } + const { memo } = this.state; + this.exchangeHandler(to, memo); }; amountChanged = (e: React.ChangeEvent): void => { @@ -256,18 +264,11 @@ export class Transfer extends BaseComponent { memoChanged = (e: React.ChangeEvent): void => { const { value: memo } = e.target; + const { to } = this.state; const mError = cryptoUtils.isWif(memo.trim()); if (mError) this.setState({ memoError: _t("transfer.memo-error").toUpperCase() }); this.stateSet({ memo }); - if (memo) { - { - this.stateSet({ toExchangeError: "" }); - } - } else { - { - this.stateSet({ toExchangeError: _t("transfer.memo-required") }); - } - } + this.exchangeHandler(to, memo); }; handleTo = () => { @@ -431,15 +432,15 @@ export class Transfer extends BaseComponent { }; canSubmit = () => { - const { toData, toError, amountError, memoError, inProgress, amount, toExchangeError } = + const { toData, toError, amountError, memoError, inProgress, amount, exchangeWarning } = this.state; return ( toData && - !toExchangeError && !toError && !amountError && !memoError && !inProgress && + !exchangeWarning && parseFloat(amount) > 0 ); }; @@ -677,7 +678,7 @@ export class Transfer extends BaseComponent { asset, to, toError, - toExchangeError, + exchangeWarning, toWarning, amount, amountError, @@ -900,7 +901,7 @@ export class Transfer extends BaseComponent { {toWarning && } {toError && } - {toExchangeError && } + {exchangeWarning && } )} diff --git a/src/common/i18n/locales/en-US.json b/src/common/i18n/locales/en-US.json index 21aae09d039..e76a71991bd 100644 --- a/src/common/i18n/locales/en-US.json +++ b/src/common/i18n/locales/en-US.json @@ -1227,6 +1227,7 @@ "memo-help": "This memo is public", "memo-error": "Never put private keys into a memo field, it is publicly visible to everyone.", "memo-required": "Transfer to an exchange must have a memo.", + "invalid-asset": "You can only send HIVE to an exchange account.", "available-hp-hint": "* available hive power", "override-warning-1": "The new amount overrides the previous one.", "override-warning-2": "Account ({{account}}) has already been delegated with {{previousAmount}}.",