@droppii-org/chat-sdk 0.1.4 → 0.1.5
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuoteMessage.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/QuoteMessage.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAe,MAAM,yBAAyB,CAAC;AAUnE,UAAU,qBAAqB;IAC7B,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,mBAAmB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;CACrD;AAED,QAAA,MAAM,gBAAgB,GAAI,2CAIvB,qBAAqB,
|
|
1
|
+
{"version":3,"file":"QuoteMessage.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/QuoteMessage.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAe,MAAM,yBAAyB,CAAC;AAUnE,UAAU,qBAAqB;IAC7B,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,mBAAmB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;CACrD;AAED,QAAA,MAAM,gBAAgB,GAAI,2CAIvB,qBAAqB,4CAuGvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -5,7 +5,7 @@ import { useTranslation } from "react-i18next";
|
|
|
5
5
|
import clsx from "clsx";
|
|
6
6
|
import MediaPreviewIcon from "../MediaPreviewIcon";
|
|
7
7
|
import useAuthStore from "../../../store/auth";
|
|
8
|
-
import {
|
|
8
|
+
import { useCallback } from "react";
|
|
9
9
|
import useConversationStore from "../../../store/conversation";
|
|
10
10
|
const QuoteMessageItem = ({ message, isMine, onPressQuoteMessage, }) => {
|
|
11
11
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -13,27 +13,54 @@ const QuoteMessageItem = ({ message, isMine, onPressQuoteMessage, }) => {
|
|
|
13
13
|
const isCrm = useAuthStore((state) => state.isCrm);
|
|
14
14
|
const conversationData = useConversationStore((state) => state.conversationData);
|
|
15
15
|
const { t } = useTranslation();
|
|
16
|
-
const
|
|
17
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
16
|
+
const parseReplyText = useCallback(() => {
|
|
17
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
18
|
+
const quoteMsg = (_a = message === null || message === void 0 ? void 0 : message.quoteElem) === null || _a === void 0 ? void 0 : _a.quoteMessage;
|
|
19
|
+
const senderID = message === null || message === void 0 ? void 0 : message.sendID;
|
|
20
|
+
const senderName = message === null || message === void 0 ? void 0 : message.senderNickname;
|
|
21
|
+
const targetID = quoteMsg === null || quoteMsg === void 0 ? void 0 : quoteMsg.sendID;
|
|
22
|
+
const targetName = quoteMsg === null || quoteMsg === void 0 ? void 0 : quoteMsg.senderNickname;
|
|
23
|
+
const isSelfReply = senderID && targetID && senderID === targetID;
|
|
24
|
+
const isFromMe = senderID === userID;
|
|
25
|
+
const isReplyToMe = targetID === userID;
|
|
26
|
+
const convoName = conversationData === null || conversationData === void 0 ? void 0 : conversationData.showName;
|
|
27
|
+
const isChatSupport = (_e = (_d = (_c = (_b = JSON === null || JSON === void 0 ? void 0 : JSON.parse) === null || _b === void 0 ? void 0 : _b.call(JSON, (conversationData === null || conversationData === void 0 ? void 0 : conversationData.ex) || "{}")) === null || _c === void 0 ? void 0 : _c.sessionInfo) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.botId;
|
|
28
|
+
// format name theo role
|
|
29
|
+
const formatName = (name, isTarget = false) => {
|
|
30
|
+
if (!name)
|
|
31
|
+
return "";
|
|
32
|
+
// Customer view → luôn dùng tên conversation
|
|
33
|
+
if (!isCrm && isChatSupport) {
|
|
34
|
+
return convoName;
|
|
35
|
+
}
|
|
36
|
+
// CX view
|
|
37
|
+
if (isTarget && targetID === userID) {
|
|
38
|
+
return t("you");
|
|
39
|
+
}
|
|
40
|
+
if (!isTarget && isFromMe) {
|
|
41
|
+
return t("you");
|
|
42
|
+
}
|
|
43
|
+
return name;
|
|
31
44
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
45
|
+
// 1. self reply
|
|
46
|
+
if (isSelfReply) {
|
|
47
|
+
return isFromMe
|
|
48
|
+
? ((_g = (_f = t("replied_yourself")) === null || _f === void 0 ? void 0 : _f.charAt(0)) === null || _g === void 0 ? void 0 : _g.toUpperCase()) +
|
|
49
|
+
((_h = t("replied_yourself")) === null || _h === void 0 ? void 0 : _h.slice(1)) // Đã trả lời chính mình
|
|
50
|
+
: `${formatName(senderName)} ${t("replied_yourself")}`;
|
|
51
|
+
}
|
|
52
|
+
// 2. mình reply người khác
|
|
53
|
+
if (isFromMe) {
|
|
54
|
+
return `${((_k = (_j = t("replied")) === null || _j === void 0 ? void 0 : _j.charAt(0)) === null || _k === void 0 ? void 0 : _k.toUpperCase()) + ((_l = t("replied")) === null || _l === void 0 ? void 0 : _l.slice(1))} ${formatName(targetName || "", true)}`;
|
|
55
|
+
}
|
|
56
|
+
// 3. người khác reply mình
|
|
57
|
+
if (isReplyToMe) {
|
|
58
|
+
return `${formatName(senderName || "")} ${t("replied_you")}`;
|
|
59
|
+
}
|
|
60
|
+
// 4. người khác ↔ người khác
|
|
61
|
+
return `${formatName(senderName || "")} ${t("replied")} ${formatName(targetName || "", true)}`;
|
|
62
|
+
}, [message, userID, isCrm, conversationData, t]);
|
|
63
|
+
return (_jsxs("div", { className: clsx("mb-[-4px] flex flex-col gap-1 flex-1 w-full", isMine ? "items-end" : "items-start"), children: [_jsxs("div", { className: "flex flex-row flex-1 items-center gap-2", children: [_jsx(Icon, { icon: "arrow-reply-b", size: 16, className: "text-blue-500" }), _jsx("span", { className: "text-xs text-gray-500", children: parseReplyText() })] }), _jsxs("div", { className: "flex flex-row flex-1 max-w-full items-center gap-2 border border-gray-200 rounded-2xl min-w-0 px-3 py-2 bg-gray-100 cursor-pointer", onClick: () => {
|
|
37
64
|
var _a, _b;
|
|
38
65
|
return onPressQuoteMessage === null || onPressQuoteMessage === void 0 ? void 0 : onPressQuoteMessage(((_b = (_a = message === null || message === void 0 ? void 0 : message.quoteElem) === null || _a === void 0 ? void 0 : _a.quoteMessage) === null || _b === void 0 ? void 0 : _b.clientMsgID) || "");
|
|
39
66
|
}, children: [_jsx(MediaPreviewIcon, { message: (_a = message === null || message === void 0 ? void 0 : message.quoteElem) === null || _a === void 0 ? void 0 : _a.quoteMessage }), _jsx("span", { className: "text-sm text-gray-500 truncate", children: generateContentBasedOnMessageType((_c = (_b = message === null || message === void 0 ? void 0 : message.quoteElem) === null || _b === void 0 ? void 0 : _b.quoteMessage) === null || _c === void 0 ? void 0 : _c.contentType, ((_f = (_e = (_d = message === null || message === void 0 ? void 0 : message.quoteElem) === null || _d === void 0 ? void 0 : _d.quoteMessage) === null || _e === void 0 ? void 0 : _e.textElem) === null || _f === void 0 ? void 0 : _f.content) || "") })] })] }));
|
|
@@ -90,11 +90,13 @@
|
|
|
90
90
|
"sessions_heading": "PHIÊN HỖ TRỢ",
|
|
91
91
|
"reply_to": "Đang trả lời {{name}}",
|
|
92
92
|
"your_self": "chính mình",
|
|
93
|
-
"replied_to": "{{from}} đã trả lời {{to}}",
|
|
94
93
|
"canned_responses": "Câu trả lời nhanh",
|
|
95
94
|
"team": "Team",
|
|
96
95
|
"personal": "Cá nhân",
|
|
97
96
|
"no_canned_response": "Không tìm thấy kết quả phù hợp",
|
|
98
97
|
"add_canned_response": "Thêm câu trả lời nhanh",
|
|
99
|
-
"canned_response_quick_search_placeholder": "Câu trả lời nhanh phù hợp với"
|
|
98
|
+
"canned_response_quick_search_placeholder": "Câu trả lời nhanh phù hợp với",
|
|
99
|
+
"replied_yourself": "đã trả lời chính mình",
|
|
100
|
+
"replied_you": "đã trả lời bạn",
|
|
101
|
+
"replied": "đã trả lời"
|
|
100
102
|
}
|