import React, { useEffect, useState } from "react";
import { HELP_MODAL_WIDTH } from "constants/HelpConstants";
import AnalyticsUtil from "utils/AnalyticsUtil";
import { getCurrentUser } from "selectors/usersSelectors";
import { useDispatch, useSelector } from "react-redux";
import bootIntercom, { updateIntercomProperties } from "utils/bootIntercom";
import {
APPSMITH_DISPLAY_VERSION,
CONTINUE,
createMessage,
HELP_RESOURCE_TOOLTIP,
INTERCOM_CONSENT_MESSAGE,
} from "@appsmith/constants/messages";
import {
Button,
Menu,
MenuContent,
MenuItem,
MenuTrigger,
Tooltip,
MenuSeparator,
Text,
} from "design-system";
import { getAppsmithConfigs } from "@appsmith/configs";
import moment from "moment/moment";
import styled from "styled-components";
import {
getFirstTimeUserOnboardingModal,
getIsFirstTimeUserOnboardingEnabled,
getSignpostingSetOverlay,
getSignpostingTooltipVisible,
getSignpostingUnreadSteps,
inGuidedTour,
} from "selectors/onboardingSelectors";
import SignpostingPopup from "pages/Editor/FirstTimeUserOnboarding/Modal";
import { showSignpostingModal } from "actions/onboardingActions";
import { triggerWelcomeTour } from "./FirstTimeUserOnboarding/Utils";
import { isAirgapped } from "@appsmith/utils/airgapHelpers";
import TooltipContent from "./FirstTimeUserOnboarding/TooltipContent";
import { getInstanceId } from "@appsmith/selectors/tenantSelectors";
import { updateIntercomConsent, updateUserDetails } from "actions/userActions";
const { appVersion, cloudHosting, intercomAppID } = getAppsmithConfigs();
const HelpFooter = styled.div`
display: flex;
align-items: center;
justify-content: space-between;
font-size: 8px;
`;
const UnreadSteps = styled.div`
position: absolute;
height: 6px;
width: 6px;
border-radius: 50%;
top: 10px;
left: 22px;
background-color: var(--ads-v2-color-fg-error);
`;
const ConsentContainer = styled.div`
padding: 10px;
`;
const ActionsRow = styled.div`
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 8px;
`;
interface HelpItem {
label: string;
link?: string;
id?: string;
icon: string;
}
const HELP_MENU_ITEMS: HelpItem[] = [
{
icon: "book-line",
label: "Documentation",
link: "https://docs.appsmith.com/",
},
{
icon: "bug-line",
label: "Report a bug",
link: "https://github.com/appsmithorg/appsmith/issues/new/choose",
},
];
if (intercomAppID && window.Intercom) {
HELP_MENU_ITEMS.push({
icon: "chat-help",
label: "Chat with us",
id: "intercom-trigger",
});
}
export function IntercomConsent({
showIntercomConsent,
}: {
showIntercomConsent: (val: boolean) => void;
}) {
const user = useSelector(getCurrentUser);
const instanceId = useSelector(getInstanceId);
const dispatch = useDispatch();
const sendUserDataToIntercom = () => {
updateIntercomProperties(instanceId, user);
dispatch(
updateUserDetails({
intercomConsentGiven: true,
}),
);
dispatch(updateIntercomConsent());
showIntercomConsent(false);
window.Intercom("show");
};
return (