Browse Source

Init routing

develop
Ezerous 6 years ago
parent
commit
f916b9ec17
  1. 8
      app/package.json
  2. 0
      app/src/components/HomeComponent.js
  3. 12
      app/src/components/NotFound.js
  4. 6
      app/src/containers/HomeContainer.js
  5. 15
      app/src/index.js
  6. 19
      app/src/redux/drizzleStore.js
  7. 0
      app/src/redux/reducers/drizzleReducer.js
  8. 6
      app/src/redux/reducers/routerReducer.js
  9. 27
      app/src/redux/routerStore.js
  10. 0
      app/src/redux/sagas/drizzleSaga.js
  11. BIN
      app/src/resources/PageNotFound.jpg
  12. BIN
      app/src/resources/ipfs_logo.png
  13. BIN
      app/src/resources/logo.png
  14. 27
      app/src/router/routes.js

8
app/package.json

@ -7,14 +7,18 @@
"url": "https://gitlab.com/Ezerous/Apella.git" "url": "https://gitlab.com/Ezerous/Apella.git"
}, },
"dependencies": { "dependencies": {
"@drizzle-utils/get-web3": "^0.1.4-alpha.0",
"@drizzle-utils/get-contract-instance": "^0.1.4-alpha.0",
"@drizzle-utils/get-accounts": "0.1.4-alpha.0", "@drizzle-utils/get-accounts": "0.1.4-alpha.0",
"@drizzle-utils/get-contract-instance": "^0.1.4-alpha.0",
"@drizzle-utils/get-web3": "^0.1.4-alpha.0",
"connected-react-router": "^6.3.1",
"drizzle": "^1.3.3", "drizzle": "^1.3.3",
"drizzle-react": "^1.2.0", "drizzle-react": "^1.2.0",
"drizzle-react-components": "^1.2.1", "drizzle-react-components": "^1.2.1",
"history": "^4.7.2",
"react": "^16.8.1", "react": "^16.8.1",
"react-dom": "^16.8.1", "react-dom": "^16.8.1",
"react-redux": "^6.0.0",
"react-router-dom": "^4.3.1",
"react-scripts": "^2.1.5", "react-scripts": "^2.1.5",
"redux": "^4.0.1", "redux": "^4.0.1",
"redux-saga": "^0.16.0" "redux-saga": "^0.16.0"

0
app/src/components/AppComponent.js → app/src/components/HomeComponent.js

12
app/src/components/NotFound.js

@ -0,0 +1,12 @@
import React from 'react';
import pageNotFound from '../resources/PageNotFound.jpg';
const NotFound = () => {
return (
<div style={{textAlign: "center"}}>
<img src={pageNotFound} alt="Page not found!"/>
</div>
);
};
export default NotFound;

6
app/src/containers/AppContainer.js → app/src/containers/HomeContainer.js

@ -1,4 +1,4 @@
import AppComponent from "../components/AppComponent"; import HomeComponent from "../components/HomeComponent";
import { drizzleConnect } from "drizzle-react"; import { drizzleConnect } from "drizzle-react";
const mapStateToProps = state => { const mapStateToProps = state => {
@ -9,6 +9,6 @@ const mapStateToProps = state => {
}; };
}; };
const AppContainer = drizzleConnect(AppComponent, mapStateToProps); const HomeContainer = drizzleConnect(HomeComponent, mapStateToProps);
export default AppContainer; export default HomeContainer;

15
app/src/index.js

@ -3,16 +3,23 @@ import { render } from "react-dom";
import { DrizzleProvider } from "drizzle-react"; import { DrizzleProvider } from "drizzle-react";
import { LoadingContainer } from "drizzle-react-components"; import { LoadingContainer } from "drizzle-react-components";
import drizzleOptions from "./config/drizzleOptions"; import drizzleOptions from "./config/drizzleOptions";
import AppContainer from "./containers/AppContainer"; import { ConnectedRouter } from 'connected-react-router'
import store from './redux/store'; import routerStore, {history} from './redux/routerStore';
import drizzleStore from './redux/drizzleStore';
import routes from './router/routes'
import * as serviceWorker from "./utils/serviceWorker"; import * as serviceWorker from "./utils/serviceWorker";
import {Provider} from "react-redux";
render( render(
<DrizzleProvider options={drizzleOptions} store={store}> <DrizzleProvider options={drizzleOptions} store={drizzleStore}>
<Provider store={routerStore}>
<LoadingContainer> <LoadingContainer>
<AppContainer /> <ConnectedRouter history={history}>
{ routes }
</ConnectedRouter>
</LoadingContainer> </LoadingContainer>
</Provider>
</DrizzleProvider>, </DrizzleProvider>,
document.getElementById('root') document.getElementById('root')
); );

19
app/src/redux/store.js → app/src/redux/drizzleStore.js

@ -1,28 +1,23 @@
import { createStore, applyMiddleware, compose } from 'redux'; import { createStore, applyMiddleware, compose } from 'redux';
import reducer from './reducers/reducer';
import rootSaga from './sagas/rootSaga';
import createSagaMiddleware from 'redux-saga'; import createSagaMiddleware from 'redux-saga';
import { generateContractsInitialState } from 'drizzle'; import { generateContractsInitialState } from 'drizzle';
import drizzleReducer from './reducers/drizzleReducer';
import rootSaga from './sagas/drizzleSaga';
import drizzleOptions from '../config/drizzleOptions'; import drizzleOptions from '../config/drizzleOptions';
const initialState = { contracts: generateContractsInitialState(drizzleOptions) };
// Redux DevTools // Redux DevTools
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const sagaMiddleware = createSagaMiddleware(); const sagaMiddleware = createSagaMiddleware();
const composedEnhancers = composeEnhancers(applyMiddleware(sagaMiddleware));
const initialState = {
contracts: generateContractsInitialState(drizzleOptions)
};
const store = createStore( const store = createStore(
reducer, drizzleReducer,
initialState, initialState,
composeEnhancers( composedEnhancers
applyMiddleware(
sagaMiddleware
)
)
); );
sagaMiddleware.run(rootSaga); sagaMiddleware.run(rootSaga);

0
app/src/redux/reducers/reducer.js → app/src/redux/reducers/drizzleReducer.js

6
app/src/redux/reducers/routerReducer.js

@ -0,0 +1,6 @@
import { combineReducers } from 'redux';
import { connectRouter } from 'connected-react-router'
export default (history) => combineReducers({
router: connectRouter(history)
})

27
app/src/redux/routerStore.js

@ -0,0 +1,27 @@
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;

0
app/src/redux/sagas/rootSaga.js → app/src/redux/sagas/drizzleSaga.js

BIN
app/src/resources/PageNotFound.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

BIN
app/src/resources/ipfs_logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
app/src/resources/logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 KiB

27
app/src/router/routes.js

@ -0,0 +1,27 @@
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>
// );
Loading…
Cancel
Save