CAL-469 Adds intercom dynamically (#762)

* Adds react-use-intercom

* Adds intercom env var

* Loads intercom dynamically if env is set

* CAL-473 Fixes client-side routing for authed pages

* Moves intercom code to ee

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Omar Lópezandkodiakhq[bot] authored and GitHub committed 2021-09-24 21:02:03 +01:00
1 parent 889b3f36ae
commit 9e7cb2c0b8
10 files changed
+80 -5

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
import { Menu } from "@headlessui/react";
import { ChatAltIcon } from "@heroicons/react/solid";
import { useIntercom } from "react-use-intercom";
import classNames from "@lib/classNames";
const HelpMenuItem = () => {
const { boot, show } = useIntercom();
return (
<Menu.Item>
{({ active }) => (
<button
onClick={() => {
boot();
show();
}}
className={classNames(
active ? "bg-gray-100 text-gray-900" : "text-neutral-700",
"w-full flex px-4 py-2 text-sm font-medium"
)}>
<ChatAltIcon
className={classNames(
"text-neutral-400 group-hover:text-neutral-500",
"mr-2 flex-shrink-0 h-5 w-5"
)}
aria-hidden="true"
/>
Help
</button>
)}
</Menu.Item>
);
};
export default HelpMenuItem;
+8
View File
@@ -0,0 +1,8 @@
import dynamic from "next/dynamic";
import { Fragment } from "react";
const HelpMenuItemDynamic = process.env.NEXT_PUBLIC_INTERCOM_APP_ID
? dynamic(() => import("./HelpMenuItem"))
: Fragment;
export default HelpMenuItemDynamic;
+8
View File
@@ -0,0 +1,8 @@
import { FC } from "react";
import { IntercomProvider } from "react-use-intercom";
const Provider: FC = ({ children }) => (
<IntercomProvider appId={process.env.NEXT_PUBLIC_INTERCOM_APP_ID!}>{children}</IntercomProvider>
);
export default Provider;
+8
View File
@@ -0,0 +1,8 @@
import dynamic from "next/dynamic";
import { Fragment } from "react";
const DynamicIntercomProvider = process.env.NEXT_PUBLIC_INTERCOM_APP_ID
? dynamic(() => import("./provider"))
: Fragment;
export default DynamicIntercomProvider;