import React, { useRef, useEffect } from 'react'; import { Button } from '@/components/ui/button'; import { useTheme } from '../contexts/ThemeContext'; import { FiMenu, FiX, FiHelpCircle, FiUsers, FiDollarSign, FiZap, FiExternalLink, FiMoon, FiSun } from 'react-icons/fi'; import { TbMessageChatbot } from "react-icons/tb"; import { LucideCodeXml } from 'lucide-react'; import { useNavigate } from "react-router-dom"; interface LeftSidebarProps { onPromptSelect: (prompt: string, content: any) => void; onStartNewChat?: () => void; // Add this prop } const suggestedQuestions = [ { text: "What is MCP?", icon: FiHelpCircle }, { text: "Who is this for?", icon: FiUsers }, { text: "Show me how I can earn", icon: FiDollarSign }, { text: "What can you help me with?", icon: FiZap }, ]; const navLinks = [ { text: "Chat", icon: TbMessageChatbot , to: "#" }, { text: "Home", icon: FiHelpCircle, to: "#home" }, { text: "MCPs", icon: FiUsers, to: "#mcps" }, { text: "Monetize", icon: FiDollarSign, to: "#monetize" }, ]; const LeftSidebar: React.FC = ({ onPromptSelect, onStartNewChat }) => { const { sidebarOpen, setSidebarOpen } = useTheme(); const { isDark, toggleTheme } = useTheme(); const sidebarRef = useRef(null); const navigate = useNavigate(); // Close sidebar on outside click useEffect(() => { if (!sidebarOpen) return; const handleClickOutside = (event: MouseEvent) => { if ( sidebarRef.current && !sidebarRef.current.contains(event.target as Node) ) { setSidebarOpen(false); } }; document.addEventListener('mousedown', handleClickOutside); return () => { document.removeEventListener('mousedown', handleClickOutside); }; }, [sidebarOpen, setSidebarOpen]); const handlePromptClick = (prompt: string) => { // Dispatch a custom event to notify ChatInterface const event = new CustomEvent('leftSidebarPrompt', { detail: { prompt } }); window.dispatchEvent(event); // Trigger the same logic as in ChatInterface onPromptSelect(prompt, null); }; return ( <> {/* Toggle Button */} {!sidebarOpen && ( )} {/* Sidebar */}
{/* Top Section: Logo, Navigation, Theme Toggle */}
{/* Logo */}
{/* Logo */} FastCode
{/* Theme Toggle */}
{/* Questions */}

Quick Start

{suggestedQuestions.map((question, index) => ( ))}
{/* Start New Chat Button */}
{/* Nav Section */}
{/* Nav menu */}

Navigation

{navLinks.map((nav, index) => ( {nav.text} ))}
{/* Visit Website */}

Resources

); }; export default LeftSidebar;