@droppii-org/chat-sdk 0.0.40 → 0.0.41

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":"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,4CAkKrE,CAAC;AAEF,eAAe,aAAa,CAAC"}
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,4CA4LrE,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,33 @@ 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" && value === SessionTag.AWAITING_REPLY && isSameValue) {
90
+ newValue = SessionTag.NONE;
91
+ }
81
92
  if (currentSession) {
82
- updateSession({
83
- sessionId: currentSession.id,
84
- [type]: value,
85
- }, {
86
- onError(error) {
87
- var _a, _b;
88
- 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) ||
89
- t(`update_session_${type}_failed`));
90
- },
91
- onSuccess() {
92
- if (type === "status") {
93
- setCurrentSessionStatus(value);
94
- }
95
- else {
96
- setCurrentSessionTag(value);
97
- }
98
- },
99
- });
93
+ if (!isSameValue ||
94
+ (type === "tag" && value === SessionTag.AWAITING_REPLY)) {
95
+ updateSession({
96
+ sessionId: currentSession.id,
97
+ [type]: newValue,
98
+ }, {
99
+ onError(error) {
100
+ var _a, _b;
101
+ 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) ||
102
+ t(`update_session_${type}_failed`));
103
+ },
104
+ onSuccess() {
105
+ if (type === "status") {
106
+ setCurrentSessionStatus(value);
107
+ }
108
+ else {
109
+ setCurrentSessionTag(value);
110
+ }
111
+ },
112
+ });
113
+ }
100
114
  }
101
115
  };
102
116
  useEffect(() => {
@@ -105,6 +119,6 @@ const MessageHeader = ({ onClose, currentSession }) => {
105
119
  setCurrentSessionStatus(currentSession.status);
106
120
  }
107
121
  }, [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 }) }))] })] }));
122
+ 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
123
  };
110
124
  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;CACzD;AAED,QAAA,MAAM,aAAa,GAAI,8BAA8B,kBAAkB,4CAqEtE,CAAC;AAEF,eAAe,aAAa,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":"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,4CAyDnE,CAAC"}
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"}
@@ -47,6 +47,7 @@ export const ChatProvider = ({ children, config }) => {
47
47
  userID: config.userID,
48
48
  wsAddress: config.wsAddr,
49
49
  applicationType: config.applicationType,
50
+ isCrm: config.isCrm,
50
51
  });
51
52
  }
52
53
  }, [config]);
@@ -31,5 +31,6 @@
31
31
  "update_session_status_failed": "Cập nhật status không thành công",
32
32
  "update_session_tag_failed": "Cập nhật tag không thành công",
33
33
  "customer": "Khách hàng",
34
- "you": "Bạn"
34
+ "you": "Bạn",
35
+ "select_tag": "Chọn tag"
35
36
  }
@@ -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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@droppii-org/chat-sdk",
3
- "version": "0.0.40",
3
+ "version": "0.0.41",
4
4
  "description": "Droppii React Chat SDK",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",