@droppii-org/chat-sdk 0.0.70 → 0.0.71
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/thread/SessionSection.d.ts.map +1 -1
- package/dist/components/thread/SessionSection.js +52 -18
- package/dist/constants/sdk.d.ts.map +1 -1
- package/dist/constants/sdk.js +1 -2
- package/dist/hooks/global/useGlobalEvent.d.ts.map +1 -1
- package/dist/hooks/global/useGlobalEvent.js +7 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionSection.d.ts","sourceRoot":"","sources":["../../../src/components/thread/SessionSection.tsx"],"names":[],"mappings":"AASA,OAAO,EAAkB,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"SessionSection.d.ts","sourceRoot":"","sources":["../../../src/components/thread/SessionSection.tsx"],"names":[],"mappings":"AASA,OAAO,EAAkB,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAmBnE,eAAO,MAAM,iBAAiB,GAAI,wBAG/B;IACD,OAAO,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,EAAE,OAAO,CAAC;CACnB,4CAsMA,CAAC;AA8CF,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,cAAc,GAAI,yBAAyB,mBAAmB,4CAkDnE,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -25,17 +25,29 @@ export const SessionDetailCard = ({ session, isActive, }) => {
|
|
|
25
25
|
const { data: availableLabels, isLoading: isLoadingLabels } = useGetLabelSession();
|
|
26
26
|
const { mutate: updateSession } = useUpdateSessionInfo();
|
|
27
27
|
const { mutate: closeSession, isPending: isClosing } = useCloseSession();
|
|
28
|
-
const [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
const [noteInput, setNoteInput] = useState({
|
|
29
|
+
value: session.note || "",
|
|
30
|
+
sessionId: session.id,
|
|
31
|
+
});
|
|
32
|
+
const [issueDetailInput, setIssueDetailInput] = useState({
|
|
33
|
+
value: session.issueDetail || "",
|
|
34
|
+
sessionId: session.id,
|
|
35
|
+
});
|
|
36
|
+
const debouncedNoteInput = useDebounce(noteInput, { wait: 500 });
|
|
37
|
+
const debouncedIssueDetailInput = useDebounce(issueDetailInput, {
|
|
38
|
+
wait: 500,
|
|
39
|
+
});
|
|
32
40
|
useEffect(() => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
setNoteInput({ value: session.note || "", sessionId: session.id });
|
|
42
|
+
setIssueDetailInput({
|
|
43
|
+
value: session.issueDetail || "",
|
|
44
|
+
sessionId: session.id,
|
|
45
|
+
});
|
|
46
|
+
}, [session.id]);
|
|
36
47
|
useEffect(() => {
|
|
37
|
-
if (
|
|
38
|
-
|
|
48
|
+
if (debouncedNoteInput.sessionId === session.id &&
|
|
49
|
+
debouncedNoteInput.value !== (session.note || "")) {
|
|
50
|
+
updateSession({ sessionId: session.id, note: debouncedNoteInput.value }, {
|
|
39
51
|
onSuccess: () => {
|
|
40
52
|
queryClient.invalidateQueries({
|
|
41
53
|
queryKey: [QUERY_KEYS.GET_LIST_SESSION_BY_CONVERSATION],
|
|
@@ -43,12 +55,19 @@ export const SessionDetailCard = ({ session, isActive, }) => {
|
|
|
43
55
|
},
|
|
44
56
|
});
|
|
45
57
|
}
|
|
46
|
-
}, [
|
|
58
|
+
}, [
|
|
59
|
+
debouncedNoteInput,
|
|
60
|
+
session.note,
|
|
61
|
+
session.id,
|
|
62
|
+
updateSession,
|
|
63
|
+
queryClient,
|
|
64
|
+
]);
|
|
47
65
|
useEffect(() => {
|
|
48
|
-
if (
|
|
66
|
+
if (debouncedIssueDetailInput.sessionId === session.id &&
|
|
67
|
+
debouncedIssueDetailInput.value !== (session.issueDetail || "")) {
|
|
49
68
|
updateSession({
|
|
50
69
|
sessionId: session.id,
|
|
51
|
-
issueDetail:
|
|
70
|
+
issueDetail: debouncedIssueDetailInput.value,
|
|
52
71
|
}, {
|
|
53
72
|
onSuccess: () => {
|
|
54
73
|
queryClient.invalidateQueries({
|
|
@@ -58,7 +77,7 @@ export const SessionDetailCard = ({ session, isActive, }) => {
|
|
|
58
77
|
});
|
|
59
78
|
}
|
|
60
79
|
}, [
|
|
61
|
-
|
|
80
|
+
debouncedIssueDetailInput,
|
|
62
81
|
session.issueDetail,
|
|
63
82
|
session.id,
|
|
64
83
|
updateSession,
|
|
@@ -90,18 +109,33 @@ export const SessionDetailCard = ({ session, isActive, }) => {
|
|
|
90
109
|
value: label.id,
|
|
91
110
|
label: label.name,
|
|
92
111
|
}));
|
|
93
|
-
return (_jsxs("div", { className: `p-3 border rounded-lg shadow-md ${isActive ? "border-blue-500" : "border-gray-300"}`, children: [_jsxs("div", { className: "flex justify-between items-start mb-3", children: [_jsx("div", { className: "flex items-center gap-2", children: _jsxs("div", { className: "flex flex-col", children: [_jsxs("div", { className: "flex items-center gap-1", children: [_jsx(Icon, { icon: "chat-square-b", size: 16, className: "text-gray-500" }), _jsxs("p", { className: "font-semibold text-sm", children: ["Session ", session.order] })] }), _jsx("p", { className: "text-xs text-gray-400", children: formatSessionDate(session.closedDate || session.createdDate) })] }) }), isActive ? (_jsx(Tag, { color: "processing", children: "\u0110ang ho\u1EA1t \u0111\u1ED9ng" })) : (_jsx(Avatar, { src: (_a = session.supporter) === null || _a === void 0 ? void 0 : _a.avatar, size: 24, children: ((_d = (_c = (_b = session.supporter) === null || _b === void 0 ? void 0 : _b.username) === null || _c === void 0 ? void 0 : _c.charAt) === null || _d === void 0 ? void 0 : _d.call(_c, 0)) || "A" }))] }), _jsxs("div", { className: "flex flex-col gap-3 text-sm", children: [_jsxs("div", { className: "flex items-center gap-2 text-gray-500", children: [_jsx(Icon, { icon: "tag-o", size: 16, className: "mt-1" }), _jsx(Select, { mode: "multiple", loading: isLoadingLabels, className: "w-full", placeholder: "Th\u00EAm th\u1EBB...", options: labelOptions, value: (_e = session.labels) === null || _e === void 0 ? void 0 : _e.map((label) => label.id), onChange: handleUpdateLabels, removeIcon: true })] }), _jsxs("div", { className: "flex items-start gap-2 text-gray-500", children: [_jsx(Icon, { icon: "info-circle-o", size: 16, className: "mt-1" }), _jsx(TextArea, { value:
|
|
112
|
+
return (_jsxs("div", { className: `p-3 border rounded-lg shadow-md ${isActive ? "border-blue-500" : "border-gray-300"}`, children: [_jsxs("div", { className: "flex justify-between items-start mb-3", children: [_jsx("div", { className: "flex items-center gap-2", children: _jsxs("div", { className: "flex flex-col", children: [_jsxs("div", { className: "flex items-center gap-1", children: [_jsx(Icon, { icon: "chat-square-b", size: 16, className: "text-gray-500" }), _jsxs("p", { className: "font-semibold text-sm", children: ["Session ", session.order] })] }), _jsx("p", { className: "text-xs text-gray-400", children: formatSessionDate(session.closedDate || session.createdDate) })] }) }), isActive ? (_jsx(Tag, { color: "processing", children: "\u0110ang ho\u1EA1t \u0111\u1ED9ng" })) : (_jsx(Avatar, { src: (_a = session.supporter) === null || _a === void 0 ? void 0 : _a.avatar, size: 24, children: ((_d = (_c = (_b = session.supporter) === null || _b === void 0 ? void 0 : _b.username) === null || _c === void 0 ? void 0 : _c.charAt) === null || _d === void 0 ? void 0 : _d.call(_c, 0)) || "A" }))] }), _jsxs("div", { className: "flex flex-col gap-3 text-sm", children: [_jsxs("div", { className: "flex items-center gap-2 text-gray-500", children: [_jsx(Icon, { icon: "tag-o", size: 16, className: "mt-1" }), _jsx(Select, { mode: "multiple", loading: isLoadingLabels, className: "w-full", placeholder: "Th\u00EAm th\u1EBB...", options: labelOptions, value: (_e = session.labels) === null || _e === void 0 ? void 0 : _e.map((label) => label.id), onChange: handleUpdateLabels, removeIcon: true })] }), _jsxs("div", { className: "flex items-start gap-2 text-gray-500", children: [_jsx(Icon, { icon: "info-circle-o", size: 16, className: "mt-1" }), _jsx(TextArea, { value: issueDetailInput.value, onChange: (e) => setIssueDetailInput({
|
|
113
|
+
value: e.target.value,
|
|
114
|
+
sessionId: session.id,
|
|
115
|
+
}), placeholder: "V\u1EA5n \u0111\u1EC1 c\u1EE5 th\u1EC3...", className: "border-none !shadow-none py-0 px-2", autoSize: { minRows: 1, maxRows: 3 } })] }), _jsxs("div", { className: "flex items-start gap-2 text-gray-500", children: [_jsx(Icon, { icon: "paper-o", size: 16, className: "mt-1" }), _jsx(TextArea, { value: noteInput.value, onChange: (e) => setNoteInput({ value: e.target.value, sessionId: session.id }), placeholder: "Ghi ch\u00FA...", className: "border-none !shadow-none py-0 px-2", autoSize: { minRows: 1, maxRows: 3 } })] })] }), isActive && (_jsx(Button, { type: "primary", block: true, className: "mt-4", onClick: handleCloseSession, loading: isClosing, children: "\u0110\u00F3ng" }))] }));
|
|
94
116
|
};
|
|
95
|
-
const ClosedSessionItem = ({ session }) => {
|
|
117
|
+
const ClosedSessionItem = ({ session, expandedSessionId, onToggleExpand, }) => {
|
|
96
118
|
var _a, _b, _c, _d;
|
|
97
|
-
const
|
|
119
|
+
const isExpanded = session.id === expandedSessionId;
|
|
120
|
+
const handleClick = () => {
|
|
121
|
+
onToggleExpand(session.id);
|
|
122
|
+
};
|
|
98
123
|
if (isExpanded) {
|
|
99
124
|
return (_jsx("div", { children: _jsx(SessionDetailCard, { session: session, isActive: false }) }));
|
|
100
125
|
}
|
|
101
|
-
return (_jsxs("div", { className: "flex justify-between items-center p-2 rounded-md hover:bg-gray-100 cursor-pointer", onClick:
|
|
126
|
+
return (_jsxs("div", { className: "flex justify-between items-center p-2 rounded-md hover:bg-gray-100 cursor-pointer", onClick: handleClick, children: [_jsxs("div", { className: "flex items-center gap-2 text-sm", children: [_jsx(Icon, { icon: "chat-square-b", size: 16, className: "text-gray-500" }), _jsxs("span", { className: "font-semibold", children: ["Session ", session.order] }), _jsx("span", { className: "text-gray-400 text-xs", children: formatSessionDate(session.closedDate || session.createdDate) })] }), _jsx(Avatar, { src: (_a = session.supporter) === null || _a === void 0 ? void 0 : _a.avatar, size: 24, children: ((_d = (_c = (_b = session.supporter) === null || _b === void 0 ? void 0 : _b.username) === null || _c === void 0 ? void 0 : _c.charAt) === null || _d === void 0 ? void 0 : _d.call(_c, 0)) || "A" })] }));
|
|
102
127
|
};
|
|
103
128
|
const SessionSection = ({ sessions, isLoading }) => {
|
|
104
129
|
const [isOpen, { toggle }] = useBoolean(true);
|
|
105
|
-
|
|
130
|
+
const [expandedSessionId, setExpandedSessionId] = useState(null);
|
|
131
|
+
const handleToggleExpand = (sessionId) => {
|
|
132
|
+
setExpandedSessionId((prevId) => (prevId === sessionId ? null : sessionId));
|
|
133
|
+
};
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
if (!isOpen) {
|
|
136
|
+
setExpandedSessionId(null);
|
|
137
|
+
}
|
|
138
|
+
}, [isOpen]);
|
|
139
|
+
return (_jsxs("div", { className: "flex flex-col border-b", children: [_jsxs("div", { role: "button", onClick: toggle, className: "flex items-center justify-between px-4 py-2 rounded-md hover:bg-gray-100 sticky top-0 bg-white z-10", children: [_jsx("h3", { className: "font-bold text-gray-500 text-xs tracking-wider", children: "SESSIONS" }), _jsx(Icon, { icon: isOpen ? "angle-up-o" : "angle-down-o", size: 18 })] }), isOpen && (_jsx("div", { className: "px-4 pt-2 pb-4", children: isLoading ? (_jsx("div", { className: "text-center mt-4", children: _jsx(Spin, {}) })) : (_jsx("div", { className: "flex flex-col gap-1", children: sessions.map((session) => (_jsx(ClosedSessionItem, { session: session, expandedSessionId: expandedSessionId, onToggleExpand: handleToggleExpand }, session.id))) })) }))] }));
|
|
106
140
|
};
|
|
107
141
|
export default SessionSection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/constants/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/constants/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,eAAO,MAAM,QAAQ,EAAE,UAAU,CAAC,OAAO,MAAM,CAI7C,CAAC"}
|
package/dist/constants/sdk.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { getSDK } from "@openim/wasm-client-sdk";
|
|
2
|
-
import { coreWasmPath } from "./index";
|
|
3
2
|
export const DChatSDK = getSDK({
|
|
4
|
-
coreWasmPath,
|
|
3
|
+
coreWasmPath: typeof window !== "undefined" ? (window.localStorage.getItem("coreWasmPath") || '') : undefined,
|
|
5
4
|
sqlWasmPath: "/sql-wasm.wasm",
|
|
6
5
|
debug: process.env.NODE_ENV === "development",
|
|
7
6
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGlobalEvent.d.ts","sourceRoot":"","sources":["../../../src/hooks/global/useGlobalEvent.ts"],"names":[],"mappings":"AA8BA,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"useGlobalEvent.d.ts","sourceRoot":"","sources":["../../../src/hooks/global/useGlobalEvent.ts"],"names":[],"mappings":"AA8BA,eAAO,MAAM,cAAc,YAkQ1B,CAAC"}
|
|
@@ -45,8 +45,14 @@ export const useGlobalEvent = () => {
|
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
const handleNewMessage = (newServerMsg) => {
|
|
48
|
+
let customData = null;
|
|
48
49
|
if (newServerMsg.contentType === MessageType.CustomMessage) {
|
|
49
|
-
|
|
50
|
+
try {
|
|
51
|
+
customData = JSON.parse(newServerMsg.customElem.data);
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
console.error("Failed to parse custom message data", e);
|
|
55
|
+
}
|
|
50
56
|
if (customData &&
|
|
51
57
|
CustomType.CallingInvite <= customData.customType &&
|
|
52
58
|
customData.customType <= CustomType.CallingHungup) {
|