diff --git a/src/components/Footer/Footer.jsx b/src/components/Footer/Footer.jsx index d22fde7..01d1ee5 100644 --- a/src/components/Footer/Footer.jsx +++ b/src/components/Footer/Footer.jsx @@ -17,11 +17,6 @@ import { HelpCircle, Mail, Phone, - X, - Send, - Bot, - Minimize2, - Maximize2, Sparkles, ChevronUp, } from "lucide-react"; @@ -34,52 +29,8 @@ import { FaDiscord } from "react-icons/fa6"; // Or from 'react-icons/fa' const Footer = () => { const [scrollProgress, setScrollProgress] = useState(0); const [isVisible, setIsVisible] = useState(false); - const [isChatOpen, setIsChatOpen] = useState(false); - const [isMinimized, setIsMinimized] = useState(false); - const [messages, setMessages] = useState([ - { - id: 1, - text: "Hi! I'm TechieBlog Assistant. How can I help you today?", - isBot: true, - timestamp: new Date(), - }, - ]); - const [inputMessage, setInputMessage] = useState(""); const navigate = useNavigate(); - const botResponses = { - greeting: [ - "Hello! Welcome to TechieBlog! How can I assist you today?", - "Hi there! I'm here to help you with any questions about our platform.", - "Hey! Great to see you here. What would you like to know?", - ], - about: [ - "TechieBlog is your go-to platform for tech insights, tutorials, and industry news. We bridge the gap between knowledge and action for tech enthusiasts and developers.", - "We're a community-driven tech blog focused on helping developers and tech enthusiasts stay updated with the latest trends and technologies.", - ], - contact: [ - "You can reach us at support@techieblog.com or call us at +1 (555) 123-4567. We're located at 123 Tech Street, Digital City.", - "Feel free to contact us through our Contact Us page or send us an email at support@techieblog.com", - ], - help: [ - "I can help you with information about our platform, contact details, navigation, and general questions. What specific help do you need?", - "You can ask me about our services, how to navigate the site, contact information, or any general questions about TechieBlog.", - ], - account: [ - "To access your account, click on the Account link in our Support section. You can login or create a new account there.", - "Account management is available through our login page. You can find it in the Support section of our footer.", - ], - events: [ - "Check out our Events page to see upcoming tech events, webinars, and conferences we're hosting or participating in.", - "We regularly organize tech events and workshops. Visit our Events section to stay updated!", - ], - default: [ - "I'm not sure about that specific question, but you can contact our support team at support@techieblog.com for detailed assistance.", - "That's a great question! For more specific inquiries, please reach out to our support team through the Contact Us page.", - "I'd recommend checking our FAQ section or contacting our support team for more detailed information about that topic.", - ], - }; - useEffect(() => { const handleScroll = () => { const scrollTop = window.scrollY; @@ -94,97 +45,29 @@ const Footer = () => { return () => window.removeEventListener("scroll", handleScroll); }, []); - const handleNavigation = (path) => { - window.scrollTo(0, 0); - navigate(path); - }; - - const getRandomResponse = (responses) => { - return responses[Math.floor(Math.random() * responses.length)]; - }; - - const getBotResponse = (userMessage) => { - const message = userMessage.toLowerCase(); + useEffect(() => { + const script1 = document.createElement('script'); + script1.src = import.meta.env.VITE_BOTPRESS_SCRIPT_1; + script1.defer = true; - if ( - message.includes("hello") || - message.includes("hi") || - message.includes("hey") - ) { - return getRandomResponse(botResponses.greeting); - } else if ( - message.includes("what") || - message.includes("about") || - message.includes("techieblog") - ) { - return getRandomResponse(botResponses.about); - } else if ( - message.includes("contact") || - message.includes("email") || - message.includes("phone") || - message.includes("reach") - ) { - return getRandomResponse(botResponses.contact); - } else if ( - message.includes("help") || - message.includes("assist") || - message.includes("support") - ) { - return getRandomResponse(botResponses.help); - } else if ( - message.includes("account") || - message.includes("login") || - message.includes("profile") - ) { - return getRandomResponse(botResponses.account); - } else if ( - message.includes("event") || - message.includes("webinar") || - message.includes("conference") - ) { - return getRandomResponse(botResponses.events); - } else { - return getRandomResponse(botResponses.default); - } - }; +const script2 = document.createElement('script'); +script2.src = import.meta.env.VITE_BOTPRESS_SCRIPT_2; +script2.defer = true; - const handleSendMessage = () => { - if (!inputMessage.trim()) return; + document.body.appendChild(script1); + document.body.appendChild(script2); - const userMessage = { - id: messages.length + 1, - text: inputMessage, - isBot: false, - timestamp: new Date(), + return () => { + document.body.removeChild(script1); + document.body.removeChild(script2); }; + }, []); - setMessages((prev) => [...prev, userMessage]); - setInputMessage(""); - - setTimeout(() => { - const botMessage = { - id: messages.length + 2, - text: getBotResponse(inputMessage), - isBot: true, - timestamp: new Date(), - }; - setMessages((prev) => [...prev, botMessage]); - }, 1000); - }; - - const handleKeyPress = (e) => { - if (e.key === "Enter") { - handleSendMessage(); - } - }; - - const toggleChat = () => { - setIsChatOpen(!isChatOpen); - setIsMinimized(false); - }; - - const toggleMinimize = () => { - setIsMinimized(!isMinimized); +const handleNavigation = (path) => { + window.scrollTo(0, 0); + navigate(path); +}; + }; return ( @@ -381,100 +264,13 @@ const Footer = () => {
- {isChatOpen && ( -
-
-
- - TechieBlog Assistant -
-
- - -
-
- - {!isMinimized && ( - <> -
- {messages.map((message) => ( -
-
- {message.text} -
-
- ))} -
- -
-
- setInputMessage(e.target.value)} - onKeyPress={handleKeyPress} - placeholder="Type your message..." - className="flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-orange-500 dark:bg-gray-700 dark:text-white text-sm" - /> - -
-
- - )} -
- )} - -
- {isChatOpen ? ( - - ) : ( - - )} -
+ +
window.scrollTo({ top: 0, behavior: "smooth" })}