mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-12 11:26:07 +03:00
04d6c3432f
# Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate):
36 lines
727 B
TypeScript
36 lines
727 B
TypeScript
import { usePathname } from "next/navigation";
|
|
import { useEffect } from "react";
|
|
|
|
import { useUserData } from "@/lib/hooks/useUserData";
|
|
|
|
import {
|
|
boot as bootIntercom,
|
|
load as loadIntercom,
|
|
update as updateIntercom,
|
|
} from "./intercom";
|
|
|
|
export const IntercomProvider = ({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode;
|
|
}): React.ReactNode => {
|
|
const pathname = usePathname();
|
|
const { userData } = useUserData();
|
|
|
|
if (
|
|
typeof window !== "undefined" &&
|
|
process.env.NEXT_PUBLIC_INTERCOM_APP_ID
|
|
) {
|
|
loadIntercom();
|
|
bootIntercom(userData?.email ?? "");
|
|
}
|
|
|
|
useEffect(() => {
|
|
if (process.env.NEXT_PUBLIC_INTERCOM_APP_ID) {
|
|
updateIntercom();
|
|
}
|
|
}, [pathname]);
|
|
|
|
return children;
|
|
};
|