12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import 'antd/dist/antd.min.css'
- import './App.scss';
- import { Router, Route, Switch, Redirect } from 'react-router-dom';
- import createHistory from "history/createBrowserHistory";
- import { connect, Provider } from 'react-redux';
- import store from './redux/redux-store';
- import { Authorization } from './components/Authorization';
- import { Container, Content, Main } from './pages/Content';
- import { CProfilePage } from './pages/ProfilePage';
- import { CAdd } from './components/main/Add';
- import HeaderComponent from './pages/Header';
- import { CMainPostsFeed } from './pages/MainPostsFeed';
- import { CRRoute } from './helpers';
- import { CPostPage } from './pages/PostPage';
- import { CAllPosts } from './pages/AllPosts';
- import { CEditorPostPage, CEntityEditorPost } from './pages/EntityEditorPost';
- export const history = createHistory()
- const Aside = () =>
- <div>sdfsdgsgsdg</div>
- const AppContent = ({ isToken }) =>
- <Router history={history}>
- {!isToken
- ?
- <Switch>
- <Route path='/auth/:_id'
- component={Authorization} />
- <Redirect from='/*' to='/auth/login' />
- </Switch>
- :
- <Content>
- <HeaderComponent />
- <Main>
- <Switch>
- <Route path='/' component={CMainPostsFeed} exact />
- <Route path='/profile/:_id' component={CProfilePage} />
- <Route path='/message' component={Aside} />
- {/* <Route path='/add' component={CAdd} /> */}
- <Route path='/edit/post/:_id' component={CEntityEditorPost} />
- <Route path='/all' component={CAllPosts} />
- <CRRoute path='/post/:id' component={CPostPage} />
- <Redirect from='/*' to='/' />
- {/* <Redirect from='/*' to='/post/:id' /> */}
- </Switch>
- {/* */}
- </Main>
- </Content >
- }
- </Router >
- const CAppContent = connect(state => ({ isToken: state.auth?.token }))(AppContent)
- store.subscribe(() => console.log(store.getState()))
- function App() {
- return (
- <Provider store={store}>
- <CAppContent />
- </Provider>
- )
- }
- export default App;
|