import { Meteor } from 'meteor/meteor';
import React from 'react';
import { render } from 'react-dom';
import { Router, Route, browserHistory, IndexRoute } from 'react-router';

import AppContainer from '../components/app-container';
import Browse from '../pages/browse';
import Feeds from '../pages/feeds';
import Home from '../pages/home';
import LoadingSpinner from '../components/utility/loading-spinner';
import Login from '../pages/login';
import Profile from '../pages/profile';
import Signup from '../pages/sign-up';

const scrollToTop = () => window.scrollTo(0, 0);

const route = (path, component, onEnter) => (
  <Route path={path} component={component} onEnter={onEnter || scrollToTop} />
);

const logout = () => {
  scrollToTop();

  Meteor.logout(error => {
    if (!error) browserHistory.push('/login');
  });
};

const renderRoutes = () => {
  render(
    <Router history={browserHistory}>
      <Route path="/" component={AppContainer}>
        <IndexRoute component={Home} onEnter={scrollToTop} />
        {route('login', Login)}
        {route('sign-up', Signup)}
        {route('feeds', Feeds)}
        {route('feeds/:category', Feeds)}
        {route('browse', Browse)}
        {route('scenes', Home)}
        {route('forums', Home)}
        {route('post', Home)}
        {route('profile', Profile)}
        {route('dashboard', Profile)}
        {route('messages', Profile)}
        {route('notifications', Profile)}
        {route('settings', Profile)}
        {route('logout', LoadingSpinner, logout)}
      </Route>
    </Router>,
    document.getElementById('react-root')
  );
};

export default renderRoutes;

@@ -1181,24 +1181,68 @@
 ', Browse)%7D%0A
+        %7Broute('browse/:category', Browse)%7D%0A
         %7Brou
@@ -1250,28 +1250,28 @@
 e('scenes', 
-Home
+null
 )%7D%0A        %7B
@@ -1286,20 +1286,20 @@
 orums', 
-Home
+null
 )%7D%0A     
@@ -1316,20 +1316,20 @@
 'post', 
-Home
+null
 )%7D%0A     
@@ -1389,32 +1389,70 @@
 ard', Profile)%7D%0A
+        %7Broute('favorites', Profile)%7D%0A
         %7Broute('

Add new routes and set those without pages to null