// These are the pages you can go to.
// They are all wrapped in the App component, which should contain the navbar etc
// See http://blog.mxstbr.com/2016/01/react-apps-with-pages for more information
// about the code splitting business
import { getAsyncInjectors } from 'utils/asyncInjectors';

const errorLoading = (err) => {
  console.error('Dynamic page loading failed', err); // eslint-disable-line no-console
};

const loadModule = (cb) => (componentModule) => {
  cb(null, componentModule.default);
};

export default function createRoutes(store) {
  // Create reusable async injectors using getAsyncInjectors factory
  const { injectReducer, injectSagas } = getAsyncInjectors(store); // eslint-disable-line no-unused-vars

  return [
    {
      path: '/',
      name: 'home',
      getComponent(nextState, cb) {
        const importModules = Promise.all([
          System.import('containers/Dashboard'),
        ]);

        const renderRoute = loadModule(cb);

        importModules.then(([component]) => {
          renderRoute(component);
        });

        importModules.catch(errorLoading);
      },
    }, {
      path: '/contacts',
      name: 'contactPage',
      getComponent(nextState, cb) {
        const importModules = Promise.all([
          System.import('containers/Contacts/ContactPage/reducer'),
          System.import('containers/Contacts/ContactPage'),
        ]);

        const renderRoute = loadModule(cb);

        importModules.then(([reducer, component]) => {
          injectReducer('contactPage', reducer.default);
          renderRoute(component);
        });

        importModules.catch(errorLoading);
      },
    }, {
      path: '/login',
      name: 'login',
      getComponent(nextState, cb) {
        const importModules = Promise.all([
          System.import('containers/Login/reducer'),
          System.import('containers/Login/sagas'),
          System.import('containers/Login'),
        ]);

        const renderRoute = loadModule(cb);

        importModules.then(([reducer, sagas, component]) => {
          injectReducer('login', reducer.default);
          injectSagas(sagas.default);
          renderRoute(component);
        });

        importModules.catch(errorLoading);
      },
    }, {
      path: '*',
      name: 'notfound',
      getComponent(nextState, cb) {
        System.import('containers/NotFoundPage')
          .then(loadModule(cb))
          .catch(errorLoading);
      },
    },
  ];
}

@@ -1650,32 +1650,34 @@
     %7D,%0A    %7D, %7B%0A
+//
       path: '/lo
@@ -1678,24 +1678,26 @@
 : '/login',%0A
+//
       name: 
@@ -1705,16 +1705,18 @@
 login',%0A
+//
       ge
@@ -1735,32 +1735,34 @@
 extState, cb) %7B%0A
+//
         const im
@@ -1781,32 +1781,34 @@
 = Promise.all(%5B%0A
+//
           System
@@ -1836,32 +1836,34 @@
 ogin/reducer'),%0A
+//
           System
@@ -1893,24 +1893,26 @@
 in/sagas'),%0A
+//
           Sy
@@ -1940,24 +1940,26 @@
 rs/Login'),%0A
+//
         %5D);%0A
@@ -1950,33 +1950,37 @@
 ,%0A//        %5D);%0A
-%0A
+//%0A//
         const re
@@ -1999,33 +1999,37 @@
 loadModule(cb);%0A
-%0A
+//%0A//
         importMo
@@ -2066,32 +2066,34 @@
 omponent%5D) =%3E %7B%0A
+//
           inject
@@ -2119,32 +2119,34 @@
 ducer.default);%0A
+//
           inject
@@ -2159,32 +2159,34 @@
 sagas.default);%0A
+//
           render
@@ -2195,32 +2195,34 @@
 ute(component);%0A
+//
         %7D);%0A%0A   
@@ -2209,33 +2209,37 @@
 ;%0A//        %7D);%0A
-%0A
+//%0A//
         importMo
@@ -2257,32 +2257,34 @@
 (errorLoading);%0A
+//
       %7D,%0A    %7D, 
@@ -2268,32 +2268,34 @@
 ng);%0A//      %7D,%0A
+//
     %7D, %7B%0A      p

Comment out incomplete login route