diff --git a/js/components/header.js b/js/components/header.js index c18ebd5b..797684ec 100644 --- a/js/components/header.js +++ b/js/components/header.js @@ -16,12 +16,13 @@ import LinkContainer from 'react-router-bootstrap/lib/LinkContainer'; import AclProxy from './acl_proxy'; +import EventActions from '../actions/event_actions'; + import UserActions from '../actions/user_actions'; import UserStore from '../stores/user_store'; import WhitelabelActions from '../actions/whitelabel_actions'; import WhitelabelStore from '../stores/whitelabel_store'; -import EventActions from '../actions/event_actions'; import HeaderNotifications from './header_notification'; @@ -58,6 +59,19 @@ let Header = React.createClass({ // close the mobile expanded navigation after a click by itself. // To get rid of this, we set the state of the component ourselves. history.listen(this.onRouteChange); + + if (this.state.currentUser && this.state.currentUser.email) { + EventActions.profileDidLoad.defer(this.state.currentUser); + } + }, + + componentWillUpdate(nextProps, nextState) { + const { currentUser: { email: curEmail } = {} } = this.state; + const { currentUser: { email: nextEmail } = {} } = nextState; + + if (nextEmail && curEmail !== nextEmail) { + EventActions.profileDidLoad.defer(nextState.currentUser); + } }, componentWillUnmount() { @@ -105,10 +119,6 @@ let Header = React.createClass({ onChange(state) { this.setState(state); - - if(this.state.currentUser && this.state.currentUser.email) { - EventActions.profileDidLoad.defer(this.state.currentUser); - } }, onMenuItemClick() { diff --git a/js/components/whitelabel/prize/portfolioreview/components/pr_hero.js b/js/components/whitelabel/prize/portfolioreview/components/pr_hero.js index 0ef99c37..15d32b84 100644 --- a/js/components/whitelabel/prize/portfolioreview/components/pr_hero.js +++ b/js/components/whitelabel/prize/portfolioreview/components/pr_hero.js @@ -5,32 +5,18 @@ import { Link } from 'react-router'; import Glyphicon from 'react-bootstrap/lib/Glyphicon'; -import UserStore from '../../../../../stores/user_store'; -import UserActions from '../../../../../actions/user_actions'; - import { getLangText } from '../../../../../utils/lang_utils'; const PRHero = React.createClass({ - getInitialState() { - return UserStore.getState(); - }, - - componentDidMount() { - UserStore.listen(this.onChange); - UserActions.fetchCurrentUser.defer(); - }, - - componentWillUnmount() { - UserStore.unlisten(this.onChange); - }, - - onChange(state) { - this.setState(state); + propTypes: { + currentUser: React.PropTypes.shape({ + email: React.PropTypes.object + }) }, render() { - const { currentUser } = this.state; + const { currentUser } = this.props; return (
diff --git a/js/components/whitelabel/prize/portfolioreview/pr_app.js b/js/components/whitelabel/prize/portfolioreview/pr_app.js index ef85bfd5..c672bdf5 100644 --- a/js/components/whitelabel/prize/portfolioreview/pr_app.js +++ b/js/components/whitelabel/prize/portfolioreview/pr_app.js @@ -6,6 +6,8 @@ import GlobalNotification from '../../../global_notification'; import Hero from './components/pr_hero'; import Header from '../../../header'; +import EventActions from '../../../../actions/event_actions'; + import UserStore from '../../../../stores/user_store'; import UserActions from '../../../../actions/user_actions'; @@ -30,6 +32,19 @@ let PRApp = React.createClass({ componentDidMount() { UserStore.listen(this.onChange); UserActions.fetchCurrentUser(); + + if (this.state.currentUser && this.state.currentUser.email) { + EventActions.profileDidLoad.defer(this.state.currentUser); + } + }, + + componentWillUpdate(nextProps, nextState) { + const { currentUser: { email: curEmail } = {} } = this.state; + const { currentUser: { email: nextEmail } = {} } = nextState; + + if (nextEmail && curEmail !== nextEmail) { + EventActions.profileDidLoad.defer(nextState.currentUser); + } }, componentWillUnmount() { @@ -49,7 +64,7 @@ let PRApp = React.createClass({ if (currentUser && currentUser.email && history.isActive(`/pieces/${getCookie(currentUser.email)}`)) { - header = ; + header = ; style = { paddingTop: '0 !important' }; } else if(currentUser && (currentUser.is_admin || currentUser.is_jury || currentUser.is_judge)) { header =
; diff --git a/sass/whitelabel/prize/portfolioreview/portfolioreview_custom_style.scss b/sass/whitelabel/prize/portfolioreview/portfolioreview_custom_style.scss index 7e19cd71..0759cf49 100644 --- a/sass/whitelabel/prize/portfolioreview/portfolioreview_custom_style.scss +++ b/sass/whitelabel/prize/portfolioreview/portfolioreview_custom_style.scss @@ -145,4 +145,10 @@ $pr--button-color: $pr--nav-fg-prim-color; text-transform: capitalize; } } -} \ No newline at end of file + + // intercom + #intercom-container .intercom-launcher-button { + background-color: $pr--button-color !important; + border-color: $pr--button-color !important; + } +}