@droppii-org/chat-sdk 0.0.27 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/chatBubble/ChatBubble.d.ts.map +1 -1
- package/dist/components/chatBubble/ChatBubble.js +4 -5
- package/dist/components/conversation/DeskConversationList.d.ts.map +1 -1
- package/dist/components/conversation/DeskConversationList.js +14 -27
- package/dist/components/message/MessageHeader.d.ts +1 -3
- package/dist/components/message/MessageHeader.d.ts.map +1 -1
- package/dist/components/message/MessageHeader.js +7 -3
- package/dist/components/message/MessageList.d.ts +0 -2
- package/dist/components/message/MessageList.d.ts.map +1 -1
- package/dist/components/message/MessageList.js +5 -5
- package/dist/components/session/AssignedSessionFilter.d.ts.map +1 -1
- package/dist/components/session/AssignedSessionFilter.js +105 -51
- package/dist/constants/im.d.ts +3 -0
- package/dist/constants/im.d.ts.map +1 -0
- package/dist/constants/im.js +2 -0
- package/dist/constants/index.d.ts +12 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +12 -0
- package/dist/context/ChatContext.d.ts.map +1 -1
- package/dist/context/ChatContext.js +29 -39
- package/dist/hooks/conversation/useConversation.d.ts +5 -5
- package/dist/hooks/conversation/useConversation.d.ts.map +1 -1
- package/dist/hooks/conversation/useConversation.js +47 -52
- package/dist/hooks/global/useGlobalEvent.d.ts.map +1 -1
- package/dist/hooks/global/useGlobalEvent.js +66 -3
- package/dist/hooks/message/useSendMessage.d.ts.map +1 -1
- package/dist/hooks/message/useSendMessage.js +1 -1
- package/dist/hooks/user/useUsersInfo.d.ts +4 -0
- package/dist/hooks/user/useUsersInfo.d.ts.map +1 -0
- package/dist/hooks/user/useUsersInfo.js +44 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/layout/index.d.ts.map +1 -1
- package/dist/layout/index.js +8 -1
- package/dist/screens/chatBubble/index.d.ts.map +1 -1
- package/dist/screens/chatBubble/index.js +4 -11
- package/dist/screens/deskMessage/index.d.ts.map +1 -1
- package/dist/screens/deskMessage/index.js +3 -4
- package/dist/store/conversation.d.ts +4 -0
- package/dist/store/conversation.d.ts.map +1 -0
- package/dist/store/conversation.js +119 -0
- package/dist/store/index.d.ts +3 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +2 -0
- package/dist/store/user.d.ts +4 -0
- package/dist/store/user.d.ts.map +1 -0
- package/dist/store/user.js +8 -0
- package/dist/store/usersInfo.d.ts +4 -0
- package/dist/store/usersInfo.d.ts.map +1 -0
- package/dist/store/usersInfo.js +12 -0
- package/dist/types/chat.d.ts +27 -0
- package/dist/types/chat.d.ts.map +1 -1
- package/dist/types/chat.js +6 -0
- package/dist/utils/imCommon.d.ts +26 -0
- package/dist/utils/imCommon.d.ts.map +1 -0
- package/dist/utils/imCommon.js +58 -0
- package/package.json +1 -1
- package/dist/hooks/zustand/useMessageStore.d.ts +0 -9
- package/dist/hooks/zustand/useMessageStore.d.ts.map +0 -1
- package/dist/hooks/zustand/useMessageStore.js +0 -8
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -1
- package/dist/types/sdk.d.ts +0 -1
- package/dist/types/sdk.d.ts.map +0 -1
- package/dist/types/sdk.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBubble.d.ts","sourceRoot":"","sources":["../../../src/components/chatBubble/ChatBubble.tsx"],"names":[],"mappings":"AAOA,UAAU,eAAe;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,UAAU,GAAI,eAAe,eAAe,
|
|
1
|
+
{"version":3,"file":"ChatBubble.d.ts","sourceRoot":"","sources":["../../../src/components/chatBubble/ChatBubble.tsx"],"names":[],"mappings":"AAOA,UAAU,eAAe;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,UAAU,GAAI,eAAe,eAAe,4CAuFjD,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -4,11 +4,10 @@ import { useEffect, useState } from "react";
|
|
|
4
4
|
import { FloatButton, Drawer, Popover } from "antd";
|
|
5
5
|
import { MessageOutlined, CloseOutlined } from "@ant-design/icons";
|
|
6
6
|
import MessageList from "../message/MessageList";
|
|
7
|
-
import useConversationStore from "../../
|
|
7
|
+
import useConversationStore from "../../store/conversation";
|
|
8
8
|
const ChatBubble = ({ className }) => {
|
|
9
9
|
const [isMobile, setIsMobile] = useState(false);
|
|
10
|
-
const
|
|
11
|
-
const selectedThreadId = useConversationStore((state) => state.selectedThreadId);
|
|
10
|
+
const selectedConversationId = useConversationStore((state) => state.selectedConversationId);
|
|
12
11
|
const [isOpen, setIsOpen] = useState(false);
|
|
13
12
|
const toggleChat = () => {
|
|
14
13
|
setIsOpen(!isOpen);
|
|
@@ -29,9 +28,9 @@ const ChatBubble = ({ className }) => {
|
|
|
29
28
|
body: { padding: 0 },
|
|
30
29
|
}, classNames: {
|
|
31
30
|
wrapper: "!z-[9999]",
|
|
32
|
-
}, children: _jsx(MessageList, { conversationId:
|
|
31
|
+
}, children: _jsx(MessageList, { conversationId: selectedConversationId, className: "flex-1", onClose: () => setIsOpen(false) }) })] }));
|
|
33
32
|
}
|
|
34
|
-
return (_jsx(Popover, { placement: "topLeft", trigger: "click", content: _jsx("div", { style: { width: 400, height: 640 }, children: _jsx(MessageList, { conversationId:
|
|
33
|
+
return (_jsx(Popover, { placement: "topLeft", trigger: "click", content: _jsx("div", { style: { width: 400, height: 640 }, children: _jsx(MessageList, { conversationId: selectedConversationId, className: "flex-1", onClose: () => setIsOpen(false) }) }), styles: { body: { padding: 0 } }, children: _jsx(FloatButton, { icon: isOpen ? _jsx(CloseOutlined, {}) : _jsx(MessageOutlined, {}), type: "primary", style: {
|
|
35
34
|
right: 24,
|
|
36
35
|
bottom: 24,
|
|
37
36
|
width: 60,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeskConversationList.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/DeskConversationList.tsx"],"names":[],"mappings":"AAqGA,UAAU,yBAAyB;IACjC,oBAAoB,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,oBAAoB,GAAI,sCAG3B,yBAAyB,
|
|
1
|
+
{"version":3,"file":"DeskConversationList.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/DeskConversationList.tsx"],"names":[],"mappings":"AAqGA,UAAU,yBAAyB;IACjC,oBAAoB,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,oBAAoB,GAAI,sCAG3B,yBAAyB,4CAgL3B,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useState, useEffect
|
|
3
|
+
import { useState, useEffect } from "react";
|
|
4
4
|
import { useRouter, useSearchParams, usePathname } from "next/navigation";
|
|
5
5
|
import { Input, Avatar, Badge, Empty } from "antd";
|
|
6
|
-
import {
|
|
7
|
-
import { useConversationList } from "../../hooks/conversation/useConversation";
|
|
6
|
+
import { markConversationMessageAsRead } from "../../hooks/conversation/useConversation";
|
|
8
7
|
import { Icon } from "../icon";
|
|
9
8
|
import { useChatContext } from "../../context/ChatContext";
|
|
10
|
-
import useConversationStore from "../../
|
|
9
|
+
import useConversationStore from "../../store/conversation";
|
|
11
10
|
const parseLatestMessage = (latestMsg, currentUserId) => {
|
|
12
11
|
var _a;
|
|
13
12
|
if (!latestMsg)
|
|
@@ -73,10 +72,9 @@ const DeskConversationList = ({ onConversationSelect, className = "", }) => {
|
|
|
73
72
|
const searchParams = useSearchParams();
|
|
74
73
|
const { user } = useChatContext();
|
|
75
74
|
const setConversationData = useConversationStore((state) => state.setConversationData);
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
const { conversationList, markConversationMessageAsRead } = useConversationList(selectedThreadId);
|
|
75
|
+
const selectedConversationId = useConversationStore((state) => state.selectedConversationId);
|
|
76
|
+
const setSelectedConversationId = useConversationStore((state) => state.setSelectedConversationId);
|
|
77
|
+
const conversationList = useConversationStore((state) => state.conversationList);
|
|
80
78
|
// Transform real conversation data from the API
|
|
81
79
|
const conversations = transformConversationData(conversationList || [], user === null || user === void 0 ? void 0 : user.userID);
|
|
82
80
|
const filteredConversations = conversations.filter((conv) => conv.name.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
|
@@ -86,30 +84,20 @@ const DeskConversationList = ({ onConversationSelect, className = "", }) => {
|
|
|
86
84
|
const newSearchParams = new URLSearchParams(searchParams);
|
|
87
85
|
newSearchParams.set("threadId", conversation.id);
|
|
88
86
|
router.push(`${pathname}?${newSearchParams.toString()}`);
|
|
89
|
-
|
|
87
|
+
setSelectedConversationId(conversation.id);
|
|
90
88
|
onConversationSelect === null || onConversationSelect === void 0 ? void 0 : onConversationSelect(conversation.id, conversation.id);
|
|
91
89
|
};
|
|
92
|
-
const onSetSelectedSourceId = useCallback(() => {
|
|
93
|
-
const selectedConversation = conversations.findIndex((conv) => conv.id === selectedThreadId);
|
|
94
|
-
if (selectedConversation !== -1) {
|
|
95
|
-
const conversation = conversations[selectedConversation];
|
|
96
|
-
const sourceId = conversation.conversationType === SessionType.Group
|
|
97
|
-
? conversation.groupID
|
|
98
|
-
: conversation.userID;
|
|
99
|
-
setSelectedSourceId(sourceId);
|
|
100
|
-
}
|
|
101
|
-
}, [conversationList, selectedThreadId]);
|
|
102
90
|
useEffect(() => {
|
|
103
91
|
const threadId = searchParams.get("threadId");
|
|
104
92
|
if (threadId) {
|
|
105
|
-
|
|
93
|
+
setSelectedConversationId(threadId);
|
|
106
94
|
const selectedConversation = conversations.find((conv) => conv.id === threadId);
|
|
107
95
|
if (selectedConversation) {
|
|
108
96
|
setConversationData(selectedConversation);
|
|
109
97
|
}
|
|
110
98
|
}
|
|
111
99
|
else if (conversations.length > 0) {
|
|
112
|
-
|
|
100
|
+
setSelectedConversationId(conversations[0].id);
|
|
113
101
|
setConversationData(conversations[0]);
|
|
114
102
|
const newSearchParams = new URLSearchParams(searchParams);
|
|
115
103
|
newSearchParams.set("threadId", conversations[0].id);
|
|
@@ -117,14 +105,13 @@ const DeskConversationList = ({ onConversationSelect, className = "", }) => {
|
|
|
117
105
|
}
|
|
118
106
|
}, [searchParams, conversations.length]);
|
|
119
107
|
useEffect(() => {
|
|
120
|
-
if (!!
|
|
121
|
-
markConversationMessageAsRead(
|
|
122
|
-
onSetSelectedSourceId();
|
|
108
|
+
if (!!selectedConversationId) {
|
|
109
|
+
markConversationMessageAsRead(selectedConversationId);
|
|
123
110
|
}
|
|
124
|
-
}, [
|
|
125
|
-
return (_jsxs("div", { className: `flex flex-col h-full bg-white border-r border-gray-200 w-[320px] ${className}`, children: [_jsx("div", { className: "p-3 border-b border-gray-200", children: _jsx(Input, { placeholder: "T\u00ECm ki\u1EBFm", prefix: _jsx(Icon, { icon: "search-o", size: 18, className: "text-gray-400" }), value: searchQuery, onChange: (e) => setSearchQuery(e.target.value), className: "rounded-lg" }) }), _jsxs("div", { className: "flex-1 overflow-y-auto", children: [filteredConversations.map((conversation) => (_jsxs("div", { onClick: () => handleConversationClick(conversation), className: `relative p-3 border-b border-gray-100 hover:bg-gray-50 cursor-pointer transition-colors ${
|
|
111
|
+
}, [selectedConversationId]);
|
|
112
|
+
return (_jsxs("div", { className: `flex flex-col h-full bg-white border-r border-gray-200 w-[320px] ${className}`, children: [_jsx("div", { className: "p-3 border-b border-gray-200", children: _jsx(Input, { placeholder: "T\u00ECm ki\u1EBFm", prefix: _jsx(Icon, { icon: "search-o", size: 18, className: "text-gray-400" }), value: searchQuery, onChange: (e) => setSearchQuery(e.target.value), className: "rounded-lg" }) }), _jsxs("div", { className: "flex-1 overflow-y-auto", children: [filteredConversations.map((conversation) => (_jsxs("div", { onClick: () => handleConversationClick(conversation), className: `relative p-3 border-b border-gray-100 hover:bg-gray-50 cursor-pointer transition-colors ${selectedConversationId === conversation.threadId
|
|
126
113
|
? "bg-blue-50"
|
|
127
|
-
: "bg-white"}`, children: [
|
|
114
|
+
: "bg-white"}`, children: [selectedConversationId === conversation.threadId && (_jsx("div", { className: "absolute left-0 top-0 bottom-0 w-1 bg-blue-500" })), _jsxs("div", { className: "flex items-start gap-3", children: [_jsx("div", { className: "relative flex-shrink-0", children: _jsx(Badge, { dot: conversation.isOnline, status: conversation.isOnline ? "success" : "default", offset: [-2, 36], children: _jsx(Avatar, { size: 48, src: conversation.avatar, alt: conversation.name, children: conversation.name.charAt(0).toUpperCase() }) }) }), _jsx("div", { className: "flex-1 min-w-0", children: _jsxs("div", { className: "flex items-start justify-between", children: [_jsxs("div", { className: "flex-1 min-w-0", children: [_jsx("h3", { className: "font-semibold text-gray-900 text-sm truncate", children: conversation.name }), _jsx("p", { className: "text-xs text-gray-500 truncate mt-0.5", children: conversation.lastMessage })] }), _jsxs("div", { className: "flex flex-col items-end gap-1 ml-2", children: [_jsx("span", { className: "text-xs text-gray-400", children: conversation.timestamp }), _jsx("div", { className: "flex items-center gap-1", children: conversation.unreadCount > 0 && (_jsx(Badge, { count: conversation.unreadCount })) })] })] }) })] })] }, conversation.id))), filteredConversations.length === 0 && (_jsx("div", { className: "flex items-center justify-center py-12", children: _jsx(Empty, { image: _jsx(Icon, { icon: "chat-square-b", size: 48, className: "text-gray-300" }), description: _jsxs("div", { children: [_jsx("p", { className: "text-lg font-medium mb-2 text-gray-500", children: "Kh\u00F4ng t\u00ECm th\u1EA5y cu\u1ED9c tr\u00F2 chuy\u1EC7n" }), _jsx("p", { className: "text-sm text-gray-400", children: searchQuery
|
|
128
115
|
? "Thử tìm kiếm với từ khóa khác"
|
|
129
116
|
: "Chưa có cuộc trò chuyện nào" })] }) }) }))] })] }));
|
|
130
117
|
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { ConversationItem } from "@openim/wasm-client-sdk";
|
|
2
1
|
interface MessageHeaderProps {
|
|
3
|
-
conversationData: ConversationItem | null;
|
|
4
2
|
onClose?: () => void;
|
|
5
3
|
}
|
|
6
|
-
declare const MessageHeader: ({
|
|
4
|
+
declare const MessageHeader: ({ onClose }: MessageHeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
5
|
export default MessageHeader;
|
|
8
6
|
//# sourceMappingURL=MessageHeader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageHeader.d.ts","sourceRoot":"","sources":["../../../src/components/message/MessageHeader.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MessageHeader.d.ts","sourceRoot":"","sources":["../../../src/components/message/MessageHeader.tsx"],"names":[],"mappings":"AAQA,UAAU,kBAAkB;IAC1B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,QAAA,MAAM,aAAa,GAAI,aAAa,kBAAkB,4CAkDrD,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Avatar, Button } from "antd";
|
|
4
4
|
import { Icon } from "../icon";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import { useConversationDisplayData } from "../../hooks/conversation/useConversation";
|
|
6
|
+
import useConversationStore from "../../store/conversation";
|
|
7
|
+
const MessageHeader = ({ onClose }) => {
|
|
8
|
+
var _a;
|
|
9
|
+
const conversationData = useConversationStore((state) => state.conversationData);
|
|
10
|
+
const { avatar, displayName } = useConversationDisplayData(conversationData);
|
|
11
|
+
return (_jsxs("div", { className: "px-4 py-3 flex items-center border-b gap-3", children: [_jsx(Avatar, { src: avatar, size: "large", children: ((_a = displayName === null || displayName === void 0 ? void 0 : displayName.charAt) === null || _a === void 0 ? void 0 : _a.call(displayName, 0)) || "A" }), _jsxs("div", { className: "flex flex-col flex-1", children: [_jsx("p", { children: displayName || "" }), _jsx("p", { className: "text-xs text-gray-500", children: "2 thành viên" })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Button, { type: "text", shape: "default", className: "text-gray-500 w-8 h-8 p-0", children: _jsx(Icon, { icon: "search-o", size: 22 }) }), _jsx(Button, { type: "text", shape: "default", className: "text-gray-500 w-8 h-8 p-0", children: _jsx(Icon, { icon: "folder-o", size: 22 }) }), _jsx(Button, { type: "text", shape: "default", className: "text-gray-500 w-8 h-8 p-0", children: _jsx(Icon, { icon: "align-justify-o", size: 22 }) }), !!onClose && (_jsx(Button, { type: "text", shape: "default", className: "text-gray-500 w-8 h-8 p-0", onClick: onClose, children: _jsx(Icon, { icon: "close-b", size: 22 }) }))] })] }));
|
|
8
12
|
};
|
|
9
13
|
export default MessageHeader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../../src/components/message/MessageList.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../../src/components/message/MessageList.tsx"],"names":[],"mappings":"AAeA,UAAU,gBAAgB;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,QAAA,MAAM,WAAW,GAAI,OAAO,gBAAgB,4CAkE3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -12,15 +12,15 @@ import MessageHeader from "./MessageHeader";
|
|
|
12
12
|
import MessageFooter from "./footer";
|
|
13
13
|
dayjs.extend(isToday);
|
|
14
14
|
const MessageList = (props) => {
|
|
15
|
-
var _a, _b;
|
|
16
|
-
const {
|
|
15
|
+
var _a, _b, _c;
|
|
16
|
+
const { onClose, conversationId } = props;
|
|
17
17
|
const scrollRef = useRef(null);
|
|
18
18
|
const { getMoreOldMessages, moreOldLoading, loadState, latestLoadState } = useMessage(conversationId);
|
|
19
19
|
const lastMessage = useMemo(() => {
|
|
20
20
|
var _a;
|
|
21
21
|
const messageList = (_a = latestLoadState.current) === null || _a === void 0 ? void 0 : _a.messageList;
|
|
22
22
|
return messageList === null || messageList === void 0 ? void 0 : messageList[(messageList === null || messageList === void 0 ? void 0 : messageList.length) - 1];
|
|
23
|
-
}, [latestLoadState]);
|
|
23
|
+
}, [(_a = latestLoadState === null || latestLoadState === void 0 ? void 0 : latestLoadState.current) === null || _a === void 0 ? void 0 : _a.messageList]);
|
|
24
24
|
const scrollToBottom = () => {
|
|
25
25
|
setTimeout(() => {
|
|
26
26
|
var _a, _b;
|
|
@@ -41,11 +41,11 @@ const MessageList = (props) => {
|
|
|
41
41
|
emitter.off("CHAT_LIST_SCROLL_TO_BOTTOM", scrollToBottom);
|
|
42
42
|
};
|
|
43
43
|
}, []);
|
|
44
|
-
return (_jsxs("div", { className: "flex flex-col flex-1 relative h-full bg-white", children: [_jsx(MessageHeader, {
|
|
44
|
+
return (_jsxs("div", { className: "flex flex-col flex-1 relative h-full bg-white", children: [_jsx(MessageHeader, { onClose: onClose }), _jsx("div", { id: "scrollableDiv", style: {
|
|
45
45
|
height: "100%",
|
|
46
46
|
overflow: "auto",
|
|
47
47
|
display: "flex",
|
|
48
48
|
flexDirection: "column-reverse",
|
|
49
|
-
}, children: _jsx(InfiniteScroll, { dataLength: ((
|
|
49
|
+
}, children: _jsx(InfiniteScroll, { dataLength: ((_b = loadState.groupMessageList) === null || _b === void 0 ? void 0 : _b.length) || 0, next: loadMoreMessage, style: { display: "flex", flexDirection: "column-reverse" }, inverse: true, hasMore: loadState.hasMoreOld, loader: _jsx("div", { className: "flex items-center justify-center py-2", children: _jsx(Spin, {}) }), scrollableTarget: "scrollableDiv", children: (_c = loadState.groupMessageList) === null || _c === void 0 ? void 0 : _c.toReversed().map((message) => _jsx(MessageItem, { groupMessage: message })) }) }), _jsx(MessageFooter, { lastMessage: lastMessage })] }));
|
|
50
50
|
};
|
|
51
51
|
export default MessageList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssignedSessionFilter.d.ts","sourceRoot":"","sources":["../../../src/components/session/AssignedSessionFilter.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AssignedSessionFilter.d.ts","sourceRoot":"","sources":["../../../src/components/session/AssignedSessionFilter.tsx"],"names":[],"mappings":"AAyBA,UAAU,0BAA0B;IAClC,cAAc,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,qBAAqB,GAAI,gCAG5B,0BAA0B,4CA6P5B,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -1,62 +1,101 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useState } from "react";
|
|
3
|
+
import { useMemo, useState } from "react";
|
|
4
4
|
import { Icon } from "../icon";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
count: 1,
|
|
16
|
-
color: "text-orange-500",
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
icon: "warning-square-o",
|
|
20
|
-
label: "Chậm xử lý",
|
|
21
|
-
count: 1,
|
|
22
|
-
color: "text-red-500",
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
icon: "time-circle-o",
|
|
26
|
-
label: "Chờ xử lý",
|
|
27
|
-
count: 0,
|
|
28
|
-
color: "text-orange-400",
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
icon: "arrow-reply-o",
|
|
32
|
-
label: "Chưa trả lời",
|
|
33
|
-
count: 1,
|
|
34
|
-
color: "text-purple-500",
|
|
35
|
-
},
|
|
5
|
+
import useConversationStore from "../../store/conversation";
|
|
6
|
+
import { SESSION_STATUS_ENUM, TAG_ENUM } from "../../constants";
|
|
7
|
+
const AssignedSessionFilter = ({ onFilterChange, className = "", }) => {
|
|
8
|
+
const [expandedCategories, setExpandedCategories] = useState(new Set([0]));
|
|
9
|
+
const [selectedFilter, setSelectedFilter] = useState("");
|
|
10
|
+
const summary = useConversationStore((state) => state.summary);
|
|
11
|
+
const setFilterSummary = useConversationStore((state) => state.setFilterSummary);
|
|
12
|
+
const messageCategories = useMemo(() => {
|
|
13
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
14
|
+
return [
|
|
36
15
|
{
|
|
37
|
-
icon: "
|
|
38
|
-
label: "Đang
|
|
39
|
-
count:
|
|
16
|
+
icon: "chat-square-b",
|
|
17
|
+
label: "Đang mở",
|
|
18
|
+
count: (summary === null || summary === void 0 ? void 0 : summary.activeSessionCount) || 0,
|
|
40
19
|
color: "text-gray-600",
|
|
20
|
+
query: {
|
|
21
|
+
status: undefined,
|
|
22
|
+
tag: undefined,
|
|
23
|
+
},
|
|
24
|
+
subCategories: [
|
|
25
|
+
{
|
|
26
|
+
icon: "user-del-o",
|
|
27
|
+
label: "Chưa phân công",
|
|
28
|
+
count: ((_b = (_a = summary === null || summary === void 0 ? void 0 : summary.sessionStatuses) === null || _a === void 0 ? void 0 : _a.find((status) => status.type === SESSION_STATUS_ENUM.UNASSIGNED)) === null || _b === void 0 ? void 0 : _b.count) || 0,
|
|
29
|
+
color: "text-orange-500",
|
|
30
|
+
query: {
|
|
31
|
+
status: SESSION_STATUS_ENUM.UNASSIGNED,
|
|
32
|
+
tag: undefined,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
icon: "warning-square-o",
|
|
37
|
+
label: "Chậm xử lý",
|
|
38
|
+
count: ((_d = (_c = summary === null || summary === void 0 ? void 0 : summary.tagCounts) === null || _c === void 0 ? void 0 : _c.find((status) => status.type === TAG_ENUM.SLOW_PROCESSING)) === null || _d === void 0 ? void 0 : _d.count) || 0,
|
|
39
|
+
color: "text-red-500",
|
|
40
|
+
query: {
|
|
41
|
+
status: undefined,
|
|
42
|
+
tag: TAG_ENUM.SLOW_PROCESSING,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
icon: "time-circle-o",
|
|
47
|
+
label: "Chờ xử lý",
|
|
48
|
+
count: ((_f = (_e = summary === null || summary === void 0 ? void 0 : summary.sessionStatuses) === null || _e === void 0 ? void 0 : _e.find((status) => status.type === SESSION_STATUS_ENUM.WAITING_PROCESS)) === null || _f === void 0 ? void 0 : _f.count) || 0,
|
|
49
|
+
color: "text-orange-400",
|
|
50
|
+
query: {
|
|
51
|
+
status: SESSION_STATUS_ENUM.WAITING_PROCESS,
|
|
52
|
+
tag: undefined,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
icon: "arrow-reply-o",
|
|
57
|
+
label: "Chưa trả lời",
|
|
58
|
+
count: ((_h = (_g = summary === null || summary === void 0 ? void 0 : summary.tagCounts) === null || _g === void 0 ? void 0 : _g.find((status) => status.type === TAG_ENUM.AWAITING_REPLY)) === null || _h === void 0 ? void 0 : _h.count) || 0,
|
|
59
|
+
color: "text-purple-500",
|
|
60
|
+
query: {
|
|
61
|
+
status: undefined,
|
|
62
|
+
tag: TAG_ENUM.AWAITING_REPLY,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
icon: "play-b",
|
|
67
|
+
label: "Đang xử lý",
|
|
68
|
+
count: ((_k = (_j = summary === null || summary === void 0 ? void 0 : summary.sessionStatuses) === null || _j === void 0 ? void 0 : _j.find((status) => status.type === SESSION_STATUS_ENUM.IN_PROCESS)) === null || _k === void 0 ? void 0 : _k.count) || 0,
|
|
69
|
+
color: "text-gray-600",
|
|
70
|
+
query: {
|
|
71
|
+
status: SESSION_STATUS_ENUM.IN_PROCESS,
|
|
72
|
+
tag: undefined,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
icon: "pause-b",
|
|
77
|
+
label: "Tạm chờ",
|
|
78
|
+
count: ((_m = (_l = summary === null || summary === void 0 ? void 0 : summary.sessionStatuses) === null || _l === void 0 ? void 0 : _l.find((status) => status.type === TAG_ENUM.TEMPORARILY_PAUSED)) === null || _m === void 0 ? void 0 : _m.count) || 0,
|
|
79
|
+
color: "text-gray-600",
|
|
80
|
+
query: {
|
|
81
|
+
status: undefined,
|
|
82
|
+
tag: TAG_ENUM.TEMPORARILY_PAUSED,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
],
|
|
41
86
|
},
|
|
42
87
|
{
|
|
43
|
-
icon: "
|
|
44
|
-
label: "
|
|
45
|
-
count:
|
|
46
|
-
color: "text-
|
|
88
|
+
icon: "check-b",
|
|
89
|
+
label: "Đã đóng",
|
|
90
|
+
count: ((_p = (_o = summary === null || summary === void 0 ? void 0 : summary.sessionStatuses) === null || _o === void 0 ? void 0 : _o.find((status) => status.type === SESSION_STATUS_ENUM.COMPLETED)) === null || _p === void 0 ? void 0 : _p.count) || 0,
|
|
91
|
+
color: "text-green-600",
|
|
92
|
+
query: {
|
|
93
|
+
status: SESSION_STATUS_ENUM.COMPLETED,
|
|
94
|
+
tag: undefined,
|
|
95
|
+
},
|
|
47
96
|
},
|
|
48
|
-
]
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
icon: "check-b",
|
|
52
|
-
label: "Đã đóng",
|
|
53
|
-
count: 0,
|
|
54
|
-
color: "text-green-600",
|
|
55
|
-
},
|
|
56
|
-
];
|
|
57
|
-
const AssignedSessionFilter = ({ onFilterChange, className = "", }) => {
|
|
58
|
-
const [expandedCategories, setExpandedCategories] = useState(new Set([0]));
|
|
59
|
-
const [selectedFilter, setSelectedFilter] = useState("");
|
|
97
|
+
];
|
|
98
|
+
}, []);
|
|
60
99
|
const toggleCategory = (index) => {
|
|
61
100
|
const newExpanded = new Set(expandedCategories);
|
|
62
101
|
if (newExpanded.has(index)) {
|
|
@@ -70,6 +109,21 @@ const AssignedSessionFilter = ({ onFilterChange, className = "", }) => {
|
|
|
70
109
|
const handleFilterSelect = (categoryId, subCategoryId) => {
|
|
71
110
|
const filterId = subCategoryId || categoryId;
|
|
72
111
|
setSelectedFilter(filterId);
|
|
112
|
+
// Find the selected category and subcategory
|
|
113
|
+
const category = messageCategories.find((cat) => cat.label === categoryId);
|
|
114
|
+
let query;
|
|
115
|
+
if (category) {
|
|
116
|
+
if (subCategoryId && category.subCategories) {
|
|
117
|
+
const subCategory = category.subCategories.find((sub) => sub.label === subCategoryId);
|
|
118
|
+
query = subCategory === null || subCategory === void 0 ? void 0 : subCategory.query;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
query = category.query;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (query) {
|
|
125
|
+
setFilterSummary(query);
|
|
126
|
+
}
|
|
73
127
|
onFilterChange === null || onFilterChange === void 0 ? void 0 : onFilterChange(categoryId, subCategoryId);
|
|
74
128
|
};
|
|
75
129
|
return (_jsxs("div", { className: `w-64 bg-white border-r border-gray-200 flex flex-col ${className}`, children: [_jsx("div", { className: "p-4 border-b border-gray-200", children: _jsx("h2", { className: "text-lg font-semibold text-gray-800", children: "TIN NH\u1EAEN C\u1EE6A T\u00D4I" }) }), _jsx("div", { className: "flex-1 overflow-y-auto", children: _jsx("ul", { className: "py-2", children: messageCategories.map((category, index) => (_jsxs("li", { children: [_jsxs("button", { onClick: () => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"im.d.ts","sourceRoot":"","sources":["../../src/constants/im.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,eAAO,MAAM,iBAAiB,eAAgD,CAAC"}
|
|
@@ -1,2 +1,14 @@
|
|
|
1
1
|
export declare const coreWasmPath = "https://droppiistg.blob.core.windows.net/droppii-stg-public/3315964d-11d5-4d27-8af7-d2ec2354994f.wasm";
|
|
2
|
+
export declare const SESSION_STATUS_ENUM: {
|
|
3
|
+
UNASSIGNED: string;
|
|
4
|
+
WAITING_PROCESS: string;
|
|
5
|
+
IN_PROCESS: string;
|
|
6
|
+
COMPLETED: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const TAG_ENUM: {
|
|
9
|
+
NONE: string;
|
|
10
|
+
AWAITING_REPLY: string;
|
|
11
|
+
SLOW_PROCESSING: string;
|
|
12
|
+
TEMPORARILY_PAUSED: string;
|
|
13
|
+
};
|
|
2
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,0GACgF,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,0GACgF,CAAC;AAE1G,eAAO,MAAM,mBAAmB;;;;;CAK/B,CAAC;AAEF,eAAO,MAAM,QAAQ;;;;;CAKpB,CAAC"}
|
package/dist/constants/index.js
CHANGED
|
@@ -1 +1,13 @@
|
|
|
1
1
|
export const coreWasmPath = "https://droppiistg.blob.core.windows.net/droppii-stg-public/3315964d-11d5-4d27-8af7-d2ec2354994f.wasm";
|
|
2
|
+
export const SESSION_STATUS_ENUM = {
|
|
3
|
+
UNASSIGNED: "UNASSIGNED",
|
|
4
|
+
WAITING_PROCESS: "WAITING_PROCESS",
|
|
5
|
+
IN_PROCESS: "IN_PROCESS",
|
|
6
|
+
COMPLETED: "COMPLETED",
|
|
7
|
+
};
|
|
8
|
+
export const TAG_ENUM = {
|
|
9
|
+
NONE: "NONE",
|
|
10
|
+
AWAITING_REPLY: "AWAITING_REPLY",
|
|
11
|
+
SLOW_PROCESSING: "SLOW_PROCESSING",
|
|
12
|
+
TEMPORARILY_PAUSED: "TEMPORARILY_PAUSED",
|
|
13
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatContext.d.ts","sourceRoot":"","sources":["../../src/context/ChatContext.tsx"],"names":[],"mappings":"AAIA,OAAO,EACL,eAAe,EACf,iBAAiB,
|
|
1
|
+
{"version":3,"file":"ChatContext.d.ts","sourceRoot":"","sources":["../../src/context/ChatContext.tsx"],"names":[],"mappings":"AAIA,OAAO,EACL,eAAe,EACf,iBAAiB,EAGlB,MAAM,eAAe,CAAC;AAIvB,eAAO,MAAM,WAAW,0CAOtB,CAAC;AAEH,eAAO,MAAM,cAAc,uBAAgC,CAAC;AAE5D,eAAO,MAAM,YAAY,GAAI,qCAI1B,iBAAiB,4CAoEnB,CAAC"}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { createContext, useContext, useEffect, useState } from "react";
|
|
4
|
-
import {
|
|
5
|
-
import { ConnectStatus, } from "../types/chat";
|
|
4
|
+
import { ConnectStatus, SyncStatus, } from "../types/chat";
|
|
6
5
|
import { DChatSDK } from "../constants/sdk";
|
|
7
6
|
import MainLayout from "../layout";
|
|
8
7
|
export const ChatContext = createContext({
|
|
9
8
|
user: null,
|
|
10
9
|
connectStatus: ConnectStatus.Disconnected,
|
|
10
|
+
syncStatus: SyncStatus.Success,
|
|
11
|
+
userTokenHandler: () => { },
|
|
12
|
+
updateConnectStatus: () => { },
|
|
13
|
+
updateSyncStatus: () => { },
|
|
11
14
|
});
|
|
12
15
|
export const useChatContext = () => useContext(ChatContext);
|
|
13
16
|
export const ChatProvider = ({ children, config, refetchToken, }) => {
|
|
14
17
|
const [connectStatus, setConnectStatus] = useState(ConnectStatus.Disconnected);
|
|
18
|
+
const [syncStatus, setSyncStatus] = useState(SyncStatus.Success);
|
|
15
19
|
const [user, setUser] = useState(null);
|
|
16
20
|
const getUserInfo = () => {
|
|
17
21
|
DChatSDK.getSelfUserInfo()
|
|
@@ -19,7 +23,7 @@ export const ChatProvider = ({ children, config, refetchToken, }) => {
|
|
|
19
23
|
setUser(data);
|
|
20
24
|
})
|
|
21
25
|
.catch(({ errCode, errMsg }) => {
|
|
22
|
-
console.
|
|
26
|
+
console.error("getSelfUserInfo", errCode, errMsg);
|
|
23
27
|
});
|
|
24
28
|
};
|
|
25
29
|
const handleLogin = (newToken) => {
|
|
@@ -29,48 +33,34 @@ export const ChatProvider = ({ children, config, refetchToken, }) => {
|
|
|
29
33
|
getUserInfo();
|
|
30
34
|
})
|
|
31
35
|
.catch(({ errCode, errMsg }) => {
|
|
32
|
-
console.
|
|
36
|
+
console.error("handleLogin", errCode, errMsg);
|
|
33
37
|
});
|
|
34
38
|
}
|
|
35
39
|
};
|
|
40
|
+
const userTokenHandler = () => {
|
|
41
|
+
refetchToken().then((token) => {
|
|
42
|
+
if (!!token) {
|
|
43
|
+
handleLogin(token);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
const updateConnectStatus = (status) => {
|
|
48
|
+
setConnectStatus(status);
|
|
49
|
+
};
|
|
50
|
+
const updateSyncStatus = (status) => {
|
|
51
|
+
setSyncStatus(status);
|
|
52
|
+
};
|
|
36
53
|
useEffect(() => {
|
|
37
54
|
if (config) {
|
|
38
55
|
handleLogin();
|
|
39
56
|
}
|
|
40
57
|
}, [config]);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
-
DChatSDK.on(CbEvents.OnUserTokenInvalid, () => {
|
|
51
|
-
console.log("OnUserTokenInvalid");
|
|
52
|
-
refetchToken().then((token) => {
|
|
53
|
-
if (!!token) {
|
|
54
|
-
handleLogin(token);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
DChatSDK.on(CbEvents.OnConnectSuccess, () => {
|
|
59
|
-
setConnectStatus(ConnectStatus.Connected);
|
|
60
|
-
});
|
|
61
|
-
DChatSDK.on(CbEvents.OnConnecting, () => {
|
|
62
|
-
setConnectStatus(ConnectStatus.Connecting);
|
|
63
|
-
});
|
|
64
|
-
DChatSDK.on(CbEvents.OnConnectFailed, () => {
|
|
65
|
-
setConnectStatus(ConnectStatus.Disconnected);
|
|
66
|
-
});
|
|
67
|
-
return () => {
|
|
68
|
-
DChatSDK.off(CbEvents.OnUserTokenExpired, () => { });
|
|
69
|
-
DChatSDK.off(CbEvents.OnUserTokenInvalid, () => { });
|
|
70
|
-
DChatSDK.off(CbEvents.OnConnectSuccess, () => { });
|
|
71
|
-
DChatSDK.off(CbEvents.OnConnectFailed, () => { });
|
|
72
|
-
DChatSDK.off(CbEvents.OnConnecting, () => { });
|
|
73
|
-
};
|
|
74
|
-
}, [refetchToken]);
|
|
75
|
-
return (_jsx(ChatContext.Provider, { value: { user, connectStatus }, children: _jsx(MainLayout, { children: children }) }));
|
|
58
|
+
return (_jsx(ChatContext.Provider, { value: {
|
|
59
|
+
user,
|
|
60
|
+
connectStatus,
|
|
61
|
+
syncStatus,
|
|
62
|
+
userTokenHandler,
|
|
63
|
+
updateConnectStatus,
|
|
64
|
+
updateSyncStatus,
|
|
65
|
+
}, children: _jsx(MainLayout, { children: children }) }));
|
|
76
66
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ConversationItem, SessionType } from "@openim/wasm-client-sdk";
|
|
2
|
-
export declare const
|
|
3
|
-
conversationList: ConversationItem[];
|
|
4
|
-
getAllConversationList: () => Promise<void>;
|
|
5
|
-
markConversationMessageAsRead: (conversationId: string) => void;
|
|
6
|
-
};
|
|
2
|
+
export declare const markConversationMessageAsRead: (conversationId: string) => void;
|
|
7
3
|
export declare const useConversationDetail: ({ sourceID, sessionType, }: {
|
|
8
4
|
sourceID: string;
|
|
9
5
|
sessionType: SessionType;
|
|
10
6
|
}) => {
|
|
11
7
|
conversationDetail: ConversationItem | null;
|
|
12
8
|
};
|
|
9
|
+
export declare const useConversationDisplayData: (conversation: ConversationItem | null) => {
|
|
10
|
+
avatar?: string | undefined;
|
|
11
|
+
displayName?: string | undefined;
|
|
12
|
+
};
|
|
13
13
|
//# sourceMappingURL=useConversation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConversation.d.ts","sourceRoot":"","sources":["../../../src/hooks/conversation/useConversation.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"useConversation.d.ts","sourceRoot":"","sources":["../../../src/hooks/conversation/useConversation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAQxE,eAAO,MAAM,6BAA6B,GAAI,gBAAgB,MAAM,SAOnE,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,4BAGnC;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,WAAW,CAAC;CAC1B;;CAuBA,CAAC;AAEF,eAAO,MAAM,0BAA0B,GACrC,cAAc,gBAAgB,GAAG,IAAI;;;CA4CtC,CAAC"}
|