import React from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { PlusIcon, XMarkIcon, ChatBubbleLeftIcon, TrashIcon, HomeIcon } from '@heroicons/react/24/outline'; const Sidebar = ({ open, onClose, conversations, activeConversationId, onConversationSelect, onNewChat, onDeleteConversation, onBackToHome, darkMode }) => { const formatDate = (date) => { const now = new Date(); const messageDate = new Date(date); const diffTime = Math.abs(now - messageDate); const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)); if (diffDays === 1) return 'Today'; if (diffDays === 2) return 'Yesterday'; if (diffDays <= 7) return `${diffDays} days ago`; return messageDate.toLocaleDateString(); }; const sidebarVariants = { open: { x: 0, transition: { type: "spring", stiffness: 300, damping: 30 } }, closed: { x: -280, transition: { type: "spring", stiffness: 300, damping: 30 } } }; const overlayVariants = { open: { opacity: 1 }, closed: { opacity: 0 } }; return ( <> {/* Mobile Overlay */} {open && ( )} {/* Sidebar */} {/* Header */}

Conversations

New Chat Back to Home
{/* Conversations List */}
{conversations.length === 0 ? (

No conversations yet

Start a new chat to begin

) : (
{conversations.map((conversation) => ( { onConversationSelect(conversation.id); onClose(); }} className={`w-full text-left p-3 rounded-lg transition-all group ${ activeConversationId === conversation.id ? darkMode ? 'bg-primary-600 text-white' : 'bg-primary-50 text-primary-900 border-primary-200' : darkMode ? 'hover:bg-gray-800 text-gray-300' : 'hover:bg-gray-50 text-gray-700' }`} >

{conversation.title}

{formatDate(conversation.createdAt)}

))}
)}
{/* Footer */}

CA Study Assistant v2.0

Powered by AI

); }; export default Sidebar;