import { Draggable } from "@hello-pangea/dnd"; import Locale from "@/app/locales"; import { useLocation } from "react-router-dom"; import { Path } from "@/app/constant"; import { Mask } from "@/app/store/mask"; import { useRef, useEffect } from "react"; import DeleteChatIcon from "@/app/icons/deleteChatIcon.svg"; import { getTime } from "@/app/utils"; import DeleteIcon from "@/app/icons/deleteIcon.svg"; import LogIcon from "@/app/icons/logIcon.svg"; import HoverPopover from "@/app/components/HoverPopover"; export default function SessionItem(props: { onClick?: () => void; onDelete?: () => void; title: string; count: number; time: string; selected: boolean; id: string; index: number; narrow?: boolean; mask: Mask; isMobileScreen: boolean; }) { const draggableRef = useRef(null); useEffect(() => { if (props.selected && draggableRef.current) { draggableRef.current?.scrollIntoView({ block: "center", }); } }, [props.selected]); const { pathname: currentPath } = useLocation(); return ( {(provided) => (
{ // draggableRef.current = ele; // provided.innerRef(ele); // }} // {...provided.draggableProps} // {...provided.dragHandleProps} title={`${props.title}\n${Locale.ChatItem.ChatItemCount( props.count, )}`} >
{props.title}
{getTime(props.time)}
{Locale.ChatItem.ChatItemCount(props.count)}
{ props.onDelete?.(); e.preventDefault(); e.stopPropagation(); }} >
{Locale.Chat.Actions.Delete}
} popoverClassName={` px-2 py-1 border-delete-chat-popover bg-delete-chat-popover-panel rounded-md shadow-delete-chat-popover-shadow `} noArrow align={props.isMobileScreen ? "end" : "start"} >
)}
); }