/* eslint-disable react-hooks/exhaustive-deps */ import { useContext, useEffect, useState } from "react"; import Head from "next/head"; import dynamic from "next/dynamic"; import Tooltips from "./components/Tooltip"; const Button = dynamic(() => import("./components/Button")); const PopOver = dynamic(() => import("./components/PopOver")); import styles from "./styles/Chatbot.module.scss"; import { ChatbotProps, Context } from "./contexts/Context"; export default function Chatbot({ color, base_url, wallpaper, owner_name, whatsapp_number, initial_message, background_color, }: ChatbotProps) { const { chatState, userName, handleSetChatState } = useContext(Context); const [openChat, setOpenChat] = useState(false); const [openPopOver, setOpenPopOver] = useState(false); function handleOpenChat() { setOpenPopOver(false); if (openChat) { setOpenChat(false); handleSetChatState(false); } else { setOpenChat(true); handleSetChatState(true); } } function handleOpenPopOver() { setOpenPopOver(true); } useEffect(() => { if (userName === "") { setTimeout(() => { handleOpenPopOver(); }, 5000); } }, [chatState]); return ( <>