{"size": 2736, "ext": "js", "max_stars_repo_path": "src/views/routes.js", "max_stars_repo_name": "JakePartusch/cafe-todo-app", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/views/routes.js", "max_issues_repo_name": "JakePartusch/cafe-todo-app", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/views/routes.js", "max_forks_repo_name": "JakePartusch/cafe-todo-app", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.7142857143, "max_line_length": 48, "alphanum_fraction": 0.5416666667}
import { isAuthenticated } from 'src/core/auth';
import App from './app';
import SignIn from './pages/sign-in';
import Tasks from './pages/tasks';


export const paths = {
  ROOT: '/',
  SIGN_IN: '/sign-in',
  OPEN: '/open',
  SHIFT: '/shift',
  SHIFT2: '/shift #2',
  SHIFT3: '/shift #3',
  PEPSI_FOUNTAIN: '/pepsi fountain',
  DISPLAY_COOLER: '/display cooler',
  REFRIGERATOR: '/refrigerator',
  BACK_COOLER: '/back cooler',
  ESPRESSO_MACHINE: '/espresso machine',
  MANAGEMENT: '/management',
  CLOSE: '/close'
};


const requireAuth = getState => {
  return (nextState, replace) => {
    if (!isAuthenticated(getState())) {
      replace(paths.SIGN_IN);
    }
  };
};

const requireUnauth = getState => {
  return (nextState, replace) => {
    if (isAuthenticated(getState())) {
      replace(paths.OPEN);
    }
  };
};


export const getRoutes = getState => {
  return {
    path: paths.ROOT,
    component: App,
    childRoutes: [
      {
        indexRoute: {
          component: Tasks,
          onEnter: requireAuth(getState)
        }
      },
      {
        name: 'OPEN',
        path: paths.OPEN,
        component: Tasks,
        onEnter: requireAuth(getState)
      },
      {
        name: 'SHIFT',
        path: paths.SHIFT,
        component: Tasks,
        onEnter: requireAuth(getState)
      },
      {
        name: 'SHIFT #2',
        path: paths.SHIFT2,
        component: Tasks,
        onEnter: requireAuth(getState)
      },
      {
        name: 'SHIFT #3',
        path: paths.SHIFT3,
        component: Tasks,
        onEnter: requireAuth(getState)
      },
      {
        name: 'PEPSI FOUNTAIN',
        path: paths.PEPSI_FOUNTAIN,
        component: Tasks,
        onEnter: requireAuth(getState)
      },
      {
        name: 'DISPLAY COOLER',
        path: paths.DISPLAY_COOLER,
        component: Tasks,
        onEnter: requireAuth(getState)
      },
      {
        name: 'REFRIGERATOR',
        path: paths.REFRIGERATOR,
        component: Tasks,
        onEnter: requireAuth(getState)
      },
      {
        name: 'BACK COOLER',
        path: paths.BACK_COOLER,
        component: Tasks,
        onEnter: requireAuth(getState)
      },
      {
        name: 'ESPRESSO MACHINE',
        path: paths.ESPRESSO_MACHINE,
        component: Tasks,
        onEnter: requireAuth(getState)
      },
      {
        name: 'MANAGEMENT',
        path: paths.MANAGEMENT,
        component: Tasks,
        onEnter: requireAuth(getState)
      },
      {
        name: 'CLOSE',
        path: paths.CLOSE,
        component: Tasks,
        onEnter: requireAuth(getState)
      },
      {
        path: paths.SIGN_IN,
        component: SignIn,
        onEnter: requireUnauth(getState)
      }
    ]
  };
};
