diff --git a/app/components/DepositWithdraw/DepositWithdrawAssetSelector.js b/app/components/DepositWithdraw/DepositWithdrawAssetSelector.js
index 9ce470b9f5..5c94e89a1c 100644
--- a/app/components/DepositWithdraw/DepositWithdrawAssetSelector.js
+++ b/app/components/DepositWithdraw/DepositWithdrawAssetSelector.js
@@ -2,76 +2,141 @@ import React from "react";
import {connect} from "alt-react";
import BindToChainState from "../Utility/BindToChainState";
import GatewayStore from "stores/GatewayStore";
-import TypeAhead from "../Utility/TypeAhead";
import counterpart from "counterpart";
+import {Select} from "bitshares-ui-style-guide";
class DepositWithdrawAssetSelector extends React.Component {
constructor(props) {
super(props);
- }
- render() {
- const {props} = this;
- const {include} = props;
- let idMap = {};
-
- let getCoinOption = item => {
- /* Gateway Specific Settings */
- let [gateway, backedCoin] = item.symbol.split(".");
-
- // Return null if backedCoin is already stored
- if (!idMap[backedCoin] && backedCoin && gateway) {
- idMap[backedCoin] = true;
-
- return {
- id: backedCoin,
- label: backedCoin,
- gateway: gateway,
- gateFee: item.gateFee,
- issuer: item.issuerId || "1.2.96397" //Fall back to open ledger
- };
- } else {
- return null;
- }
+ this.state = {
+ assets: []
};
+ }
- let coinArr = [];
+ componentDidMount() {
+ this.getAssets();
+ }
- if (!(this.props.includeBTS === false)) {
- coinArr.push({id: "BTS", label: "BTS", gateway: ""});
- }
+ getAssets() {
+ let {backedCoins, include, includeBTS} = this.props;
+ let {assets} = this.state;
- props.backedCoins.forEach(coin => {
- coinArr = coinArr
- .concat(coin.map(getCoinOption))
- .filter(item => {
- return item;
+ let idMap = {};
+
+ backedCoins.forEach(coin => {
+ assets = assets
+ .concat(coin.map(
+ item => {
+ /* Gateway Specific Settings */
+ let [gateway, backedCoin] = item.symbol.split(".");
+
+ // Return null if backedCoin is already stored
+ if (!idMap[backedCoin] && backedCoin && gateway) {
+ idMap[backedCoin] = true;
+
+ return {
+ id: backedCoin,
+ label: backedCoin,
+ gateway: gateway,
+ gateFee: item.gateFee,
+ issuer: item.issuerId || "1.2.96397" //Fall back to open ledger
+ };
+ } else {
+ return null;
+ }
+ }
+ ))
+ .filter(item => {
+ return item;
})
.filter(item => {
- if (item.id == "BTS") return true;
- if (include) {
- return include.includes(item.id);
- }
+ if (item.id == "BTS") { return true; }
+ if (include) { return include.includes(item.id); }
return true;
});
});
- let coinItems = coinArr.sort(function(a, b) {
- if (a.id && b.id) return a.id.localeCompare(b.id);
+ if (!(includeBTS === false)) {
+ assets.push({id: "BTS", label: "BTS", gateway: ""});
+ }
+
+ this.setState({
+ assets: assets
});
- let i18n =
- props.usageContext == "withdraw"
- ? "gateway.asset_search_withdraw"
- : "gateway.asset_search_deposit";
+ }
+
+ getSelectedAssetArray(selectedAsset) {
+ let {assets} = this.state;
+
+ let asset;
+
+ assets.map(a => {
+ if(a.id == selectedAsset) {
+ asset = a;
+ }
+ });
+
+ return asset;
+ }
+
+ _onSelect(selectedAsset) {
+ let {onSelect} = this.props;
+ let asset = this.getSelectedAssetArray(selectedAsset);
+
+ if(onSelect) {
+ onSelect(asset);
+ }
+ }
+
+ _onInputChanged(selectedAsset) {
+ let {onChange} = this.props;
+ let asset = this.getSelectedAssetArray(selectedAsset);
+
+ if(onChange) {
+ onChange(asset.id);
+ }
+ }
+
+ render() {
+ let {usageContext} = this.props;
+
+ let coinItems = this.state.assets.sort(function(a, b) {
+ if (a.id && b.id) return a.id.localeCompare(b.id);
+ });
return (
-