mirror of
https://github.com/gosticks/plane.git
synced 2025-10-16 12:45:33 +00:00
* chore(repo): migrate to pnpm * chore(repo): cleanup pnpm integration with turbo * chore(repo): run lint * chore(repo): cleanup tsconfigs * chore: align TypeScript to 5.8.3 across monorepo; update pnpm override and catalog; pnpm install to update lockfile * chore(repo): revert logger.ts changes * fix: type errors * fix: build errors * fix: pnpm home setup in dockerfiles --------- Co-authored-by: sriramveeraghanta <veeraghanta.sriram@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com>
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
"use client";
|
|
|
|
import React, { FC, useEffect } from "react";
|
|
import { Intercom, show, hide, onHide } from "@intercom/messenger-js-sdk";
|
|
import { observer } from "mobx-react";
|
|
// store hooks
|
|
import { useInstance } from "@/hooks/store/use-instance";
|
|
import { useTransient } from "@/hooks/store/use-transient";
|
|
import { useUser } from "@/hooks/store/user";
|
|
|
|
export type IntercomProviderProps = {
|
|
children: React.ReactNode;
|
|
};
|
|
|
|
const IntercomProvider: FC<IntercomProviderProps> = observer((props) => {
|
|
const { children } = props;
|
|
// hooks
|
|
const { data: user } = useUser();
|
|
const { config } = useInstance();
|
|
const { isIntercomToggle, toggleIntercom } = useTransient();
|
|
|
|
useEffect(() => {
|
|
if (isIntercomToggle) show();
|
|
else hide();
|
|
}, [isIntercomToggle]);
|
|
|
|
onHide(() => {
|
|
toggleIntercom(false);
|
|
});
|
|
|
|
useEffect(() => {
|
|
if (user && config?.is_intercom_enabled && config.intercom_app_id) {
|
|
Intercom({
|
|
app_id: config.intercom_app_id || "",
|
|
user_id: user.id,
|
|
name: `${user.first_name} ${user.last_name}`,
|
|
email: user.email,
|
|
hide_default_launcher: true,
|
|
});
|
|
}
|
|
}, [user, config, toggleIntercom]);
|
|
|
|
return <>{children}</>;
|
|
});
|
|
|
|
export default IntercomProvider;
|