mirror of
https://github.com/ascribe/onion.git
synced 2025-01-03 10:25:08 +01:00
Update prize routes for loading user and whitelabel settings in top level app
This commit is contained in:
parent
5ae166edf3
commit
06ea23c627
@ -36,7 +36,7 @@ let SettingsContainer = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { currentUser, whitelabel } = this.props;
|
const { children, currentUser, whitelabel } = this.props;
|
||||||
|
|
||||||
setDocumentTitle(getLangText('Account settings'));
|
setDocumentTitle(getLangText('Account settings'));
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ let SettingsContainer = React.createClass({
|
|||||||
currentUser={currentUser}
|
currentUser={currentUser}
|
||||||
loadUser={this.loadUser}
|
loadUser={this.loadUser}
|
||||||
whitelabel={whitelabel} />
|
whitelabel={whitelabel} />
|
||||||
{this.props.children}
|
{children}
|
||||||
<AclProxy
|
<AclProxy
|
||||||
aclObject={whitelabel}
|
aclObject={whitelabel}
|
||||||
aclName="acl_view_settings_api">
|
aclName="acl_view_settings_api">
|
||||||
|
@ -77,7 +77,7 @@ let RegisterPiece = React.createClass( {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getSpecifyEditions() {
|
getSpecifyEditions() {
|
||||||
if (this.props.whitelabel && this.props.whitelabel.acl_create_editions || Object.keys(this.props.whitelabel).length === 0) {
|
if (this.props.whitelabel && (this.props.whitelabel.acl_create_editions || Object.keys(this.props.whitelabel).length)) {
|
||||||
return (
|
return (
|
||||||
<Property
|
<Property
|
||||||
name="num_editions"
|
name="num_editions"
|
||||||
|
@ -26,7 +26,7 @@ let SignupContainer = React.createClass({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSuccess(message){
|
handleSuccess(message) {
|
||||||
this.setState({
|
this.setState({
|
||||||
submitted: true,
|
submitted: true,
|
||||||
message: message
|
message: message
|
||||||
@ -34,14 +34,17 @@ let SignupContainer = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const { location } = this.props;
|
||||||
|
const { message, submitted } = this.state;
|
||||||
|
|
||||||
setDocumentTitle(getLangText('Sign up'));
|
setDocumentTitle(getLangText('Sign up'));
|
||||||
|
|
||||||
if (this.state.submitted) {
|
if (submitted) {
|
||||||
return (
|
return (
|
||||||
<div className="ascribe-login-wrapper">
|
<div className="ascribe-login-wrapper">
|
||||||
<br/>
|
<br/>
|
||||||
<div className="ascribe-login-text ascribe-login-header">
|
<div className="ascribe-login-text ascribe-login-header">
|
||||||
{this.state.message}
|
{message}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -50,7 +53,7 @@ let SignupContainer = React.createClass({
|
|||||||
<div className="ascribe-login-wrapper">
|
<div className="ascribe-login-wrapper">
|
||||||
<SignupForm
|
<SignupForm
|
||||||
handleSuccess={this.handleSuccess}
|
handleSuccess={this.handleSuccess}
|
||||||
location={this.props.location}/>
|
location={location}/>
|
||||||
<div className="ascribe-login-text">
|
<div className="ascribe-login-text">
|
||||||
{getLangText('Already an ascribe user')}? <Link to="/login">{getLangText('Log in')}...</Link><br/>
|
{getLangText('Already an ascribe user')}? <Link to="/login">{getLangText('Log in')}...</Link><br/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -30,9 +30,8 @@ const { object } = React.PropTypes;
|
|||||||
|
|
||||||
const PRRegisterPieceForm = React.createClass({
|
const PRRegisterPieceForm = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
location: object,
|
currentUser: object,
|
||||||
history: object,
|
location: object
|
||||||
currentUser: object
|
|
||||||
},
|
},
|
||||||
|
|
||||||
mixins: [History],
|
mixins: [History],
|
||||||
|
@ -3,43 +3,39 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { History } from 'react-router';
|
import { History } from 'react-router';
|
||||||
|
|
||||||
import PrizeActions from '../../simple_prize/actions/prize_actions';
|
|
||||||
import PrizeStore from '../../simple_prize/stores/prize_store';
|
|
||||||
|
|
||||||
import Button from 'react-bootstrap/lib/Button';
|
import Button from 'react-bootstrap/lib/Button';
|
||||||
import ButtonGroup from 'react-bootstrap/lib/ButtonGroup';
|
import ButtonGroup from 'react-bootstrap/lib/ButtonGroup';
|
||||||
|
|
||||||
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
||||||
|
|
||||||
import UserStore from '../../../../../stores/user_store';
|
import PrizeActions from '../../simple_prize/actions/prize_actions';
|
||||||
import UserActions from '../../../../../actions/user_actions';
|
import PrizeStore from '../../simple_prize/stores/prize_store';
|
||||||
|
|
||||||
import { mergeOptions } from '../../../../../utils/general_utils';
|
|
||||||
import { getLangText } from '../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../utils/lang_utils';
|
||||||
|
|
||||||
|
|
||||||
const PRLanding = React.createClass({
|
const PRLanding = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
// Provided from PrizeApp
|
||||||
|
currentUser: React.PropTypes.object,
|
||||||
|
whitelabel: React.PropTypes.object,
|
||||||
|
|
||||||
|
//Provided from router
|
||||||
location: React.PropTypes.object
|
location: React.PropTypes.object
|
||||||
},
|
},
|
||||||
|
|
||||||
mixins: [History],
|
mixins: [History],
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return mergeOptions(
|
return PrizeStore.getState();
|
||||||
PrizeStore.getState(),
|
|
||||||
UserStore.getState()
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { location } = this.props;
|
const { location } = this.props;
|
||||||
UserStore.listen(this.onChange);
|
|
||||||
UserActions.fetchCurrentUser();
|
|
||||||
PrizeStore.listen(this.onChange);
|
PrizeStore.listen(this.onChange);
|
||||||
PrizeActions.fetchPrize();
|
PrizeActions.fetchPrize();
|
||||||
|
|
||||||
if(location && location.query && location.query.redirect) {
|
if (location && location.query && location.query.redirect) {
|
||||||
let queryCopy = JSON.parse(JSON.stringify(location.query));
|
let queryCopy = JSON.parse(JSON.stringify(location.query));
|
||||||
delete queryCopy.redirect;
|
delete queryCopy.redirect;
|
||||||
window.setTimeout(() => this.history.replaceState(null, `/${location.query.redirect}`, queryCopy));
|
window.setTimeout(() => this.history.replaceState(null, `/${location.query.redirect}`, queryCopy));
|
||||||
@ -47,7 +43,6 @@ const PRLanding = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
UserStore.unlisten(this.onChange);
|
|
||||||
PrizeStore.unlisten(this.onChange);
|
PrizeStore.unlisten(this.onChange);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -56,7 +51,7 @@ const PRLanding = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getButtons() {
|
getButtons() {
|
||||||
if (this.state.prize && this.state.prize.active){
|
if (this.state.prize && this.state.prize.active) {
|
||||||
return (
|
return (
|
||||||
<ButtonGroup className="enter" bsSize="large" vertical>
|
<ButtonGroup className="enter" bsSize="large" vertical>
|
||||||
<LinkContainer to="/signup">
|
<LinkContainer to="/signup">
|
||||||
@ -75,39 +70,37 @@ const PRLanding = React.createClass({
|
|||||||
</LinkContainer>
|
</LinkContainer>
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
return (
|
return (
|
||||||
<ButtonGroup className="enter" bsSize="large" vertical>
|
<ButtonGroup className="enter" bsSize="large" vertical>
|
||||||
<a className="btn btn-default" href="https://www.ascribe.io/app/signup">
|
<a className="btn btn-default" href="https://www.ascribe.io/app/signup">
|
||||||
{getLangText('Sign up to ascribe')}
|
{getLangText('Sign up to ascribe')}
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
{getLangText('or, already an ascribe user?')}
|
{getLangText('or, already an ascribe user?')}
|
||||||
</p>
|
</p>
|
||||||
<LinkContainer to="/login">
|
<LinkContainer to="/login">
|
||||||
<Button>
|
<Button>
|
||||||
{getLangText('Log in')}
|
{getLangText('Log in')}
|
||||||
</Button>
|
</Button>
|
||||||
</LinkContainer>
|
</LinkContainer>
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getTitle() {
|
getTitle() {
|
||||||
if (this.state.prize && this.state.prize.active){
|
const { prize } = this.state;
|
||||||
return (
|
|
||||||
<p>
|
|
||||||
{getLangText('This is the submission page for Portfolio Review 2016.')}
|
|
||||||
</p>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<p>
|
<p>
|
||||||
{getLangText('Submissions for Portfolio Review 2016 are now closed.')}
|
{getLangText(prize && prize.active ? 'This is the submission page for Portfolio Review 2016.'
|
||||||
|
: 'Submissions for Portfolio Review 2016 are now closed.')}
|
||||||
</p>
|
</p>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="container">
|
<div className="container">
|
||||||
@ -125,4 +118,4 @@ const PRLanding = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default PRLanding;
|
export default PRLanding;
|
||||||
|
@ -6,9 +6,6 @@ import { Link, History } from 'react-router';
|
|||||||
import Col from 'react-bootstrap/lib/Col';
|
import Col from 'react-bootstrap/lib/Col';
|
||||||
import Row from 'react-bootstrap/lib/Row';
|
import Row from 'react-bootstrap/lib/Row';
|
||||||
|
|
||||||
import UserStore from '../../../../../stores/user_store';
|
|
||||||
import UserActions from '../../../../../actions/user_actions';
|
|
||||||
|
|
||||||
import PRRegisterPieceForm from './pr_forms/pr_register_piece_form';
|
import PRRegisterPieceForm from './pr_forms/pr_register_piece_form';
|
||||||
|
|
||||||
import { getLangText } from '../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../utils/lang_utils';
|
||||||
@ -20,43 +17,31 @@ const { object } = React.PropTypes;
|
|||||||
|
|
||||||
const PRRegisterPiece = React.createClass({
|
const PRRegisterPiece = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
// Provided from PrizeApp
|
||||||
|
currentUser: React.PropTypes.object,
|
||||||
|
whitelabel: React.PropTypes.object,
|
||||||
|
|
||||||
|
//Provided from router
|
||||||
location: object
|
location: object
|
||||||
},
|
},
|
||||||
|
|
||||||
mixins: [History],
|
mixins: [History],
|
||||||
|
|
||||||
getInitialState() {
|
|
||||||
return UserStore.getState();
|
|
||||||
},
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
UserStore.listen(this.onChange);
|
|
||||||
UserActions.fetchCurrentUser();
|
|
||||||
},
|
|
||||||
|
|
||||||
componentDidUpdate() {
|
componentDidUpdate() {
|
||||||
const { currentUser } = this.state;
|
const { currentUser } = this.props;
|
||||||
if(currentUser && currentUser.email) {
|
if (currentUser && currentUser.email) {
|
||||||
const submittedPieceId = getCookie(currentUser.email);
|
const submittedPieceId = getCookie(currentUser.email);
|
||||||
if(submittedPieceId) {
|
if (submittedPieceId) {
|
||||||
this.history.pushState(null, `/pieces/${submittedPieceId}`);
|
this.history.pushState(null, `/pieces/${submittedPieceId}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount() {
|
|
||||||
UserStore.unlisten(this.onChange);
|
|
||||||
},
|
|
||||||
|
|
||||||
onChange(state) {
|
|
||||||
this.setState(state);
|
|
||||||
},
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { currentUser } = this.state;
|
const { currentUser, location } = this.props;
|
||||||
const { location } = this.props;
|
|
||||||
|
|
||||||
setDocumentTitle(getLangText('Submit to Portfolio Review'));
|
setDocumentTitle(getLangText('Submit to Portfolio Review'));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Row>
|
<Row>
|
||||||
<Col xs={6}>
|
<Col xs={6}>
|
||||||
@ -77,7 +62,7 @@ const PRRegisterPiece = React.createClass({
|
|||||||
<Col xs={6}>
|
<Col xs={6}>
|
||||||
<PRRegisterPieceForm
|
<PRRegisterPieceForm
|
||||||
location={location}
|
location={location}
|
||||||
currentUser={currentUser}/>
|
currentUser={currentUser} />
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
);
|
);
|
||||||
|
@ -1,17 +1,21 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import GlobalNotification from '../../../global_notification';
|
|
||||||
|
|
||||||
import Hero from './components/pr_hero';
|
|
||||||
import Header from '../../../header';
|
|
||||||
|
|
||||||
import EventActions from '../../../../actions/event_actions';
|
import EventActions from '../../../../actions/event_actions';
|
||||||
|
|
||||||
import UserStore from '../../../../stores/user_store';
|
import UserStore from '../../../../stores/user_store';
|
||||||
import UserActions from '../../../../actions/user_actions';
|
import UserActions from '../../../../actions/user_actions';
|
||||||
|
|
||||||
import { getSubdomain } from '../../../../utils/general_utils';
|
import WhitelabelActions from '../../../../actions/whitelabel_actions';
|
||||||
|
import WhitelabelStore from '../../../../stores/whitelabel_store';
|
||||||
|
|
||||||
|
import AppRouteWrapper from '../../../app_route_wrapper';
|
||||||
|
import Hero from './components/pr_hero';
|
||||||
|
import Header from '../../../header';
|
||||||
|
import GlobalNotification from '../../../global_notification';
|
||||||
|
|
||||||
|
import { getSubdomain, mergeOptions } from '../../../../utils/general_utils';
|
||||||
import { getCookie } from '../../../../utils/fetch_api_utils';
|
import { getCookie } from '../../../../utils/fetch_api_utils';
|
||||||
|
|
||||||
|
|
||||||
@ -26,16 +30,23 @@ let PRApp = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return UserStore.getState();
|
return mergeOptions(
|
||||||
|
UserStore.getState(),
|
||||||
|
WhitelabelStore.getState()
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
UserStore.listen(this.onChange);
|
UserStore.listen(this.onChange);
|
||||||
|
WhitelabelStore.listen(this.onChange);
|
||||||
|
|
||||||
UserActions.fetchCurrentUser();
|
UserActions.fetchCurrentUser();
|
||||||
|
WhitelabelActions.fetchWhitelabel();
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
UserStore.unlisten(this.onChange);
|
UserStore.unlisten(this.onChange);
|
||||||
|
WhitelabelActions.unlisten(this.onChange);
|
||||||
},
|
},
|
||||||
|
|
||||||
onChange(state) {
|
onChange(state) {
|
||||||
@ -43,13 +54,20 @@ let PRApp = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { history, children, routes } = this.props;
|
const { children, history, routes } = this.props;
|
||||||
const { currentUser } = this.state;
|
const { currentUser, whitelabel } = this.state;
|
||||||
|
const subdomain = getSubdomain();
|
||||||
|
|
||||||
|
// Add the current user and whitelabel settings to all child routes
|
||||||
|
const childrenWithProps = React.Children.map(children, (child) => {
|
||||||
|
return React.cloneElement(child, {
|
||||||
|
currentUser,
|
||||||
|
whitelabel
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
let style = {};
|
let style = {};
|
||||||
let subdomain = getSubdomain();
|
|
||||||
let header;
|
let header;
|
||||||
|
|
||||||
|
|
||||||
if (currentUser && currentUser.email && history.isActive(`/pieces/${getCookie(currentUser.email)}`)) {
|
if (currentUser && currentUser.email && history.isActive(`/pieces/${getCookie(currentUser.email)}`)) {
|
||||||
header = <Hero currentUser={currentUser} />;
|
header = <Hero currentUser={currentUser} />;
|
||||||
style = { paddingTop: '0 !important' };
|
style = { paddingTop: '0 !important' };
|
||||||
@ -65,7 +83,12 @@ let PRApp = React.createClass({
|
|||||||
<div
|
<div
|
||||||
style={style}
|
style={style}
|
||||||
className={'container ascribe-prize-app client--' + subdomain}>
|
className={'container ascribe-prize-app client--' + subdomain}>
|
||||||
{children}
|
<AppRouteWrapper
|
||||||
|
currentUser={currentUser}
|
||||||
|
whitelabel={whitelabel}>
|
||||||
|
{/* Routes are injected here */}
|
||||||
|
{children}
|
||||||
|
</AppRouteWrapper>
|
||||||
<GlobalNotification />
|
<GlobalNotification />
|
||||||
<div id="modal" className="container"></div>
|
<div id="modal" className="container"></div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -31,7 +31,7 @@ import { AuthPrizeRoleRedirect } from './portfolioreview/components/pr_routes/pr
|
|||||||
const ROUTES = {
|
const ROUTES = {
|
||||||
sluice: (
|
sluice: (
|
||||||
<Route path='/' component={SPApp}>
|
<Route path='/' component={SPApp}>
|
||||||
<IndexRoute component={SPLanding} />
|
<IndexRoute component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(SPLanding)} />
|
||||||
<Route
|
<Route
|
||||||
path='login'
|
path='login'
|
||||||
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(SPLoginContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(SPLoginContainer)} />
|
||||||
@ -63,7 +63,7 @@ const ROUTES = {
|
|||||||
),
|
),
|
||||||
portfolioreview: (
|
portfolioreview: (
|
||||||
<Route path='/' component={PRApp}>
|
<Route path='/' component={PRApp}>
|
||||||
<IndexRoute component={ProxyHandler(AuthPrizeRoleRedirect({ to: '/collection', when: ['is_admin', 'is_judge', 'is_jury'] }))(PRLanding)} />
|
<IndexRoute component={ProxyHandler(AuthPrizeRoleRedirect({ to: '/collection', when: ['is_admin', 'is_judge', 'is_jury'] }))(PRLanding)} />
|
||||||
<Route
|
<Route
|
||||||
path='register_piece'
|
path='register_piece'
|
||||||
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(PRRegisterPiece)}/>
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(PRRegisterPiece)}/>
|
||||||
|
@ -19,9 +19,6 @@ import PieceStore from '../../../../../../stores/piece_store';
|
|||||||
import PieceListStore from '../../../../../../stores/piece_list_store';
|
import PieceListStore from '../../../../../../stores/piece_list_store';
|
||||||
import PieceListActions from '../../../../../../actions/piece_list_actions';
|
import PieceListActions from '../../../../../../actions/piece_list_actions';
|
||||||
|
|
||||||
import UserStore from '../../../../../../stores/user_store';
|
|
||||||
import UserActions from '../../../../../../actions/user_actions';
|
|
||||||
|
|
||||||
import Piece from '../../../../../../components/ascribe_detail/piece';
|
import Piece from '../../../../../../components/ascribe_detail/piece';
|
||||||
import Note from '../../../../../../components/ascribe_detail/note';
|
import Note from '../../../../../../components/ascribe_detail/note';
|
||||||
|
|
||||||
@ -53,8 +50,15 @@ import { setDocumentTitle } from '../../../../../../utils/dom_utils';
|
|||||||
*/
|
*/
|
||||||
let PrizePieceContainer = React.createClass({
|
let PrizePieceContainer = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
params: React.PropTypes.object,
|
selectedPrizeActionButton: React.PropTypes.func,
|
||||||
selectedPrizeActionButton: React.PropTypes.func
|
|
||||||
|
// Provided from PrizeApp
|
||||||
|
currentUser: React.PropTypes.object,
|
||||||
|
whitelabel: React.PropTypes.object,
|
||||||
|
|
||||||
|
//Provided from router
|
||||||
|
location: React.PropTypes.object,
|
||||||
|
params: React.PropTypes.object
|
||||||
},
|
},
|
||||||
|
|
||||||
mixins: [ReactError],
|
mixins: [ReactError],
|
||||||
@ -62,7 +66,7 @@ let PrizePieceContainer = React.createClass({
|
|||||||
getInitialState() {
|
getInitialState() {
|
||||||
//FIXME: this component uses the PieceStore, but we avoid using the getState() here since it may contain stale data
|
//FIXME: this component uses the PieceStore, but we avoid using the getState() here since it may contain stale data
|
||||||
// It should instead use something like getInitialState() where that call also resets the state.
|
// It should instead use something like getInitialState() where that call also resets the state.
|
||||||
return UserStore.getState();
|
return {};
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
@ -74,9 +78,7 @@ let PrizePieceContainer = React.createClass({
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
PieceStore.listen(this.onChange);
|
PieceStore.listen(this.onChange);
|
||||||
UserStore.listen(this.onChange);
|
|
||||||
|
|
||||||
UserActions.fetchCurrentUser();
|
|
||||||
this.loadPiece();
|
this.loadPiece();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -99,7 +101,6 @@ let PrizePieceContainer = React.createClass({
|
|||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
PieceStore.unlisten(this.onChange);
|
PieceStore.unlisten(this.onChange);
|
||||||
UserStore.unlisten(this.onChange);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onChange(state) {
|
onChange(state) {
|
||||||
@ -107,7 +108,8 @@ let PrizePieceContainer = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getActions() {
|
getActions() {
|
||||||
const { currentUser, piece } = this.state;
|
const { currentUser } = this.props;
|
||||||
|
const { piece } = this.state;
|
||||||
|
|
||||||
if (piece && piece.notifications && piece.notifications.length > 0) {
|
if (piece && piece.notifications && piece.notifications.length > 0) {
|
||||||
return (
|
return (
|
||||||
@ -124,8 +126,8 @@ let PrizePieceContainer = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { selectedPrizeActionButton } = this.props;
|
const { currentUser, selectedPrizeActionButton } = this.props;
|
||||||
const { currentUser, piece } = this.state;
|
const { piece } = this.state;
|
||||||
|
|
||||||
if (piece && piece.id) {
|
if (piece && piece.id) {
|
||||||
/*
|
/*
|
||||||
|
@ -1,57 +1,47 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { History } from 'react-router';
|
|
||||||
|
|
||||||
import PrizeActions from '../actions/prize_actions';
|
|
||||||
import PrizeStore from '../stores/prize_store';
|
|
||||||
|
|
||||||
import Button from 'react-bootstrap/lib/Button';
|
import Button from 'react-bootstrap/lib/Button';
|
||||||
import ButtonGroup from 'react-bootstrap/lib/ButtonGroup';
|
import ButtonGroup from 'react-bootstrap/lib/ButtonGroup';
|
||||||
|
|
||||||
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
||||||
|
|
||||||
import UserStore from '../../../../../stores/user_store';
|
import PrizeActions from '../actions/prize_actions';
|
||||||
import UserActions from '../../../../../actions/user_actions';
|
import PrizeStore from '../stores/prize_store';
|
||||||
|
|
||||||
import { mergeOptions } from '../../../../../utils/general_utils';
|
|
||||||
import { getLangText } from '../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../utils/lang_utils';
|
||||||
|
|
||||||
let Landing = React.createClass({
|
|
||||||
|
|
||||||
mixins: [History],
|
let Landing = React.createClass({
|
||||||
|
propTypes: {
|
||||||
|
// Provided from PrizeApp
|
||||||
|
currentUser: React.PropTypes.object,
|
||||||
|
whitelabel: React.PropTypes.object,
|
||||||
|
|
||||||
|
//Provided from router
|
||||||
|
location: React.PropTypes.object
|
||||||
|
},
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return mergeOptions(
|
return PrizeStore.getState();
|
||||||
PrizeStore.getState(),
|
|
||||||
UserStore.getState()
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
UserStore.listen(this.onChange);
|
|
||||||
UserActions.fetchCurrentUser();
|
|
||||||
PrizeStore.listen(this.onChange);
|
PrizeStore.listen(this.onChange);
|
||||||
PrizeActions.fetchPrize();
|
PrizeActions.fetchPrize();
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
UserStore.unlisten(this.onChange);
|
|
||||||
PrizeStore.unlisten(this.onChange);
|
PrizeStore.unlisten(this.onChange);
|
||||||
},
|
},
|
||||||
|
|
||||||
onChange(state) {
|
onChange(state) {
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
|
|
||||||
// if user is already logged in, redirect him to piece list
|
|
||||||
if(this.state.currentUser && this.state.currentUser.email) {
|
|
||||||
// FIXME: hack to redirect out of the dispatch cycle
|
|
||||||
window.setTimeout(() => this.history.replaceState(null, '/collection'), 0);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getButtons() {
|
getButtons() {
|
||||||
if (this.state.prize && this.state.prize.active){
|
if (this.state.prize && this.state.prize.active) {
|
||||||
return (
|
return (
|
||||||
<ButtonGroup className="enter" bsSize="large" vertical>
|
<ButtonGroup className="enter" bsSize="large" vertical>
|
||||||
<LinkContainer to="/signup">
|
<LinkContainer to="/signup">
|
||||||
@ -70,39 +60,37 @@ let Landing = React.createClass({
|
|||||||
</LinkContainer>
|
</LinkContainer>
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
return (
|
return (
|
||||||
<ButtonGroup className="enter" bsSize="large" vertical>
|
<ButtonGroup className="enter" bsSize="large" vertical>
|
||||||
<a className="btn btn-default" href="https://www.ascribe.io/app/signup">
|
<a className="btn btn-default" href="https://www.ascribe.io/app/signup">
|
||||||
{getLangText('Sign up to ascribe')}
|
{getLangText('Sign up to ascribe')}
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
{getLangText('or, already an ascribe user?')}
|
{getLangText('or, already an ascribe user?')}
|
||||||
</p>
|
</p>
|
||||||
<LinkContainer to="/login">
|
<LinkContainer to="/login">
|
||||||
<Button>
|
<Button>
|
||||||
{getLangText('Log in')}
|
{getLangText('Log in')}
|
||||||
</Button>
|
</Button>
|
||||||
</LinkContainer>
|
</LinkContainer>
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getTitle() {
|
getTitle() {
|
||||||
if (this.state.prize && this.state.prize.active){
|
const { prize } = this.state;
|
||||||
return (
|
|
||||||
<p>
|
|
||||||
{getLangText('This is the submission page for Sluice_screens ↄc Prize 2015.')}
|
|
||||||
</p>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<p>
|
<p>
|
||||||
{getLangText('Submissions for Sluice_screens ↄc Prize 2015 are now closed.')}
|
{getLangText(prize && prize.active ? 'This is the submission page for Sluice_screens ↄc Prize 2015.'
|
||||||
|
: 'Submissions for Sluice_screens ↄc Prize 2015 are now closed.')}
|
||||||
</p>
|
</p>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="container">
|
<div className="container">
|
||||||
|
@ -11,6 +11,11 @@ import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
|||||||
|
|
||||||
let LoginContainer = React.createClass({
|
let LoginContainer = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
// Provided from PrizeApp
|
||||||
|
currentUser: React.PropTypes.object,
|
||||||
|
whitelabel: React.PropTypes.object,
|
||||||
|
|
||||||
|
//Provided from router
|
||||||
location: React.PropTypes.object
|
location: React.PropTypes.object
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1,19 +1,15 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PieceList from '../../../../piece_list';
|
|
||||||
|
|
||||||
import UserActions from '../../../../../actions/user_actions';
|
import Button from 'react-bootstrap/lib/Button';
|
||||||
import UserStore from '../../../../../stores/user_store';
|
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
||||||
|
|
||||||
import PrizeActions from '../actions/prize_actions';
|
import PrizeActions from '../actions/prize_actions';
|
||||||
import PrizeStore from '../stores/prize_store';
|
import PrizeStore from '../stores/prize_store';
|
||||||
|
|
||||||
import Button from 'react-bootstrap/lib/Button';
|
|
||||||
|
|
||||||
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
|
||||||
|
|
||||||
import AccordionListItemPrize from './ascribe_accordion_list/accordion_list_item_prize';
|
import AccordionListItemPrize from './ascribe_accordion_list/accordion_list_item_prize';
|
||||||
|
import PieceList from '../../../../piece_list';
|
||||||
|
|
||||||
import { mergeOptions } from '../../../../../utils/general_utils';
|
import { mergeOptions } from '../../../../../utils/general_utils';
|
||||||
import { getLangText } from '../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../utils/lang_utils';
|
||||||
@ -21,25 +17,24 @@ import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
|||||||
|
|
||||||
let PrizePieceList = React.createClass({
|
let PrizePieceList = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
// Provided from PrizeApp
|
||||||
|
currentUser: React.PropTypes.object,
|
||||||
|
whitelabel: React.PropTypes.object,
|
||||||
|
|
||||||
|
//Provided from router
|
||||||
location: React.PropTypes.object
|
location: React.PropTypes.object
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return mergeOptions(
|
return PrizeStore.getState();
|
||||||
PrizeStore.getState(),
|
|
||||||
UserStore.getState()
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
UserStore.listen(this.onChange);
|
|
||||||
UserActions.fetchCurrentUser();
|
|
||||||
PrizeStore.listen(this.onChange);
|
PrizeStore.listen(this.onChange);
|
||||||
PrizeActions.fetchPrize();
|
PrizeActions.fetchPrize();
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
UserStore.unlisten(this.onChange);
|
|
||||||
PrizeStore.unlisten(this.onChange);
|
PrizeStore.unlisten(this.onChange);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -48,7 +43,8 @@ let PrizePieceList = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getButtonSubmit() {
|
getButtonSubmit() {
|
||||||
const { currentUser, prize } = this.state;
|
const { currentUser } = this.props;
|
||||||
|
const { prize } = this.state;
|
||||||
if (prize && prize.active && !currentUser.is_jury && !currentUser.is_admin && !currentUser.is_judge) {
|
if (prize && prize.active && !currentUser.is_jury && !currentUser.is_admin && !currentUser.is_judge) {
|
||||||
return (
|
return (
|
||||||
<LinkContainer to="/register_piece">
|
<LinkContainer to="/register_piece">
|
||||||
@ -57,32 +53,34 @@ let PrizePieceList = React.createClass({
|
|||||||
</Button>
|
</Button>
|
||||||
</LinkContainer>
|
</LinkContainer>
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const { currentUser, location } = this.props;
|
||||||
|
|
||||||
setDocumentTitle(getLangText('Collection'));
|
setDocumentTitle(getLangText('Collection'));
|
||||||
|
|
||||||
let orderParams = ['artist_name', 'title'];
|
let orderParams = ['artist_name', 'title'];
|
||||||
if (this.state.currentUser.is_jury) {
|
if (currentUser.is_jury) {
|
||||||
orderParams = ['rating', 'title'];
|
orderParams = ['rating', 'title'];
|
||||||
}
|
}
|
||||||
if (this.state.currentUser.is_judge) {
|
if (currentUser.is_judge) {
|
||||||
orderParams = ['rating', 'title', 'selected'];
|
orderParams = ['rating', 'title', 'selected'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<PieceList
|
||||||
<PieceList
|
ref="list"
|
||||||
ref="list"
|
{...this.props}
|
||||||
redirectTo="/register_piece"
|
redirectTo="/register_piece"
|
||||||
accordionListItemType={AccordionListItemPrize}
|
accordionListItemType={AccordionListItemPrize}
|
||||||
orderParams={orderParams}
|
orderParams={orderParams}
|
||||||
orderBy={this.state.currentUser.is_jury ? 'rating' : null}
|
orderBy={currentUser.is_jury ? 'rating' : null}
|
||||||
filterParams={[]}
|
filterParams={[]}
|
||||||
customSubmitButton={this.getButtonSubmit()}
|
customSubmitButton={this.getButtonSubmit()} />
|
||||||
location={this.props.location}/>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -16,6 +16,11 @@ import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
|||||||
|
|
||||||
let PrizeRegisterPiece = React.createClass({
|
let PrizeRegisterPiece = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
// Provided from PrizeApp
|
||||||
|
currentUser: React.PropTypes.object,
|
||||||
|
whitelabel: React.PropTypes.object,
|
||||||
|
|
||||||
|
//Provided from router
|
||||||
location: React.PropTypes.object
|
location: React.PropTypes.object
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -38,62 +43,61 @@ let PrizeRegisterPiece = React.createClass({
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { location } = this.props;
|
const { location } = this.props;
|
||||||
|
const { prize } = this.state;
|
||||||
|
|
||||||
setDocumentTitle(getLangText('Submit to the prize'));
|
setDocumentTitle(getLangText('Submit to the prize'));
|
||||||
|
|
||||||
if(this.state.prize && this.state.prize.active){
|
if (prize && prize.active) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<RegisterPiece
|
||||||
<RegisterPiece
|
{...this.props}
|
||||||
enableLocalHashing={false}
|
enableLocalHashing={false}
|
||||||
headerMessage={''}
|
headerMessage={''}
|
||||||
submitMessage={getLangText('Submit')}
|
submitMessage={getLangText('Submit')}
|
||||||
location={location}>
|
location={location}>
|
||||||
<Property
|
<Property
|
||||||
name='artist_statement'
|
name='artist_statement'
|
||||||
label={getLangText('Artist statement')}
|
label={getLangText('Artist statement')}
|
||||||
editable={true}
|
editable={true}
|
||||||
overrideForm={true}>
|
overrideForm={true}>
|
||||||
<InputTextAreaToggable
|
<InputTextAreaToggable
|
||||||
rows={1}
|
rows={1}
|
||||||
placeholder={getLangText('Enter your statement')}
|
placeholder={getLangText('Enter your statement')}
|
||||||
required />
|
required />
|
||||||
</Property>
|
</Property>
|
||||||
<Property
|
<Property
|
||||||
name='work_description'
|
name='work_description'
|
||||||
label={getLangText('Work description')}
|
label={getLangText('Work description')}
|
||||||
editable={true}
|
editable={true}
|
||||||
overrideForm={true}>
|
overrideForm={true}>
|
||||||
<InputTextAreaToggable
|
<InputTextAreaToggable
|
||||||
rows={1}
|
rows={1}
|
||||||
placeholder={getLangText('Enter the description for your work')}
|
placeholder={getLangText('Enter the description for your work')}
|
||||||
required />
|
required />
|
||||||
</Property>
|
</Property>
|
||||||
<Property
|
<Property
|
||||||
name="terms"
|
name="terms"
|
||||||
className="ascribe-property-collapsible-toggle"
|
className="ascribe-property-collapsible-toggle"
|
||||||
style={{paddingBottom: 0}}>
|
style={{paddingBottom: 0}}>
|
||||||
<InputCheckbox>
|
<InputCheckbox>
|
||||||
<span>
|
<span>
|
||||||
{' ' + getLangText('I agree to the Terms of Service the art price') + ' '}
|
{' ' + getLangText('I agree to the Terms of Service the art price') + ' '}
|
||||||
(<a href="https://s3-us-west-2.amazonaws.com/ascribe0/whitelabel/sluice/terms.pdf" target="_blank" style={{fontSize: '0.9em', color: 'rgba(0,0,0,0.7)'}}>
|
(<a href="https://s3-us-west-2.amazonaws.com/ascribe0/whitelabel/sluice/terms.pdf" target="_blank" style={{fontSize: '0.9em', color: 'rgba(0,0,0,0.7)'}}>
|
||||||
{getLangText('read')}
|
{getLangText('read')}
|
||||||
</a>)
|
</a>)
|
||||||
</span>
|
</span>
|
||||||
</InputCheckbox>
|
</InputCheckbox>
|
||||||
</Property>
|
</Property>
|
||||||
</RegisterPiece>
|
</RegisterPiece>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return (
|
return (
|
||||||
<div className='row'>
|
<div className='row'>
|
||||||
<div style={{textAlign: 'center'}}>
|
<div style={{textAlign: 'center'}}>
|
||||||
{getLangText('The prize is no longer active')}
|
{getLangText('The prize is no longer active')}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import UserStore from '../../../../../stores/user_store';
|
|
||||||
import UserActions from '../../../../../actions/user_actions';
|
|
||||||
import PrizeActions from '../actions/prize_actions';
|
import PrizeActions from '../actions/prize_actions';
|
||||||
import PrizeStore from '../stores/prize_store';
|
import PrizeStore from '../stores/prize_store';
|
||||||
import PrizeJuryActions from '../actions/prize_jury_actions';
|
import PrizeJuryActions from '../actions/prize_jury_actions';
|
||||||
@ -28,40 +26,27 @@ import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
|||||||
|
|
||||||
|
|
||||||
let Settings = React.createClass({
|
let Settings = React.createClass({
|
||||||
getInitialState() {
|
propTypes: {
|
||||||
return UserStore.getState();
|
// Provided from PrizeApp
|
||||||
},
|
currentUser: React.PropTypes.object,
|
||||||
|
whitelabel: React.PropTypes.object,
|
||||||
|
|
||||||
componentDidMount() {
|
//Provided from router
|
||||||
UserStore.listen(this.onChange);
|
location: React.PropTypes.object
|
||||||
UserActions.fetchCurrentUser();
|
|
||||||
},
|
|
||||||
|
|
||||||
componentWillUnmount() {
|
|
||||||
UserStore.unlisten(this.onChange);
|
|
||||||
},
|
|
||||||
|
|
||||||
onChange(state) {
|
|
||||||
this.setState(state);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
setDocumentTitle(getLangText('Account settings'));
|
setDocumentTitle(getLangText('Account settings'));
|
||||||
|
|
||||||
let prizeSettings = null;
|
|
||||||
if (this.state.currentUser.is_admin){
|
|
||||||
prizeSettings = <PrizeSettings />;
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<SettingsContainer>
|
<SettingsContainer {...this.props}>
|
||||||
{prizeSettings}
|
{this.props.currentUser.is_admin ? <PrizeSettings /> : null}
|
||||||
</SettingsContainer>
|
</SettingsContainer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let PrizeSettings = React.createClass({
|
let PrizeSettings = React.createClass({
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return PrizeStore.getState();
|
return PrizeStore.getState();
|
||||||
},
|
},
|
||||||
|
@ -8,6 +8,11 @@ import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
|||||||
|
|
||||||
let SignupContainer = React.createClass({
|
let SignupContainer = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
// Provided from PrizeApp
|
||||||
|
currentUser: React.PropTypes.object,
|
||||||
|
whitelabel: React.PropTypes.object,
|
||||||
|
|
||||||
|
//Provided from router
|
||||||
location: React.PropTypes.object
|
location: React.PropTypes.object
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -18,7 +23,7 @@ let SignupContainer = React.createClass({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSuccess(message){
|
handleSuccess(message) {
|
||||||
this.setState({
|
this.setState({
|
||||||
submitted: true,
|
submitted: true,
|
||||||
message: message
|
message: message
|
||||||
@ -26,13 +31,15 @@ let SignupContainer = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const { location } = this.props;
|
||||||
|
const { message, submitted } = this.state;
|
||||||
setDocumentTitle(getLangText('Sign up'));
|
setDocumentTitle(getLangText('Sign up'));
|
||||||
|
|
||||||
if (this.state.submitted){
|
if (submitted) {
|
||||||
return (
|
return (
|
||||||
<div className="ascribe-login-wrapper">
|
<div className="ascribe-login-wrapper">
|
||||||
<div className="ascribe-login-text ascribe-login-header">
|
<div className="ascribe-login-text ascribe-login-header">
|
||||||
{this.state.message}
|
{message}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -43,7 +50,7 @@ let SignupContainer = React.createClass({
|
|||||||
headerMessage={getLangText('Create account for submission')}
|
headerMessage={getLangText('Create account for submission')}
|
||||||
submitMessage={getLangText('Sign up')}
|
submitMessage={getLangText('Sign up')}
|
||||||
handleSuccess={this.handleSuccess}
|
handleSuccess={this.handleSuccess}
|
||||||
location={this.props.location}/>
|
location={location} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,21 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
import UserStore from '../../../../stores/user_store';
|
||||||
|
import UserActions from '../../../../actions/user_actions';
|
||||||
|
|
||||||
|
import WhitelabelActions from '../../../../actions/whitelabel_actions';
|
||||||
|
import WhitelabelStore from '../../../../stores/whitelabel_store';
|
||||||
|
|
||||||
import Hero from './components/prize_hero';
|
import Hero from './components/prize_hero';
|
||||||
|
|
||||||
|
import AppRouteWrapper from '../../../app_route_wrapper';
|
||||||
import Header from '../../../header';
|
import Header from '../../../header';
|
||||||
import Footer from '../../../footer';
|
import Footer from '../../../footer';
|
||||||
import GlobalNotification from '../../../global_notification';
|
import GlobalNotification from '../../../global_notification';
|
||||||
|
|
||||||
import { getSubdomain } from '../../../../utils/general_utils';
|
import { getSubdomain, mergeOptions } from '../../../../utils/general_utils';
|
||||||
|
|
||||||
|
|
||||||
let PrizeApp = React.createClass({
|
let PrizeApp = React.createClass({
|
||||||
@ -19,15 +28,40 @@ let PrizeApp = React.createClass({
|
|||||||
routes: React.PropTypes.arrayOf(React.PropTypes.object)
|
routes: React.PropTypes.arrayOf(React.PropTypes.object)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getInitialState() {
|
||||||
|
return mergeOptions(
|
||||||
|
UserStore.getState(),
|
||||||
|
WhitelabelStore.getState()
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
UserStore.listen(this.onChange);
|
||||||
|
WhitelabelStore.listen(this.onChange);
|
||||||
|
|
||||||
|
UserActions.fetchCurrentUser();
|
||||||
|
WhitelabelActions.fetchWhitelabel();
|
||||||
|
},
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
UserStore.unlisten(this.onChange);
|
||||||
|
WhitelabelActions.unlisten(this.onChange);
|
||||||
|
},
|
||||||
|
|
||||||
|
onChange(state) {
|
||||||
|
this.setState(state);
|
||||||
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { history, routes } = this.props;
|
const { history, routes, children } = this.props;
|
||||||
let header = null;
|
const { currentUser, whitelabel } = this.state;
|
||||||
let subdomain = getSubdomain();
|
const subdomain = getSubdomain();
|
||||||
|
|
||||||
// The second element of routes is always the active component object, where we can
|
// The second element of routes is always the active component object, where we can
|
||||||
// extract the path.
|
// extract the path.
|
||||||
let path = routes[1] ? routes[1].path : null;
|
let path = routes[1] ? routes[1].path : null;
|
||||||
|
|
||||||
|
let header = null;
|
||||||
// if the path of the current activeRoute is not defined, then this is the IndexRoute
|
// if the path of the current activeRoute is not defined, then this is the IndexRoute
|
||||||
if (!path || history.isActive('/login') || history.isActive('/signup')) {
|
if (!path || history.isActive('/login') || history.isActive('/signup')) {
|
||||||
header = <Hero />;
|
header = <Hero />;
|
||||||
@ -38,10 +72,15 @@ let PrizeApp = React.createClass({
|
|||||||
return (
|
return (
|
||||||
<div className={'container ascribe-prize-app client--' + subdomain}>
|
<div className={'container ascribe-prize-app client--' + subdomain}>
|
||||||
{header}
|
{header}
|
||||||
{this.props.children}
|
<AppRouteWrapper
|
||||||
|
currentUser={currentUser}
|
||||||
|
whitelabel={whitelabel}>
|
||||||
|
{/* Routes are injected here */}
|
||||||
|
{children}
|
||||||
|
</AppRouteWrapper>
|
||||||
|
<Footer />
|
||||||
<GlobalNotification />
|
<GlobalNotification />
|
||||||
<div id="modal" className="container"></div>
|
<div id="modal" className="container"></div>
|
||||||
<Footer />
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,12 @@ import PrizePieceContainer from '../../../simple_prize/components/ascribe_detail
|
|||||||
|
|
||||||
const SluicePieceContainer = React.createClass({
|
const SluicePieceContainer = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
// Provided from PrizeApp
|
||||||
|
currentUser: React.PropTypes.object,
|
||||||
|
whitelabel: React.PropTypes.object,
|
||||||
|
|
||||||
|
//Provided from router
|
||||||
|
location: React.PropTypes.object,
|
||||||
params: React.PropTypes.object
|
params: React.PropTypes.object
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user