|
@@ -1,9 +1,15 @@
|
|
|
import React from 'react'
|
|
|
-import { Layout, Loading, Main } from './components'
|
|
|
+import { Layout, Loading, Main, Modals } from './components'
|
|
|
import { withRouter } from 'react-router-dom'
|
|
|
import socket from './socket'
|
|
|
|
|
|
-const initialState = { loading: true, blocks: [], timestamp: 0 }
|
|
|
+const initialState = {
|
|
|
+ loading: true,
|
|
|
+ blocks: [],
|
|
|
+ timestamp: 0,
|
|
|
+ modal: null,
|
|
|
+ validator: null,
|
|
|
+}
|
|
|
|
|
|
class App extends React.Component {
|
|
|
initializeSocket() {
|
|
@@ -20,12 +26,37 @@ class App extends React.Component {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ setShowModal(showModal) {
|
|
|
+ this.setState({ showModal })
|
|
|
+ }
|
|
|
+ showValidator(account) {
|
|
|
+ //const validator = this.state.validators.find((v) => v.account === account)
|
|
|
+ //if (!validator) return
|
|
|
+
|
|
|
+ this.setState({ validator: { account } })
|
|
|
+ this.setShowModal('validator')
|
|
|
+ }
|
|
|
+
|
|
|
renderError() {
|
|
|
if (this.state.showModal === 'Error') return
|
|
|
this.setShowModal('Error')
|
|
|
}
|
|
|
renderApp() {
|
|
|
- return <Main {...this.state} />
|
|
|
+ return (
|
|
|
+ <div>
|
|
|
+ <Modals
|
|
|
+ setShowModal={this.setShowModal}
|
|
|
+ showModal={this.state.showModal}
|
|
|
+ validator={this.state.validator}
|
|
|
+ blocks={this.state.blocks}
|
|
|
+ />
|
|
|
+ <Main
|
|
|
+ setShowModal={this.setShowModal}
|
|
|
+ showValidator={this.showValidator}
|
|
|
+ {...this.state}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ )
|
|
|
}
|
|
|
render() {
|
|
|
if (this.state.loading) return <Loading />
|
|
@@ -44,6 +75,8 @@ class App extends React.Component {
|
|
|
constructor() {
|
|
|
super()
|
|
|
this.state = initialState
|
|
|
+ this.setShowModal = this.setShowModal.bind(this)
|
|
|
+ this.showValidator = this.showValidator.bind(this)
|
|
|
}
|
|
|
}
|
|
|
|