|
@@ -1,44 +1,62 @@
|
|
|
-import React, { useRef, createElement, Component } from 'react';
|
|
|
-import { Router, Route, Redirect, Switch, useParams } from 'react-router-dom';
|
|
|
+import React, { useState } from 'react';
|
|
|
+import { Router, Route, Switch, useParams } from 'react-router-dom';
|
|
|
import createHistory from "history/createBrowserHistory";
|
|
|
import { createStore, combineReducers, applyMiddleware } from 'redux';
|
|
|
-import { Provider, connect } from 'react-redux';
|
|
|
+import { Provider, connect, useSelector } from 'react-redux';
|
|
|
import thunk from 'redux-thunk';
|
|
|
import './App.css';
|
|
|
-import { authReducer, promiseReducer } from './reducers';
|
|
|
-import { actionFullLogin, actionRootCats } from './jql_actions'
|
|
|
+import { authReducer, promiseReducer, actionAuthLogin } from './reducers';
|
|
|
import { CLoginForm, GoodExample, GoodsList, goodsExample, Category, exampleCategory, OrderGood, exampleOrderGood, Order, exampleOrder, OrderList, exampleOrderList, exampleOrderGoodsList, OrderGoodsList } from "./Components";
|
|
|
-import { MyLink } from './Components';
|
|
|
import { MainAppBar } from './Components';
|
|
|
+import { CLogout } from './Components';
|
|
|
+import { Sidebar } from './Components/Sidebar';
|
|
|
|
|
|
|
|
|
export const history = createHistory()
|
|
|
console.log(useParams)
|
|
|
-const store = createStore(combineReducers({ promise: promiseReducer, auth: authReducer }), applyMiddleware(thunk))
|
|
|
+const store = createStore(combineReducers({ promise: promiseReducer, auth: authReducer }), applyMiddleware(thunk));
|
|
|
store.subscribe(() => console.log(store.getState()))
|
|
|
|
|
|
-store.dispatch(actionRootCats())
|
|
|
+//store.dispatch(actionRootCats())
|
|
|
+//store.dispatch(actionAuthLogin(localStorage.authToken));
|
|
|
|
|
|
|
|
|
/*const CCatMenu = connect(state => ({ cats: state.promise?.rootCats?.payload || [] }), { onLogin: actionFullLogin })(CatMenu)
|
|
|
|
|
|
const CLoginForm = connect(null, { onLogin: actionFullLogin })(LoginForm)*/
|
|
|
+store.dispatch(actionAuthLogin(localStorage.authToken));
|
|
|
+
|
|
|
const NotFound = () =>
|
|
|
- <div>
|
|
|
- <h1>404 not found</h1>
|
|
|
- </div>
|
|
|
+ <div>
|
|
|
+ <h1>404 not found</h1>
|
|
|
+ </div>
|
|
|
+
|
|
|
+const Test = () => {
|
|
|
+ let state = useSelector(state => state);
|
|
|
+ let stateAuth = state.auth;
|
|
|
+ let [auth, setAuth] = useState('');
|
|
|
+ if (stateAuth != auth) {
|
|
|
+ auth = auth;
|
|
|
+ }
|
|
|
+ return <div />
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
|
|
|
function App() {
|
|
|
+
|
|
|
return (
|
|
|
<>
|
|
|
-
|
|
|
<Router history={history}>
|
|
|
<Provider store={store}>
|
|
|
+ <Test />
|
|
|
<div className="App">
|
|
|
<MainAppBar />
|
|
|
+ <Sidebar menuComponent={() => <div>TEST!!!!!!</div>} />
|
|
|
<Switch>
|
|
|
{/*<Route path="/" component={Main} exact />*/}
|
|
|
<Route path="/login" component={CLoginForm} />
|
|
|
+ <Route path="/logout" component={CLogout} />
|
|
|
<Route path="*" component={NotFound} />
|
|
|
</Switch>
|
|
|
{/*<CCatMenu />
|