Main.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import {BrowserRouter as Router, Route, Link, Switch, Redirect} from 'react-router-dom';
  2. import createHistory from "history/createBrowserHistory";
  3. import { useState } from 'react';
  4. import {Provider, connect} from 'react-redux';
  5. import {createStore, combineReducers, applyMiddleware} from 'redux';
  6. import thunk from 'redux-thunk';
  7. import store from "../reducers";
  8. import Catalog from "./catalog";
  9. import {actionCatalogCard, CBasketPage, searchInput, CGoodsCategory, SearchInput, CGoodsSearch, LoginForm, CGoodCard, YourProfile} from "./index";
  10. const Main = ({className = "MainImg" }) => {
  11. return (
  12. <>
  13. <div className = {className}>
  14. <div className = "catalogHead">
  15. <SearchInput/>
  16. </div>
  17. <div className = "catalogInput">
  18. <aside>
  19. <Switch>
  20. <Route path = "/catalog/" component={Catalog} />
  21. <Route path = "/search/"component={Catalog} />
  22. <Route path = "/good/:id" component={(window.innerWidth > 900) && Catalog} />
  23. </Switch>
  24. </aside>
  25. <content>
  26. <Switch>
  27. <Route path = "/" component = {MainMag} exact/>
  28. <Route path = "/catalog/" component={MainCatalog} exact/>
  29. <Route path = "/catalog/:id" component= {({match}) => <CGoodsCategory id = {match.params.id} /> }/>
  30. <Route path = "/search/:name" component = {({match}) => <CGoodsSearch name = {match.params.name}/>}/>
  31. <Route path = "/good/:id" component = {({match}) => <CGoodCard id = {match.params.id}/>}/>
  32. <Route path = "/login" component = {LoginForm}/>
  33. <Route path = "/profile/:login" component = {YourProfile}/>
  34. <Route path = "/basket" component = {CBasketPage}/>
  35. <Route path="/about" component = {About} exact/>
  36. <Route path = "/post" component = {Post} exact/>
  37. <Route path = "/contacts" component = {Contacts} />
  38. <Route component = { NotFound } exact/>
  39. </Switch>
  40. </content>
  41. </div>
  42. </div>
  43. </>
  44. )
  45. }
  46. // const Id = ({name = "Idishnic"} )=> {
  47. // return(<div>{name}</div>) }
  48. const MainMag = () => <div>Я тут кароче самый главный страниц</div>
  49. const About = () => <div>Мы крутой магазин, бла-бла</div>
  50. const NotFound = () => <div>Да пошел ты!</div>
  51. const MainCatalog = () => <div>Chose</div>
  52. const Post = () => <div className = "post">Точно не знаю зачем это, возможно потом уберу. Но в некоторых магазинах есть такое</div>
  53. const Contacts = () => <div className = "contacts">Тут будет адрес, номер телефона и соцсети</div>
  54. export default Main;