From 2c106d1d3f6d59b10ad946e01e8bb3d0df587e40 Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Sun, 14 Mar 2021 10:10:16 +0300
Subject: refactor: create Service abstraction

---
 src/index.tsx | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

(limited to 'src/index.tsx')

diff --git a/src/index.tsx b/src/index.tsx
index 4ec1db0..932fbf3 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -8,16 +8,13 @@ import {
 } from 'react-router-dom';
 import Header from './components/Header';
 import Home from './containers/Home';
-import Products from './containers/Products';
-import ProductForm from './containers/ProductForm';
-import Contractors from './containers/Contractors';
-import ContractorForm from './containers/ContractorForm';
+import Service from './containers/Service/Service';
+import { ServiceProvider } from './containers/Service/ServiceContext';
+import services from './services';
 
 const navigation = [
   { name: 'Главная', route: '/' },
-  { name: 'Товары', route: '/products' },
-  { name: 'Контрагенты', route: '/contractors' },
-  { name: 'Накладные', route: '/waybills' },
+  ...services.map(({ name, route }) => ({ name, route: `/${route}` })),
 ];
 
 const App: React.FC = () => (
@@ -25,12 +22,13 @@ const App: React.FC = () => (
     <Header navigation={navigation} />
     <Switch>
       <Route exact path="/" component={Home} />
-      <Route exact path="/products" component={Products} />
-      <Route exact path="/products/add" component={ProductForm} />
-      <Route exact path="/products/edit/:id" component={ProductForm} />
-      <Route exact path="/contractors" component={Contractors} />
-      <Route exact path="/contractors/add" component={ContractorForm} />
-      <Route exact path="/contractors/edit/:id" component={ContractorForm} />
+      {services.map(service => (
+        <Route path={`/${service.route}`}>
+          <ServiceProvider value={service}>
+            <Service />
+          </ServiceProvider>
+        </Route>
+      ))}
     </Switch>
   </Router>
 );
-- 
cgit v1.2.3

