@@ -20,7 +20,7 @@ import MobileDashboardView from './modules/Mobile/MobileDashboardView';
2020import { getUser } from './modules/User/actions' ;
2121import { stopSketch } from './modules/IDE/actions/ide' ;
2222import { userIsAuthenticated , userIsNotAuthenticated , userIsAuthorized } from './utils/auth' ;
23- import { createMobileFirst , responsiveForm } from './utils/responsive' ;
23+ import { mobileFirst , responsiveForm } from './utils/responsive' ;
2424
2525const checkAuth = ( store ) => {
2626 store . dispatch ( getUser ( ) ) ;
@@ -34,45 +34,41 @@ const onRouteChange = (store) => {
3434 store . dispatch ( stopSketch ( ) ) ;
3535} ;
3636
37- const routes = ( store ) => {
38- const mobileFirst = createMobileFirst ( store ) ;
37+ const routes = store => (
38+ < Route path = "/" component = { App } onChange = { ( ) => { onRouteChange ( store ) ; } } >
39+ < IndexRoute onEnter = { checkAuth ( store ) } component = { mobileFirst ( MobileIDEView , IDEView ) } />
3940
40- return (
41- < Route path = "/" component = { App } onChange = { ( ) => { onRouteChange ( store ) ; } } >
42- < IndexRoute onEnter = { checkAuth ( store ) } component = { mobileFirst ( MobileIDEView , IDEView ) } />
41+ < Route path = "/login" component = { userIsNotAuthenticated ( mobileFirst ( responsiveForm ( LoginView ) , LoginView ) ) } />
42+ < Route path = "/signup" component = { userIsNotAuthenticated ( mobileFirst ( responsiveForm ( SignupView ) , SignupView ) ) } />
43+ < Route path = "/reset-password" component = { userIsNotAuthenticated ( ResetPasswordView ) } />
44+ < Route path = "/verify" component = { EmailVerificationView } />
45+ < Route
46+ path = "/reset-password/:reset_password_token"
47+ component = { NewPasswordView }
48+ />
49+ < Route path = "/projects/:project_id" component = { IDEView } />
50+ < Route path = "/:username/full/:project_id" component = { FullView } />
51+ < Route path = "/full/:project_id" component = { FullView } />
4352
44- < Route path = "/login" component = { userIsNotAuthenticated ( mobileFirst ( responsiveForm ( LoginView ) , LoginView ) ) } />
45- < Route path = "/signup" component = { userIsNotAuthenticated ( mobileFirst ( responsiveForm ( SignupView ) , SignupView ) ) } />
46- < Route path = "/reset-password" component = { userIsNotAuthenticated ( ResetPasswordView ) } />
47- < Route path = "/verify" component = { EmailVerificationView } />
48- < Route
49- path = "/reset-password/:reset_password_token"
50- component = { NewPasswordView }
51- />
52- < Route path = "/projects/:project_id" component = { IDEView } />
53- < Route path = "/:username/full/:project_id" component = { FullView } />
54- < Route path = "/full/:project_id" component = { FullView } />
53+ < Route path = "/:username/assets" component = { userIsAuthenticated ( userIsAuthorized ( mobileFirst ( MobileDashboardView , DashboardView ) ) ) } />
54+ < Route path = "/:username/sketches" component = { mobileFirst ( MobileDashboardView , DashboardView ) } />
55+ < Route path = "/:username/sketches/:project_id" component = { mobileFirst ( MobileIDEView , IDEView ) } />
56+ < Route path = "/:username/sketches/:project_id/add-to-collection" component = { mobileFirst ( MobileIDEView , IDEView ) } />
57+ < Route path = "/:username/collections" component = { mobileFirst ( MobileDashboardView , DashboardView ) } />
5558
56- < Route path = "/:username/assets" component = { userIsAuthenticated ( userIsAuthorized ( mobileFirst ( MobileDashboardView , DashboardView ) ) ) } />
57- < Route path = "/:username/sketches" component = { mobileFirst ( MobileDashboardView , DashboardView ) } />
58- < Route path = "/:username/sketches/:project_id" component = { mobileFirst ( MobileIDEView , IDEView ) } />
59- < Route path = "/:username/sketches/:project_id/add-to-collection" component = { mobileFirst ( MobileIDEView , IDEView ) } />
60- < Route path = "/:username/collections" component = { mobileFirst ( MobileDashboardView , DashboardView ) } />
59+ < Route path = "/:username/collections/create" component = { DashboardView } />
60+ < Route path = "/:username/collections/:collection_id" component = { CollectionView } />
6161
62- < Route path = "/:username/collections/create" component = { DashboardView } />
63- < Route path = "/:username/collections/:collection_id" component = { CollectionView } />
62+ < Route path = "/sketches" component = { createRedirectWithUsername ( '/:username/sketches' ) } />
63+ < Route path = "/assets" component = { createRedirectWithUsername ( '/:username/assets' ) } />
64+ < Route path = "/account" component = { userIsAuthenticated ( AccountView ) } />
65+ < Route path = "/about" component = { IDEView } />
6466
65- < Route path = "/sketches" component = { createRedirectWithUsername ( '/:username/sketches' ) } />
66- < Route path = "/assets" component = { createRedirectWithUsername ( '/:username/assets' ) } />
67- < Route path = "/account" component = { userIsAuthenticated ( AccountView ) } />
68- < Route path = "/about" component = { IDEView } />
67+ { /* Mobile-only Routes */ }
68+ < Route path = "/preview" component = { MobileSketchView } />
69+ < Route path = "/preferences" component = { MobilePreferences } />
6970
70- { /* Mobile-only Routes */ }
71- < Route path = "/preview" component = { MobileSketchView } />
72- < Route path = "/preferences" component = { MobilePreferences } />
73-
74- </ Route >
75- ) ;
76- } ;
71+ </ Route >
72+ ) ;
7773
7874export default routes ;
0 commit comments