diff -r 28971cf04a91 -r 37ecf0b9c174 clientjs/packages/annotation-dashboard-nextleap/src/store.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/clientjs/packages/annotation-dashboard-nextleap/src/store.js Thu Sep 20 17:51:15 2018 +0200 @@ -0,0 +1,39 @@ +import React, { Component } from 'react'; + +import thunkMiddleware from 'redux-thunk'; +import { Provider } from 'react-redux'; +import { createLogger } from 'redux-logger'; +import { createStore, applyMiddleware, compose } from 'redux'; + +import { fetchAnnotations } from 'dashboard-components/lib/actions'; +import rootReducer from 'dashboard-components/lib/reducers'; + +import { dashboardId } from './config.json'; + +let middlewares = [thunkMiddleware]; + +if (process.env.NODE_ENV !== 'production') { + const loggerMiddleware = createLogger(); + middlewares = [...middlewares, loggerMiddleware]; +} + +/* eslint-disable no-underscore-dangle */ +const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; +/* eslint-enable */ + +const store = createStore( + rootReducer, + composeEnhancers(applyMiddleware(...middlewares)), +); + +export default WrappedComponent => class extends Component { + componentWillMount() { + const apiUrl = process.env.REACT_APP_API_URL; + const discussionUrl = process.env.REACT_APP_DISCUSSION_URL; + store.dispatch(fetchAnnotations(apiUrl, discussionUrl, dashboardId)); + } + + render() { + return ; + } +};