Fire profileDidLoad event in PR to load intercom

This commit is contained in:
Brett Sun 2015-12-14 16:30:38 +01:00
parent d9615188b0
commit 5aaf02b0b4
4 changed files with 43 additions and 26 deletions

View File

@ -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() {

View File

@ -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 (
<div className="piece--hero">

View File

@ -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 = <Hero />;
header = <Hero currentUser={currentUser} />;
style = { paddingTop: '0 !important' };
} else if(currentUser && (currentUser.is_admin || currentUser.is_jury || currentUser.is_judge)) {
header = <Header routes={routes} />;

View File

@ -145,4 +145,10 @@ $pr--button-color: $pr--nav-fg-prim-color;
text-transform: capitalize;
}
}
}
// intercom
#intercom-container .intercom-launcher-button {
background-color: $pr--button-color !important;
border-color: $pr--button-color !important;
}
}