@droppii-org/chat-sdk
Version:
Droppii React Chat SDK
28 lines (27 loc) • 1.72 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import useConversationStore from "../../store/conversation";
import UserSection from "./UserSection";
import SessionSection, { SessionDetailCard } from "./SessionSection";
import { useGetListSessionByConversation } from "../../hooks/session/useGetListSessionByConversation";
import { useMemo } from "react";
const ThreadInfo = () => {
const conversationData = useConversationStore((state) => state.conversationData);
const conversationId = (conversationData === null || conversationData === void 0 ? void 0 : conversationData.conversationID) || "";
const { data: sessions, isLoading } = useGetListSessionByConversation({
conversationId,
page: 1,
pageSize: 50,
});
const { closedSessions, activeSession } = useMemo(() => {
if (!sessions)
return { closedSessions: [], activeSession: null };
const active = sessions.find((s) => !s.isClosed);
const closed = sessions.filter((s) => s.isClosed);
return { closedSessions: closed, activeSession: active };
}, [sessions]);
if (!conversationId) {
return null;
}
return (_jsxs("div", { className: "h-full w-[330px] bg-white shadow-md flex flex-col relative", children: [_jsxs("div", { className: `flex-grow overflow-y-auto ${activeSession ? "pb-60" : ""}`, children: [_jsx(UserSection, {}), _jsx(SessionSection, { sessions: closedSessions, isLoading: isLoading })] }), activeSession && (_jsx("div", { className: "absolute bottom-0 left-0 right-0 p-4 z-20 bg-white backdrop-blur-sm", children: _jsx(SessionDetailCard, { session: activeSession, isActive: true }) }))] }));
};
export default ThreadInfo;