diff options
author | eug-vs <eug-vs@keemail.me> | 2021-03-14 01:00:49 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2021-03-14 01:00:49 +0300 |
commit | c6fac69a8273ce20216002925deb0a2b5425dc25 (patch) | |
tree | c2a22bb4ca992b1e5f7aaee496b3a8a1006013f5 /src/index.tsx | |
parent | 9e0fde7ed793426d9a3ed8c79e56bc95c01486b2 (diff) | |
download | commercel-ui-c6fac69a8273ce20216002925deb0a2b5425dc25.tar.gz |
feat: add basic routing
Diffstat (limited to 'src/index.tsx')
-rw-r--r-- | src/index.tsx | 41 |
1 files changed, 13 insertions, 28 deletions
diff --git a/src/index.tsx b/src/index.tsx index 4c354f4..169da4c 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,43 +1,28 @@ import React from 'react'; import ReactDOM from 'react-dom'; import 'tailwindcss/tailwind.css'; -import Paper from './components/Paper'; +import { + BrowserRouter as Router, + Switch, + Route +} from 'react-router-dom'; import Header from './components/Header'; -import Button from './components/Button'; -import ListTable from './components/ListTable'; +import Home from './containers/Home'; +import Products from './containers/Products'; const navigation = [ { name: 'Главная', route: '/'}, { name: 'Товары', route: '/products'} ]; -const fields = [ - { key: '_id', label: 'ID' }, - { key: 'name', label: 'Название' }, - { key: 'type', label: 'Тип' }, -]; - -const items = [ - { _id: 1, name: 'Товар 1', type: 'Кондиционер' }, - { _id: 2, name: 'Товар 2', type: 'Кондиционер' }, - { _id: 3, name: 'Товар 3', type: 'Кондиционер' }, - { _id: 4, name: 'Товар 4', type: 'Кондиционер' }, - { _id: 5, name: 'Товар 5', type: 'Кондиционер' }, - { _id: 6, name: 'Товар 6', type: 'Кондиционер' }, -]; - const App: React.FC = () => ( - <> + <Router> <Header navigation={navigation} /> - <Paper> - <p> - Привет, мир! - <Button>Нажми меня</Button> - <Button variant="outlined">Отменить</Button> - </p> - <ListTable items={items} fields={fields} /> - </Paper> - </> + <Switch> + <Route exact path="/" component={Home} /> + <Route exact path="/products" component={Products} /> + </Switch> + </Router> ); ReactDOM.render( |