/* eslint-disable no-unused-vars */
import React from 'react';
/* eslint-disable no-unused-vars */
import { Router, browserHistory, Route, IndexRedirect, Redirect } from 'react-router';

function redirect(state, replace) {
  if (state.location.query.video === '1') {
    replace('/encrypt/direct/1');
  }
}

module.exports = (
	<Router history={browserHistory}>
		<Route path="/encrypt">
			<IndexRedirect to="/encrypt/social/2" />
			<Route path="signup" component={require(`./pages/encrypt/signup.jsx`)}/>
			<Route path="signup-complete" component={require(`./pages/encrypt/signup-complete.jsx`)}/>
			<Route path=":type/:video" component={require('./pages/encrypt/pageType.jsx')}/>
			<Redirect from="direct" to="/encrypt/direct/2" />
			<Redirect from="social" to="/encrypt/social/2" />
			<Route path="2" onEnter={redirect} />
			<Redirect from="3" to="/encrypt/hybrid/2" />
			<Redirect from="*" to="/encrypt/" />
		</Route>
	</Router>
	);

/* eslint-disable no-unused-vars */
import React from 'react';
/* eslint-disable no-unused-vars */
import { Router, browserHistory, Route, IndexRedirect, Redirect, IndexRoute } from 'react-router';
import encryptVideos from './data/encryptVideos';

function redirect(state, replace) {
	var pageType;
	switch(state.location.pathname.slice(-1)){
		case '2':
			pageType = 'direct';
			break;
		case '3':
			pageType = 'hybrid';
			break;
		default:
			pageType = 'social';
	}
  if (state.location.query.video) {
    replace(`/encrypt/${pageType}/${state.location.query.video}`);
  } else {
  	replace(`/encrypt/${pageType}/${encryptVideos.length}`);
  }
}

function indexDirect(state, replace) {
	if(state.location.query.video){
		replace(`/encrypt/social/${state.location.query.video}`);
	} else {
		replace(`/encrypt/social/${encryptVideos.length}`);
	}
}

module.exports = (
	<Router history={browserHistory}>
		<Route path="/encrypt">
			<IndexRoute onEnter={indexDirect} />
			<Route path="signup" component={require(`./pages/encrypt/signup.jsx`)}/>
			<Route path="signup-complete" component={require(`./pages/encrypt/signup-complete.jsx`)}/>
			<Route path=":type/:video" component={require('./pages/encrypt/pageType.jsx')}/>
			<Redirect from="direct" to={`/encrypt/direct/${encryptVideos.length}`} />
			<Redirect from="social" to={`/encrypt/social/${encryptVideos.length}`} />
			<Route path="2" onEnter={redirect} />
			<Route path="3" onEnter={redirect} />
			<Redirect from="*" to="/encrypt/" />
		</Route>
	</Router>
	);

Add query handling for routing
Add query handling for routing
