Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Commit

Permalink
Intercom integration
Browse files Browse the repository at this point in the history
  • Loading branch information
artkravchenko committed Mar 25, 2017
1 parent 9d44f0b commit b82a37c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/auth-block.js
Expand Up @@ -21,19 +21,24 @@ import { Link } from 'react-router';
import { CurrentUser as CurrentUserPropType } from '../prop-types/users';
import { API_HOST } from '../config';
import { URL_NAMES, getUrl } from '../utils/urlGenerator';
import { IntercomAPI } from './intercom';

import Avatar from './user/avatar';
import { v2 as Dropdown } from './dropdown';
import MenuItem from './menu-item';

function handleLogout() {
IntercomAPI('shutdown');
}

const menuItems = username => ([
{ key: 'profile',
node: <Link to={getUrl(URL_NAMES.USER, { username })}>My profile</Link> },
{ key: 'settings',
node: <Link to={getUrl(URL_NAMES.SETTINGS)}>Profile settings</Link> },
{ key: 'logout',
node: (
<form action={`${API_HOST}/api/v1/logout`} method="post">
<form action={`${API_HOST}/api/v1/logout`} method="post" onSubmit={handleLogout}>
<button
className="button button-transparent button-wide button-caption_left"
type="submit"
Expand Down
13 changes: 13 additions & 0 deletions src/pages/app.js
Expand Up @@ -20,6 +20,8 @@ import ga from 'react-google-analytics';
import Helmet from 'react-helmet';

import { ActionsTrigger } from '../triggers';
import { INTERCOM_APP_ID } from '../config';
import WrappedIntercom from '../components/intercom';

const GAInitializer = ga.Initializer;

Expand Down Expand Up @@ -48,6 +50,10 @@ export default class App extends React.Component {
}
}

shouldComponentUpdate(nextProps) {
return nextProps.children !== this.props.children;
}

render() {
const { children } = this.props;

Expand All @@ -56,11 +62,18 @@ export default class App extends React.Component {
gaContent = <GAInitializer />;
}

let url = '';
if (this.props.location) {
url = this.props.location.pathname
.concat(this.props.location.search);
}

return (
<div className="page">
<Helmet title="" titleTemplate="%sLibertySoil.org" />
{children}
{gaContent}
<WrappedIntercom app_id={INTERCOM_APP_ID} url={url} />
</div>
);
}
Expand Down

0 comments on commit b82a37c

Please sign in to comment.