App.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { BrowserRouter as Router, Route, Link, NavLink } from "react-router-dom";
  2. import React, { Component, Props } from 'react';
  3. import { Provider } from 'react-redux';
  4. import CBKDrawer from './components/Drawer';
  5. import { Grid, Row } from '@material/react-layout-grid';
  6. import List, { ListItem, ListItemText } from '@material/react-list';
  7. import configureStore from 'store/configureStore';
  8. import './styles/app.scss';
  9. import "@material/react-layout-grid/dist/layout-grid.min.css";
  10. import Routes, { RouteWithSubRoutes } from 'route.config';
  11. function Index() {
  12. return <h2>Home</h2>;
  13. }
  14. function Users() {
  15. return <h2>Users</h2>;
  16. }
  17. const store = configureStore();
  18. class App extends Component<{}, {}> {
  19. navbarItems: { title: string, path: string, active: boolean }[]
  20. constructor(props: any) {
  21. super(props);
  22. this.navbarItems = [
  23. { title: 'Recipes', path: '/recipes', active: false },
  24. { title: 'Planner', path: '/planner', active: false },
  25. { title: 'Shoplist', path: '/shoplist', active: false },
  26. ];
  27. }
  28. render() {
  29. return (
  30. <Provider store={store}>
  31. <Router>
  32. <CBKDrawer>
  33. {
  34. this.navbarItems.map((item, i) => (
  35. <NavLink
  36. to={item.path}
  37. activeClassName='active'
  38. key={i}
  39. >{item.title}</NavLink>
  40. ))
  41. }
  42. </CBKDrawer>
  43. <div className="cbk-main">
  44. {
  45. Routes.map((route, i) => (
  46. <RouteWithSubRoutes key={i} {...route} />
  47. ))
  48. }
  49. </div>
  50. </Router>
  51. </Provider>
  52. )
  53. }
  54. }
  55. export default App;