@droppii-org/chat-sdk 0.0.40 → 0.0.42
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/message/MessageHeader.d.ts.map +1 -1
- package/dist/components/message/MessageHeader.js +36 -20
- package/dist/components/message/SelectSession.d.ts +2 -1
- package/dist/components/message/SelectSession.d.ts.map +1 -1
- package/dist/components/message/SelectSession.js +3 -2
- package/dist/components/message/footer/ActionBar.d.ts.map +1 -1
- package/dist/components/message/footer/ActionBar.js +3 -3
- package/dist/context/ChatContext.d.ts.map +1 -1
- package/dist/context/ChatContext.js +1 -0
- package/dist/locales/vi/common.json +2 -1
- package/dist/store/auth.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageHeader.d.ts","sourceRoot":"","sources":["../../../src/components/message/MessageHeader.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGpD,UAAU,kBAAkB;IAC1B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,cAAc,CAAC,EAAE,gBAAgB,CAAC;CACnC;AAED,KAAK,sBAAsB,GAAG,aAAa,GAAG,UAAU,CAAC;AAEzD,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,sBAAsB,CAAC;IAC9B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,QAAA,MAAM,aAAa,GAAI,6BAA6B,kBAAkB,
|
|
1
|
+
{"version":3,"file":"MessageHeader.d.ts","sourceRoot":"","sources":["../../../src/components/message/MessageHeader.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGpD,UAAU,kBAAkB;IAC1B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,cAAc,CAAC,EAAE,gBAAgB,CAAC;CACnC;AAED,KAAK,sBAAsB,GAAG,aAAa,GAAG,UAAU,CAAC;AAEzD,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,sBAAsB,CAAC;IAC9B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,QAAA,MAAM,aAAa,GAAI,6BAA6B,kBAAkB,4CAgMrE,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -54,6 +54,13 @@ const MessageHeader = ({ onClose, currentSession }) => {
|
|
|
54
54
|
}, [t]);
|
|
55
55
|
const tagOptions = useMemo(() => {
|
|
56
56
|
return [
|
|
57
|
+
{
|
|
58
|
+
label: t("select_tag"),
|
|
59
|
+
value: SessionTag.NONE,
|
|
60
|
+
tintColorClassname: "text-gray-500",
|
|
61
|
+
tintColorClassnameBg: "bg-gray-500",
|
|
62
|
+
bgTintColorClassname: "bg-gray-100",
|
|
63
|
+
},
|
|
57
64
|
{
|
|
58
65
|
label: t("awaiting_reply"),
|
|
59
66
|
value: SessionTag.AWAITING_REPLY,
|
|
@@ -77,26 +84,35 @@ const MessageHeader = ({ onClose, currentSession }) => {
|
|
|
77
84
|
},
|
|
78
85
|
];
|
|
79
86
|
}, [t]);
|
|
80
|
-
const handleUpdateSession = (value, type) => {
|
|
87
|
+
const handleUpdateSession = (value, type, isSameValue) => {
|
|
88
|
+
let newValue = value;
|
|
89
|
+
if (type === "tag" &&
|
|
90
|
+
value === SessionTag.TEMPORARILY_PAUSED &&
|
|
91
|
+
isSameValue) {
|
|
92
|
+
newValue = SessionTag.NONE;
|
|
93
|
+
}
|
|
81
94
|
if (currentSession) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
if (!isSameValue ||
|
|
96
|
+
(type === "tag" && value === SessionTag.TEMPORARILY_PAUSED)) {
|
|
97
|
+
updateSession({
|
|
98
|
+
sessionId: currentSession.id,
|
|
99
|
+
[type]: newValue,
|
|
100
|
+
}, {
|
|
101
|
+
onError(error) {
|
|
102
|
+
var _a, _b;
|
|
103
|
+
message.error(((_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) ||
|
|
104
|
+
t(`update_session_${type}_failed`));
|
|
105
|
+
},
|
|
106
|
+
onSuccess() {
|
|
107
|
+
if (type === "status") {
|
|
108
|
+
setCurrentSessionStatus(value);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
setCurrentSessionTag(value);
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
}
|
|
100
116
|
}
|
|
101
117
|
};
|
|
102
118
|
useEffect(() => {
|
|
@@ -105,6 +121,6 @@ const MessageHeader = ({ onClose, currentSession }) => {
|
|
|
105
121
|
setCurrentSessionStatus(currentSession.status);
|
|
106
122
|
}
|
|
107
123
|
}, [currentSession]);
|
|
108
|
-
return (_jsxs("div", { className: "px-4 py-3 flex items-center border-b gap-3 bg-white no-transform", children: [_jsx(Avatar, { src: avatar, size: "large", className: "min-w-10 min-h-10", 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 overflow-hidden flex-1", children: [_jsx("p", { className: "text-base truncate", children: displayName || "" }), _jsx("p", { className: "text-xs text-gray-500 truncate", children: "2 thành viên" })] }), _jsxs("div", { className: "flex items-center gap-2 justify-end overflow-hidden", children: [isCx && (_jsx(SelectSession, { options: tagOptions, value: currentSessionTag, onChange: (value) => handleUpdateSession(value, "tag") })), isCx && (_jsx(SelectSession, { options: statusOptions, value: currentSessionStatus, onChange: (value) => handleUpdateSession(value, "status") })), _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(MediaCollection, {}), _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 }) }))] })] }));
|
|
124
|
+
return (_jsxs("div", { className: "px-4 py-3 flex items-center border-b gap-3 bg-white no-transform", children: [_jsx(Avatar, { src: avatar, size: "large", className: "min-w-10 min-h-10", 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 overflow-hidden flex-1", children: [_jsx("p", { className: "text-base truncate", children: displayName || "" }), _jsx("p", { className: "text-xs text-gray-500 truncate", children: "2 thành viên" })] }), _jsxs("div", { className: "flex items-center gap-2 justify-end overflow-hidden", children: [isCx && (_jsx(SelectSession, { options: tagOptions, value: currentSessionTag, onChange: (value) => handleUpdateSession(value, "tag", value === currentSessionTag), excludeOptions: [SessionTag.SLOW_PROCESSING, SessionTag.NONE] })), isCx && (_jsx(SelectSession, { options: statusOptions, value: currentSessionStatus, onChange: (value) => handleUpdateSession(value, "status", value === currentSessionStatus) })), _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(MediaCollection, {}), _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 }) }))] })] }));
|
|
109
125
|
};
|
|
110
126
|
export default MessageHeader;
|
|
@@ -3,7 +3,8 @@ interface SelectSessionProps {
|
|
|
3
3
|
options: SelectSessionOption[];
|
|
4
4
|
value: SelectSessionOption["value"];
|
|
5
5
|
onChange: (value: SelectSessionOption["value"]) => void;
|
|
6
|
+
excludeOptions?: SelectSessionOption["value"][];
|
|
6
7
|
}
|
|
7
|
-
declare const SelectSession: ({ options, value, onChange }: SelectSessionProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
declare const SelectSession: ({ options, value, onChange, excludeOptions, }: SelectSessionProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
9
|
export default SelectSession;
|
|
9
10
|
//# sourceMappingURL=SelectSession.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectSession.d.ts","sourceRoot":"","sources":["../../../src/components/message/SelectSession.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAMtD,UAAU,kBAAkB;IAC1B,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC/B,KAAK,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACpC,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"SelectSession.d.ts","sourceRoot":"","sources":["../../../src/components/message/SelectSession.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAMtD,UAAU,kBAAkB;IAC1B,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC/B,KAAK,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACpC,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;IACxD,cAAc,CAAC,EAAE,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC;CACjD;AAED,QAAA,MAAM,aAAa,GAAI,+CAKpB,kBAAkB,4CAuEpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -5,7 +5,8 @@ import { useBoolean } from "ahooks";
|
|
|
5
5
|
import { Icon } from "../icon";
|
|
6
6
|
import clsx from "clsx";
|
|
7
7
|
import { useTranslation } from "react-i18next";
|
|
8
|
-
const SelectSession = ({ options, value, onChange }) => {
|
|
8
|
+
const SelectSession = ({ options, value, onChange, excludeOptions, }) => {
|
|
9
|
+
var _a;
|
|
9
10
|
const { t } = useTranslation();
|
|
10
11
|
const [open, { toggle }] = useBoolean(false);
|
|
11
12
|
const selectedOption = options.find((option) => option.value === value);
|
|
@@ -13,7 +14,7 @@ const SelectSession = ({ options, value, onChange }) => {
|
|
|
13
14
|
onChange(value);
|
|
14
15
|
toggle();
|
|
15
16
|
};
|
|
16
|
-
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: clsx("flex items-center gap-2 px-3 py-1 rounded-sm min-w-[64px] cursor-pointer", selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.bgTintColorClassname, selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.tintColorClassname), onClick: toggle, children: [_jsx("span", { className: "text-xs font-medium truncate", children: (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) || "" }), _jsx(Icon, { icon: "angle-down-o", size: 14 })] }), _jsx(Modal, { title: t("update_session_status_title"), closable: { "aria-label": "Custom Close Button" }, open: open, onOk: toggle, onCancel: toggle, width: 300, styles: { content: { padding: 12 } }, footer: null, children: _jsx("div", { className: "flex flex-col gap-1", children: options.map((option) => {
|
|
17
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: clsx("flex items-center gap-2 px-3 py-1 rounded-sm min-w-[64px] cursor-pointer", selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.bgTintColorClassname, selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.tintColorClassname), onClick: toggle, children: [_jsx("span", { className: "text-xs font-medium truncate", children: (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) || "" }), _jsx(Icon, { icon: "angle-down-o", size: 14 })] }), _jsx(Modal, { title: t("update_session_status_title"), closable: { "aria-label": "Custom Close Button" }, open: open, onOk: toggle, onCancel: toggle, width: 300, styles: { content: { padding: 12 } }, footer: null, children: _jsx("div", { className: "flex flex-col gap-1", children: (_a = options === null || options === void 0 ? void 0 : options.filter) === null || _a === void 0 ? void 0 : _a.call(options, (option) => !(excludeOptions === null || excludeOptions === void 0 ? void 0 : excludeOptions.includes(option.value))).map((option) => {
|
|
17
18
|
const isSelected = option.value === value;
|
|
18
19
|
return (_jsxs("div", { className: "flex items-center gap-2 px-3 py-2 cursor-pointer hover:bg-gray-100 rounded-sm", onClick: () => onChange(option.value), onClickCapture: () => handleSelect(option.value), children: [_jsx("div", { className: clsx("w-2 h-2 rounded-full", option.tintColorClassnameBg) }), _jsx("span", { className: clsx("text-xs truncate flex-1", isSelected && "font-bold"), children: option.label }), isSelected && (_jsx(Icon, { icon: "check-b", size: 18, className: "text-blue-500" }))] }, option.value));
|
|
19
20
|
}) }) })] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBar.d.ts","sourceRoot":"","sources":["../../../../src/components/message/footer/ActionBar.tsx"],"names":[],"mappings":"AAkFA,QAAA,MAAM,SAAS,+
|
|
1
|
+
{"version":3,"file":"ActionBar.d.ts","sourceRoot":"","sources":["../../../../src/components/message/footer/ActionBar.tsx"],"names":[],"mappings":"AAkFA,QAAA,MAAM,SAAS,+CAwPd,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -101,12 +101,12 @@ const ActionBar = () => {
|
|
|
101
101
|
message.error(`${file.name} không đúng định dạng JPG, JPEG, PNG hoặc VIDEO`);
|
|
102
102
|
}
|
|
103
103
|
if (isErrorSize) {
|
|
104
|
-
if (isVideo) {
|
|
105
|
-
message.error(`Tệp không được vượt quá ${maxSize}MB`);
|
|
106
|
-
}
|
|
107
104
|
if (isImage) {
|
|
108
105
|
message.error(`${file.name} có kích thước tập tin vượt quá ${maxSize}MB`);
|
|
109
106
|
}
|
|
107
|
+
else {
|
|
108
|
+
message.error(`Tệp không được vượt quá ${maxSize}MB`);
|
|
109
|
+
}
|
|
110
110
|
}
|
|
111
111
|
return Upload.LIST_IGNORE;
|
|
112
112
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatContext.d.ts","sourceRoot":"","sources":["../../src/context/ChatContext.tsx"],"names":[],"mappings":"AAEA,OAAO,sBAAsB,CAAC;AAG9B,OAAO,EACL,eAAe,EACf,iBAAiB,EAGlB,MAAM,eAAe,CAAC;AASvB,eAAO,MAAM,WAAW,0CAOtB,CAAC;AAEH,eAAO,MAAM,cAAc,uBAAgC,CAAC;AAE5D,eAAO,MAAM,YAAY,GAAI,sBAAsB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"ChatContext.d.ts","sourceRoot":"","sources":["../../src/context/ChatContext.tsx"],"names":[],"mappings":"AAEA,OAAO,sBAAsB,CAAC;AAG9B,OAAO,EACL,eAAe,EACf,iBAAiB,EAGlB,MAAM,eAAe,CAAC;AASvB,eAAO,MAAM,WAAW,0CAOtB,CAAC;AAEH,eAAO,MAAM,cAAc,uBAAgC,CAAC;AAE5D,eAAO,MAAM,YAAY,GAAI,sBAAsB,iBAAiB,4CA0DnE,CAAC"}
|
package/dist/store/auth.js
CHANGED
|
@@ -17,7 +17,7 @@ const useAuthStore = create((set, get) => ({
|
|
|
17
17
|
initAuthStore: ({ accessToken, chatToken, apiAddress, wsAddress, platformID, userID, applicationType, isCrm, }) => {
|
|
18
18
|
var _a;
|
|
19
19
|
const jwtParser = !!accessToken ? jwtDecode(accessToken) : null;
|
|
20
|
-
const isCx = isCrm && ((_a = jwtParser === null || jwtParser === void 0 ? void 0 : jwtParser.role) === null || _a === void 0 ? void 0 : _a.includes("CRM_LIVE_CHAT"));
|
|
20
|
+
const isCx = !!isCrm && !!((_a = jwtParser === null || jwtParser === void 0 ? void 0 : jwtParser.role) === null || _a === void 0 ? void 0 : _a.includes("CRM_LIVE_CHAT"));
|
|
21
21
|
set({
|
|
22
22
|
accessToken,
|
|
23
23
|
chatToken,
|