import React, { useState, useEffect } from 'react'; import { Link as RouterLink, Outlet,…
- User
import React, { useState, useEffect } from 'react'; import { Link as RouterLink, Outlet, useNavigate, useLocation } from 'react-router-dom'; import { Box, [Redacted Person], [Redacted Person], Text, [Redacted Person], useColorMode, IconButton, Icon, [Redacted Person], [Redacted Person], useBreakpointValue, Tooltip, [Redacted Person], } from '@chakra-ui/react'; import { Scales, ChatTeardropText, CubeTransparent, ClockCounterClockwise, EnvelopeSimple, Gear, Sun, [Redacted Person], Bookmark, Plus, Copyright, IconProps, } from '@phosphor-icons/react'; import { useTranslation } from 'react-i18next'; import DesktopMenu from './Menu/DesktopMenu'; import MobileMenu from './Menu/MobileMenu'; import ScrollToTop from './utils/scroll';
const LAYOUT = { HEADER_HEIGHT: "60px", FOOTER_HEIGHT: "116px", SIDEBAR_WIDTH: { COLLAPSED: "80px", EXPANDED: "256px" }, Z_INDEX: { [Redacted Person]: 30, SIDEBAR: 20, CONTENT: 10, FOOTER: 5 } };
interface MenuItem { id: string; icon: React.ComponentType; label: string; path?: string; onClick?: () => void; hasExpandButton?: boolean; }
interface SidebarItemProps { icon: React.ComponentType; label: string; active: boolean; onClick: () => void; collapsed: boolean; hasExpandButton?: boolean; }
const SidebarItem: React.FC = ({ icon: IconComponent, label, active, onClick, collapsed, hasExpandButton }) => { const navigate = useNavigate(); const { t } = useTranslation("common");
return ( <Button onClick={onClick} variant="ghost" justifyContent={collapsed ? "center" : "flex-start"} w={hasExpandButton && !collapsed ? "85%" : "full"} h="10" gap={3} color={active ? "#4E4AC6" : "gray.600"} bg={active ? "#d5d1ef" : "transparent"} _hover={{ bg: "#d5d1ef" }} > {!collapsed && label} {hasExpandButton && !collapsed && ( <Tooltip label={t('view_full_history')} placement="right"> <IconButton aria-label="View full history" icon={} size="sm" variant="ghost" colorScheme="purple" onClick={(e) => { e.stopPropagation(); navigate('/historylist'); }} /> )} ); };
const Root: React.FC = () => { const navigate = useNavigate(); const location = useLocation(); const { colorMode, toggleColorMode } = useColorMode(); const { t } = useTranslation("common"); const isMobile = useBreakpointValue({ base: true, lg: false });
const [collapsed, setCollapsed] = useState(() => { const saved = localStorage.getItem("sidebarCollapsed"); return saved ? JSON.parse(saved) : isMobile; });
const [activeItem, setActiveItem] = useState(() => { const path = location.pathname.split("/")[1]; return path || "search"; });
useEffect(() => { localStorage.setItem("sidebarCollapsed", JSON.stringify(collapsed)); }, [collapsed]);
useEffect(() => { const path = location.pathname.split("/")[1]; setActiveItem(path || "search"); }, [location]);
useEffect(() => { if (isMobile && !collapsed) { setCollapsed(true); } }, [isMobile]);
const menuItems: MenuItem[] = [ { id: "search", icon: Scales, label: t("Recherche Juridique"), path: "/search" }, { id: "chatbot", icon: ChatTeardropText, label: t("ChatBot"), path: "/chatbot" }, { id: "pdf", icon: CubeTransparent, label: t("Document AI"), path: "/pdf" }, { id: "history", icon: ClockCounterClockwise, label: t("Historique"), path: "/historylist", hasExpandButton: true } ];
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.