X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FFront.git;a=blobdiff_plain;f=cmd%2Fweb%2Fjs%2Faccount.jsx;h=3dc8afd084b48551ca7e2a673fed7781db2178d7;hp=c80be33ecfa605878648d1c9b15983c643121a80;hb=d1c0ccfcb84f1b8778e38b027a333d03e1f4ae9e;hpb=36942af3bf6eec57c4bebd6c373fe58e6323bce4 diff --git a/cmd/web/js/account.jsx b/cmd/web/js/account.jsx index c80be33..3dc8afd 100644 --- a/cmd/web/js/account.jsx +++ b/cmd/web/js/account.jsx @@ -1,15 +1,68 @@ import Api from './api.js'; import React from 'react'; +import classnames from 'classnames'; + +class Panel extends React.Component { + render = () => { + if (this.props.component === null) { + return
; + } + + var className = classnames('row', this.props.topClassName); + + return ( +
+
+
+
{this.props.title}
+
+
+ {this.props.component} +
+
); + } +} + +class AccountInformation extends React.Component { + constructor(props) { + super(props); + this.state = {'email': null}; + } + + loadAccount = () => { + Api.Call('USER_ACCOUNT', {}, function(err, status, data) { + if (err) { + console.error(err, data); + return; + } + + this.setState({'email': data.email}); + }.bind(this)); + } + + componentDidMount = () => { + this.loadAccount(); + } + + render = () => { + var component =

Loading...

; + if (this.state.email !== null) { + component =

Email: {this.state.email}

; + } + + return component; + } + +} class PoloniexConfiguration extends React.Component { constructor(props) { super(props); - this.state = {'apiKey': '', 'apiSecret': '', 'apiRequested': false, 'status': 'loading', 'editMode': false}; + this.state = {'apiKey': '', 'apiSecret': '', 'status': 'loading', 'editMode': false}; } checkCredentials = () => { Api.Call('MARKET_TEST_CREDENTIALS', {'name': 'poloniex'}, function(err, status, data) { - this.setState({'apiRequested': true}); if (err) { console.error(err, data); if (err.code === 'invalid_market_credentials') { @@ -53,7 +106,7 @@ class PoloniexConfiguration extends React.Component { onEditClick = () => { Api.Call('MARKET', {'name': 'poloniex'}, function(err, status, data) { - this.setState({'apiRequested': true, 'editMode': true}); + this.setState({'editMode': true}); if (err) { console.error(err, data); return; @@ -90,11 +143,8 @@ class PoloniexConfiguration extends React.Component { console.error('unknown status', this.state.status); displayText = null; } - if (this.state.apiRequested === false) { - return
; - } + return ( -
-
); } } @@ -140,33 +189,40 @@ class PoloniexCredentialsForm extends React.Component { } return ( -
-
- Poloniex credentials -
-
-
- {this.props.statusMessage} -
-
-
-
-
- - - - -
-
-
+ +
+
+ {this.props.statusMessage}
+
+
+
+ + + + +
+
+
+
); } } -export default PoloniexConfiguration; +class UserAccount extends React.Component { + render = () => { + return ( + + } title="Account" /> + } title="Poloniex credentials" topClassName="api-credentials-form" /> + + ); + } +} + +export default UserAccount;