|
@@ -5,34 +5,27 @@ import {Provider, connect} from 'react-redux';
|
|
|
import {Header, Footer, actionCatalogCard, MainImg} from "./components/index"
|
|
|
import {BrowserRouter as Router, Route, Link, Switch, Redirect} from 'react-router-dom';
|
|
|
import createHistory from "history/createBrowserHistory";
|
|
|
-import store from "./reducers"
|
|
|
import Catalog from "./components/catalog"
|
|
|
import BigCatalog2 from "./components/bigCat"
|
|
|
+import {createStore, combineReducers, applyMiddleware, compose} from 'redux';
|
|
|
+import thunk from 'redux-thunk';
|
|
|
|
|
|
|
|
|
-const MainImg2 = ({className = "MainImg"}) => {
|
|
|
- return (
|
|
|
- <div className = {className}>
|
|
|
- <aside></aside>
|
|
|
- <content>
|
|
|
- <Switch>
|
|
|
- <Route path = "/" component = {Main} exact/>
|
|
|
- <Route path = "/catalog" component={BigCatalog2}/>
|
|
|
- {/* <Route path="/about" component = {About}/> */}
|
|
|
- <Route path = "/post" component = {Post}/>
|
|
|
- <Route path = "/contacts" component = {Contacts}/>
|
|
|
- <Route component = { NotFound } exact/>
|
|
|
- </Switch>
|
|
|
- </content>
|
|
|
- </div>
|
|
|
- )
|
|
|
-}
|
|
|
|
|
|
-const Main = () => <div>Я тут кароче самый главный страниц</div>
|
|
|
-const NotFound = () => <div>Да пошел ты!</div>
|
|
|
|
|
|
-const Post = () => <div className = "post">Точно не знаю зачем это, возможно потом уберу. Но в некоторых магазинах есть такое</div>
|
|
|
-const Contacts = () => <div className = "contacts">Тут будет адрес, номер телефона и соцсети</div>
|
|
|
+function promiseReducer(state={}, action){
|
|
|
+ if (action.type === 'PROMISE'){
|
|
|
+ const { name="default", status, payload, error} = action
|
|
|
+ if (status){
|
|
|
+ return {
|
|
|
+ ...state, [name]: {status, payload: (status === 'PENDING' && state[name] && state[name].payload) || payload, error}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return state;
|
|
|
+}
|
|
|
+
|
|
|
+const store = createStore(combineReducers({promiseRed: promiseReducer}), compose(applyMiddleware(thunk)))
|
|
|
|
|
|
|
|
|
function App() {
|
|
@@ -43,7 +36,7 @@ function App() {
|
|
|
|
|
|
<Header/>
|
|
|
|
|
|
- <MainImg2/>
|
|
|
+ <MainImg/>
|
|
|
|
|
|
<Footer/>
|
|
|
</Router>
|