mirror of https://gitlab.com/ecentrics/concordia
Ezerous
6 years ago
16 changed files with 185 additions and 125 deletions
@ -0,0 +1,4 @@ |
|||
body { |
|||
margin: 10em; |
|||
padding: 0; |
|||
} |
@ -1,17 +0,0 @@ |
|||
import React from "react"; |
|||
import { AccountData, ContractData } from "drizzle-react-components"; |
|||
|
|||
export default ({ accounts }) => ( |
|||
<div className="App"> |
|||
<div className="section"> |
|||
<h1>Active Account</h1> |
|||
<AccountData accountIndex="0" units="ether" precision="3" /> |
|||
</div> |
|||
<div className="section"> |
|||
<h1>Has user signed up?</h1> |
|||
<p> |
|||
<ContractData contract="Forum" method="hasUserSignedUp" methodArgs={[accounts[0],{from: accounts[0]}]} /> |
|||
</p> |
|||
</div> |
|||
</div> |
|||
); |
@ -0,0 +1,57 @@ |
|||
import React, { Component } from 'react'; |
|||
import { push } from 'connected-react-router' |
|||
import PropTypes from 'prop-types'; |
|||
|
|||
import { Image, Menu } from 'semantic-ui-react' |
|||
|
|||
import logo from '../resources/logo.png'; |
|||
import {bindActionCreators} from "redux"; |
|||
import {connect} from "react-redux"; |
|||
|
|||
class NavBar extends Component { |
|||
constructor(props){ |
|||
super(props); |
|||
|
|||
// this.handleItemClick = this.handleItemClick.bind(this);
|
|||
|
|||
this.navRef = React.createRef(); |
|||
} |
|||
|
|||
|
|||
render() { |
|||
return ( |
|||
<Menu fixed='top' inverted> |
|||
<Menu.Item onClick={() => {this.props.navigateTo('/')}}> |
|||
<Image |
|||
size='mini' |
|||
src={logo} |
|||
style={{ marginRight: '1.5em' }} |
|||
/> |
|||
Apella |
|||
</Menu.Item> |
|||
<Menu.Item onClick={() => {this.props.navigateTo('/signup')}}> |
|||
SignUp |
|||
</Menu.Item> |
|||
</Menu> |
|||
); |
|||
} |
|||
} |
|||
|
|||
NavBar.contextTypes = { |
|||
router: PropTypes.object |
|||
}; |
|||
|
|||
const mapDispatchToProps = dispatch => bindActionCreators({ |
|||
navigateTo: (location) => push(location) |
|||
}, dispatch); |
|||
|
|||
|
|||
const mapStateToProps = state => { |
|||
return { |
|||
hasSignedUp: state.user.hasSignedUp, |
|||
} |
|||
}; |
|||
|
|||
//export default drizzleConnect(NavBar, mapStateToProps, mapDispatchToProps);
|
|||
|
|||
export default connect(mapStateToProps, mapDispatchToProps)(NavBar); |
@ -0,0 +1,46 @@ |
|||
import React, { Component } from 'react'; |
|||
|
|||
import { Header } from 'semantic-ui-react'; |
|||
import {bindActionCreators} from "redux"; |
|||
import {push} from "connected-react-router"; |
|||
import {connect} from "react-redux"; |
|||
|
|||
class SignUp extends Component { |
|||
render() { |
|||
return ( |
|||
this.props.user.hasSignedUp |
|||
?(<div className="vertical-center-in-parent"> |
|||
<Header color='teal' textAlign='center' as='h2'> |
|||
There is already an account for this addresss. |
|||
</Header> |
|||
<Header color='teal' textAlign='center' as='h4'> |
|||
If you want to create another account please change your address. |
|||
</Header> |
|||
</div>) |
|||
:(<div className="sign-up-container"> |
|||
<div> |
|||
<h1>Sign Up</h1> |
|||
<p className="no-margin"> |
|||
<strong>Account address:</strong> {this.props.user.address} |
|||
</p> |
|||
UsernameFormContainer |
|||
</div> |
|||
</div>) |
|||
); |
|||
} |
|||
} |
|||
const mapDispatchToProps = dispatch => bindActionCreators({ |
|||
navigateTo: () => push() |
|||
}, dispatch); |
|||
|
|||
|
|||
const mapStateToProps = state => { |
|||
return { |
|||
user: state.user |
|||
} |
|||
}; |
|||
|
|||
const SignUpContainer = connect(mapStateToProps, mapDispatchToProps)(SignUp); |
|||
|
|||
export default SignUpContainer; |
|||
|
@ -1,30 +1,21 @@ |
|||
import React from "react"; |
|||
import { render } from "react-dom"; |
|||
import { DrizzleProvider } from "drizzle-react"; |
|||
import { LoadingContainer } from "drizzle-react-components"; |
|||
import drizzleOptions from "./config/drizzleOptions"; |
|||
import React from 'react'; |
|||
import { render } from 'react-dom'; |
|||
import { Provider } from 'react-redux'; |
|||
import { ConnectedRouter } from 'connected-react-router' |
|||
import routerStore, {history} from './redux/routerStore'; |
|||
import drizzleStore from './redux/drizzleStore'; |
|||
import routes from './router/routes' |
|||
|
|||
import * as serviceWorker from "./utils/serviceWorker"; |
|||
import {Provider} from "react-redux"; |
|||
import store, {history} from './redux/store'; |
|||
import routes from './routes' |
|||
import * as serviceWorker from './utils/serviceWorker'; |
|||
|
|||
import './assets/css/index.css'; |
|||
|
|||
render( |
|||
<DrizzleProvider options={drizzleOptions} store={drizzleStore}> |
|||
<Provider store={routerStore}> |
|||
<LoadingContainer> |
|||
<ConnectedRouter history={history}> |
|||
{ routes } |
|||
</ConnectedRouter> |
|||
</LoadingContainer> |
|||
</Provider> |
|||
</DrizzleProvider>, |
|||
<Provider store={store}> |
|||
<ConnectedRouter history={history}> |
|||
{ routes } |
|||
</ConnectedRouter> |
|||
</Provider>, |
|||
document.getElementById('root') |
|||
); |
|||
|
|||
// If you want your app to work offline and load faster, you can change
|
|||
// unregister() to register() below. Note this comes with some pitfalls.
|
|||
// Learn more about service workers: http://bit.ly/CRA-PWA
|
|||
serviceWorker.unregister(); |
|||
serviceWorker.unregister(); // See also: http://bit.ly/CRA-PWA
|
|||
|
@ -1,10 +0,0 @@ |
|||
import { combineReducers } from 'redux'; |
|||
import { drizzleReducers } from 'drizzle'; |
|||
import userReducer from "./userReducer"; |
|||
|
|||
const reducer = combineReducers({ |
|||
user: userReducer, |
|||
...drizzleReducers |
|||
}); |
|||
|
|||
export default reducer; |
@ -0,0 +1,10 @@ |
|||
import { combineReducers } from 'redux'; |
|||
import { drizzleReducers } from 'drizzle'; |
|||
import { connectRouter } from 'connected-react-router' |
|||
import userReducer from './userReducer'; |
|||
|
|||
export default (history) => combineReducers({ |
|||
router: connectRouter(history), |
|||
user: userReducer, |
|||
...drizzleReducers |
|||
}) |
@ -1,6 +0,0 @@ |
|||
import { combineReducers } from 'redux'; |
|||
import { connectRouter } from 'connected-react-router' |
|||
|
|||
export default (history) => combineReducers({ |
|||
router: connectRouter(history) |
|||
}) |
@ -1,27 +0,0 @@ |
|||
import { createBrowserHistory } from 'history' |
|||
import { createStore, applyMiddleware, compose } from 'redux'; |
|||
import { routerMiddleware } from 'connected-react-router' |
|||
|
|||
import createRootReducer from './reducers/routerReducer'; |
|||
|
|||
export const history = createBrowserHistory(); |
|||
|
|||
const rootReducer = createRootReducer(history); |
|||
|
|||
const initialState = {}; |
|||
|
|||
// Redux DevTools
|
|||
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; |
|||
|
|||
const routingMiddleware = routerMiddleware(history); |
|||
|
|||
|
|||
const composedEnhancers = composeEnhancers(applyMiddleware(routingMiddleware)); |
|||
|
|||
const routerStore = createStore( |
|||
rootReducer, |
|||
initialState, |
|||
composedEnhancers |
|||
); |
|||
|
|||
export default routerStore; |
@ -1,6 +1,6 @@ |
|||
import { all, fork } from 'redux-saga/effects' |
|||
import { drizzleSagas } from 'drizzle' |
|||
import userSaga from "./userSaga"; |
|||
import userSaga from './userSaga'; |
|||
|
|||
export default function* root() { |
|||
let sagas = [...drizzleSagas, userSaga]; |
@ -1,25 +1,34 @@ |
|||
import { createStore, applyMiddleware, compose } from 'redux'; |
|||
import { createBrowserHistory } from 'history' |
|||
import createSagaMiddleware from 'redux-saga'; |
|||
import { generateContractsInitialState } from 'drizzle'; |
|||
import {Drizzle, generateContractsInitialState} from 'drizzle'; |
|||
import {routerMiddleware} from 'connected-react-router'; |
|||
|
|||
import drizzleReducer from './reducers/drizzleReducer'; |
|||
import rootSaga from './sagas/drizzleSaga'; |
|||
import rootSaga from './sagas/rootSaga'; |
|||
import drizzleOptions from '../config/drizzleOptions'; |
|||
import createRootReducer from './reducers/rootReducer'; |
|||
|
|||
|
|||
export const history = createBrowserHistory(); |
|||
|
|||
const rootReducer = createRootReducer(history); |
|||
|
|||
const initialState = { contracts: generateContractsInitialState(drizzleOptions) }; |
|||
|
|||
// Redux DevTools
|
|||
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; |
|||
|
|||
const sagaMiddleware = createSagaMiddleware(); |
|||
const composedEnhancers = composeEnhancers(applyMiddleware(sagaMiddleware)); |
|||
const routingMiddleware = routerMiddleware(history); |
|||
const composedEnhancers = composeEnhancers(applyMiddleware(sagaMiddleware, routingMiddleware)); |
|||
|
|||
const store = createStore( |
|||
drizzleReducer, |
|||
rootReducer, |
|||
initialState, |
|||
composedEnhancers |
|||
); |
|||
|
|||
new Drizzle(drizzleOptions, store); |
|||
|
|||
sagaMiddleware.run(rootSaga); |
|||
|
|||
export default store; |
@ -1,27 +0,0 @@ |
|||
import React from 'react' |
|||
import { Route, Switch } from 'react-router-dom' |
|||
import HomeContainer from '../containers/HomeContainer' |
|||
import NotFound from '../components/NotFound' |
|||
|
|||
const routes = ( |
|||
<div> |
|||
<Switch> |
|||
<Route exact path="/" component={HomeContainer} /> |
|||
<Route component={NotFound} /> |
|||
</Switch> |
|||
</div> |
|||
); |
|||
|
|||
export default routes |
|||
|
|||
|
|||
// const routes = (
|
|||
// <div>
|
|||
// <NavBar />
|
|||
// <Switch>
|
|||
// <Route exact path="/" component={Home} />
|
|||
// <Route path="/signup" component={SignUp} />
|
|||
// <Route component={NotFound} />
|
|||
// </Switch>
|
|||
// </div>
|
|||
// );
|
@ -0,0 +1,20 @@ |
|||
import React from 'react' |
|||
import { Route, Switch } from 'react-router-dom' |
|||
import NavBar from "./containers/NavBar"; |
|||
import HomeContainer from './containers/HomeContainer' |
|||
import SignUpContainer from './containers/SignUpContainer' |
|||
import NotFound from './components/NotFound' |
|||
|
|||
|
|||
const routes = ( |
|||
<div> |
|||
<NavBar /> |
|||
<Switch> |
|||
<Route exact path="/" component={HomeContainer} /> |
|||
<Route path="/signup" component={SignUpContainer} /> |
|||
<Route component={NotFound} /> |
|||
</Switch> |
|||
</div> |
|||
); |
|||
|
|||
export default routes |
Loading…
Reference in new issue