Skip to content

Commit

Permalink
Merge pull request #802 from filecoin-project/@jasonleyser/intercom
Browse files Browse the repository at this point in the history
Intercom user data
  • Loading branch information
martinalong committed Jul 2, 2021
2 parents 4d1c7de + 44cbddf commit 788913b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 18 deletions.
33 changes: 24 additions & 9 deletions components/core/ApplicationUserControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,25 @@ const STYLES_ITEM_BOX = css`
}
`;

const OpenIntercom = ({ user }) => {
const { show } = useIntercom();

const showWithProps = () =>
show({
name: user.data.name || user.username,
});
const OpenIntercom = ({ user, onTogglePopup }) => {
const { show, update } = useIntercom();

return (
<span style={{ cursor: "pointer", display: "block" }} onClick={() => showWithProps()}>
<span
style={{ cursor: "pointer", display: "block" }}
onClick={() => {
onTogglePopup();
update({
name: user.data.name,
email: user.email,
customAttributes: {
slate_userid: user.id,
username: user.username,
},
});
show();
}}
>
Help
</span>
);
Expand Down Expand Up @@ -229,7 +238,13 @@ export class ApplicationUserControlsPopup extends React.Component {
],
[
{
text: <OpenIntercom style={{ display: "block" }} user={this.props.viewer} />,
text: (
<OpenIntercom
style={{ display: "block" }}
user={this.props.viewer}
onTogglePopup={this.props.onTogglePopup}
/>
),
},
{
text: "Sign out",
Expand Down
22 changes: 16 additions & 6 deletions components/core/SearchModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,24 @@ const FilePreview = ({ file, slate, user, viewerId }) => {
};

const OpenIntercom = ({ user }) => {
const { show } = useIntercom();

const showWithProps = () => show({
name: user.data.name || user.username,
});
const { show, update } = useIntercom();

return(
<span style={{ marginRight: 24, cursor: "pointer" }} onClick={() => showWithProps()}>
<span
style={{ marginRight: 24, cursor: "pointer" }}
onClick={() => {
update({
name: user.data.name,
email: user.email,
customAttributes: {
slate_userid: user.id,
username: user.username
}
});
show()
}
}
>
Contact Us
</span>
);
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 788913b

Please sign in to comment.