diff --git a/assets/scripts/config.js b/assets/scripts/config.js index 5f6e382..955301b 100644 --- a/assets/scripts/config.js +++ b/assets/scripts/config.js @@ -1,3 +1,3 @@ const config = { - 'iguanaPort': 7778 + 'iguanaPort': 7772 }; diff --git a/assets/scripts/login.js b/assets/scripts/login.js index 5f83f0c..28708b6 100644 --- a/assets/scripts/login.js +++ b/assets/scripts/login.js @@ -2,8 +2,8 @@ const toastrConfig = { 'closeButton': true, 'debug': false, 'positionClass': 'toast-bottom-right', - 'showDuration': '5000', - 'hideDuration': '1000', + 'showDuration': '15000', + 'hideDuration': '11000', 'timeOut': '5000', 'extendedTimeOut': '1000', 'showEasing': 'swing', diff --git a/react/src/actions/actionCreators.js b/react/src/actions/actionCreators.js index 1240837..9be7561 100644 --- a/react/src/actions/actionCreators.js +++ b/react/src/actions/actionCreators.js @@ -1,3 +1,20 @@ import 'whatwg-fetch'; -export const ACTION = 'ACTION'; +export const TOASTER_MESSAGE = 'TOASTER_MESSAGE'; + +function triggerToaster(display, message) { + return { + type: TOASTER_MESSAGE, + display, + message, + } +} + +export function addCoin(coin, mode) { + return dispatch => { + dispatch(triggerToaster(true, 'Coin ' + coin + ' added in ' + mode)) + /*return fetch(``) + .then(response => response.json()) + .then(json => dispatch(r(json)))*/ + } +} diff --git a/react/src/components/addcoin/addcoin.js b/react/src/components/addcoin/addcoin.js index 60415a1..80fc514 100644 --- a/react/src/components/addcoin/addcoin.js +++ b/react/src/components/addcoin/addcoin.js @@ -1,5 +1,7 @@ import React from 'react'; import { translate } from '../../translate/translate'; +import { addCoin } from '../../actions/actionCreators'; +import Store from '../../store'; class AddCoin extends React.Component { constructor(props) { @@ -18,30 +20,40 @@ class AddCoin extends React.Component { disabled: true, checked: false, }, + mode: null, }; this.updateSelectedCoin = this.updateSelectedCoin.bind(this); this.updateSelectedMode = this.updateSelectedMode.bind(this); this.setNativeMode = this.setNativeMode.bind(this); this.setBasiliskMode = this.setBasiliskMode.bind(this); this.setFullMode = this.setFullMode.bind(this); + this.activateCoin = this.activateCoin.bind(this); } updateSelectedCoin(e) { - const coin = e.target.value.split(':'); + const coin = e.target.value.split('|'); + const defaultMode = coin[1]; + const modeToValue = { + 'full': 1, + 'basilisk': 0, + 'native': -1, + }; + this.setState(Object.assign({}, this.state, { [e.target.name]: e.target.value, fullMode: { - disabled: coin[1].indexOf('full') > -1 ? false : true, - checked: coin[1].indexOf('full') > -1 ? true : false, + disabled: e.target.value.indexOf('full') > -1 ? false : true, + checked: defaultMode === 'full' ? true : false, }, basiliskMode: { - disabled: coin[1].indexOf('basilisk') > -1 ? false : true, - checked: coin[1].indexOf('basilisk') > -1 ? true : false, + disabled: e.target.value.indexOf('basilisk') > -1 ? false : true, + checked: defaultMode === 'basilisk' ? true : false, }, nativeMode: { - disabled: coin[1].indexOf('native') > -1 ? false : true, - checked: coin[1].indexOf('native') > -1 ? true : false, - } + disabled: e.target.value.indexOf('native') > -1 ? false : true, + checked: defaultMode === 'native' ? true : false, + }, + mode: modeToValue[defaultMode] })); } @@ -59,6 +71,7 @@ class AddCoin extends React.Component { ...this.state.nativeMode, checked: _value === '-1' ? true : false, }, + mode: _value, })); } @@ -76,7 +89,6 @@ class AddCoin extends React.Component { handleForm(e) { e.preventDefault(); - //Store.dispatch((this.state)); e.target.reset(); this.setState({ mode: '', @@ -84,6 +96,11 @@ class AddCoin extends React.Component { }); } + activateCoin() { + console.log(this.state); + Store.dispatch(addCoin(this.state.selectedCoin.split('|')[0], this.state.mode)); + } + render() { return (
@@ -102,40 +119,40 @@ class AddCoin extends React.Component {