2015-07-10 16:43:35 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import React from 'react';
|
2018-05-31 11:57:00 +02:00
|
|
|
import { Route, IndexRoute, Redirect } from 'react-router';
|
2015-07-10 16:43:35 +02:00
|
|
|
|
2016-02-08 14:50:24 +01:00
|
|
|
import { ProxyHandler, AuthRedirect } from '../../../components/ascribe_routes/proxy_handler';
|
|
|
|
import { AuthPrizeRoleRedirect } from './portfolioreview/components/pr_routes/pr_proxy_handler';
|
|
|
|
|
|
|
|
// General components
|
|
|
|
import EditionContainer from '../../ascribe_detail/edition_container';
|
|
|
|
import LogoutContainer from '../../logout_container';
|
|
|
|
import PasswordResetContainer from '../../password_reset_container';
|
|
|
|
import CoaVerifyContainer from '../../coa_verify_container';
|
|
|
|
import ErrorNotFoundPage from '../../error_not_found_page';
|
|
|
|
|
|
|
|
import SPApp from './simple_prize/prize_app';
|
2015-11-05 16:45:12 +01:00
|
|
|
import SPLanding from './simple_prize/components/prize_landing';
|
|
|
|
import SPLoginContainer from './simple_prize/components/prize_login_container';
|
|
|
|
import SPRegisterPiece from './simple_prize/components/prize_register_piece';
|
|
|
|
import SPPieceList from './simple_prize/components/prize_piece_list';
|
|
|
|
import SPPieceContainer from './simple_prize/components/ascribe_detail/prize_piece_container';
|
|
|
|
import SPSettingsContainer from './simple_prize/components/prize_settings_container';
|
2015-07-10 16:43:35 +02:00
|
|
|
|
2015-12-21 16:16:41 +01:00
|
|
|
import SluicePieceContainer from './sluice/components/sluice_detail/sluice_piece_container';
|
|
|
|
|
2015-11-06 12:09:31 +01:00
|
|
|
import PRApp from './portfolioreview/pr_app';
|
|
|
|
import PRLanding from './portfolioreview/components/pr_landing';
|
2015-11-06 16:52:08 +01:00
|
|
|
import PRRegisterPiece from './portfolioreview/components/pr_register_piece';
|
2015-11-06 12:09:31 +01:00
|
|
|
|
2016-02-08 14:50:24 +01:00
|
|
|
import { getLangText } from '../../../utils/lang_utils';
|
2015-10-09 15:19:24 +02:00
|
|
|
|
2015-07-10 16:43:35 +02:00
|
|
|
|
2015-11-05 16:45:12 +01:00
|
|
|
const ROUTES = {
|
2015-11-06 12:09:31 +01:00
|
|
|
sluice: (
|
2015-11-05 16:45:12 +01:00
|
|
|
<Route path='/' component={SPApp}>
|
2016-02-05 10:38:59 +01:00
|
|
|
<IndexRoute
|
2016-03-04 15:53:55 +01:00
|
|
|
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(SPLanding)} />
|
2015-10-12 16:51:03 +02:00
|
|
|
<Route
|
|
|
|
path='login'
|
2016-03-04 15:53:55 +01:00
|
|
|
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(SPLoginContainer)} />
|
2015-10-12 16:51:03 +02:00
|
|
|
<Route
|
|
|
|
path='logout'
|
2016-03-04 15:53:55 +01:00
|
|
|
component={ProxyHandler(AuthRedirect({to: '/', when: 'loggedOut'}))(LogoutContainer)} />
|
2018-06-01 10:58:50 +02:00
|
|
|
<Redirect from='signup' to='login' />
|
|
|
|
<Route path='signup' />
|
2015-10-12 16:51:03 +02:00
|
|
|
<Route
|
|
|
|
path='password_reset'
|
2016-03-04 15:53:55 +01:00
|
|
|
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(PasswordResetContainer)} />
|
2015-10-12 16:51:03 +02:00
|
|
|
<Route
|
|
|
|
path='settings'
|
2016-03-04 15:53:55 +01:00
|
|
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(SPSettingsContainer)} />
|
2015-10-12 16:51:03 +02:00
|
|
|
<Route
|
|
|
|
path='register_piece'
|
2015-12-08 11:17:04 +01:00
|
|
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(SPRegisterPiece)}
|
2016-03-04 15:53:55 +01:00
|
|
|
headerTitle={getLangText('+ NEW WORK')} />
|
2015-10-12 16:51:03 +02:00
|
|
|
<Route
|
|
|
|
path='collection'
|
2015-12-08 11:17:04 +01:00
|
|
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(SPPieceList)}
|
2016-03-04 15:53:55 +01:00
|
|
|
headerTitle={getLangText('COLLECTION')} />
|
2016-02-05 10:38:59 +01:00
|
|
|
<Route
|
|
|
|
path='pieces/:pieceId'
|
2016-03-04 15:53:55 +01:00
|
|
|
component={SluicePieceContainer} />
|
2016-02-05 10:38:59 +01:00
|
|
|
<Route
|
|
|
|
path='editions/:editionId'
|
2016-03-04 15:53:55 +01:00
|
|
|
component={EditionContainer} />
|
2016-02-05 10:38:59 +01:00
|
|
|
<Route
|
|
|
|
path='coa_verify'
|
2016-03-04 15:53:55 +01:00
|
|
|
component={CoaVerifyContainer} />
|
2016-02-05 10:38:59 +01:00
|
|
|
<Route
|
|
|
|
path='*'
|
2016-03-04 15:53:55 +01:00
|
|
|
component={ErrorNotFoundPage} />
|
2015-07-10 16:43:35 +02:00
|
|
|
</Route>
|
2015-11-06 12:09:31 +01:00
|
|
|
),
|
|
|
|
portfolioreview: (
|
|
|
|
<Route path='/' component={PRApp}>
|
2016-02-05 10:38:59 +01:00
|
|
|
<IndexRoute
|
2016-03-04 15:53:55 +01:00
|
|
|
component={ProxyHandler(AuthPrizeRoleRedirect({ to: '/collection', when: ['is_admin', 'is_judge', 'is_jury'] }))(PRLanding)} />
|
2015-11-06 12:09:31 +01:00
|
|
|
<Route
|
|
|
|
path='register_piece'
|
2016-03-04 15:53:55 +01:00
|
|
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(PRRegisterPiece)} />
|
2015-12-08 15:21:20 +01:00
|
|
|
<Route
|
|
|
|
path='collection'
|
|
|
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(SPPieceList)}
|
2016-03-04 15:53:55 +01:00
|
|
|
headerTitle={getLangText('SUBMISSIONS')} />
|
2015-11-06 12:09:31 +01:00
|
|
|
<Route
|
|
|
|
path='login'
|
2015-12-08 15:21:20 +01:00
|
|
|
component={ProxyHandler(
|
|
|
|
AuthPrizeRoleRedirect({ to: '/collection', when: ['is_admin', 'is_judge', 'is_jury'] }),
|
|
|
|
AuthRedirect({to: '/register_piece', when: 'loggedIn'})
|
2016-03-04 15:53:55 +01:00
|
|
|
)(SPLoginContainer)} />
|
2015-11-06 12:09:31 +01:00
|
|
|
<Route
|
|
|
|
path='logout'
|
2016-03-04 15:53:55 +01:00
|
|
|
component={ProxyHandler(AuthRedirect({to: '/', when: 'loggedOut'}))(LogoutContainer)} />
|
2018-06-01 10:58:50 +02:00
|
|
|
<Redirect from='signup' to='login' />
|
|
|
|
<Route path='signup' />
|
2015-11-06 12:09:31 +01:00
|
|
|
<Route
|
|
|
|
path='password_reset'
|
2015-12-09 14:00:00 +01:00
|
|
|
component={ProxyHandler(
|
|
|
|
AuthPrizeRoleRedirect({ to: '/collection', when: ['is_admin', 'is_judge', 'is_jury'] }),
|
|
|
|
AuthRedirect({to: '/register_piece', when: 'loggedIn'})
|
2016-03-04 15:53:55 +01:00
|
|
|
)(PasswordResetContainer)} />
|
2015-12-08 15:21:20 +01:00
|
|
|
<Route
|
|
|
|
path='settings'
|
2016-03-04 15:53:55 +01:00
|
|
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(SPSettingsContainer)} />
|
2016-02-05 10:38:59 +01:00
|
|
|
<Route
|
|
|
|
path='pieces/:pieceId'
|
2016-03-04 15:53:55 +01:00
|
|
|
component={SPPieceContainer} />
|
2016-02-05 10:38:59 +01:00
|
|
|
<Route
|
|
|
|
path='editions/:editionId'
|
2016-03-04 15:53:55 +01:00
|
|
|
component={EditionContainer} />
|
2016-02-05 10:38:59 +01:00
|
|
|
<Route
|
|
|
|
path='coa_verify'
|
2016-03-04 15:53:55 +01:00
|
|
|
component={CoaVerifyContainer} />
|
2016-02-05 10:38:59 +01:00
|
|
|
<Route
|
|
|
|
path='*'
|
2016-03-04 15:53:55 +01:00
|
|
|
component={ErrorNotFoundPage} />
|
2015-11-06 12:09:31 +01:00
|
|
|
</Route>
|
2015-11-05 16:45:12 +01:00
|
|
|
)
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function getRoutes(commonRoutes, subdomain) {
|
|
|
|
if(subdomain in ROUTES) {
|
|
|
|
return ROUTES[subdomain];
|
|
|
|
} else {
|
|
|
|
throw new Error('Subdomain wasn\'t specified in the wallet app.');
|
|
|
|
}
|
2015-07-10 16:43:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-12 16:51:03 +02:00
|
|
|
export default getRoutes;
|