@droppii-org/chat-sdk 0.1.52 → 0.1.54
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/biz-thread-detail/BizMessageList.d.ts.map +1 -1
- package/dist/components/biz-thread-detail/BizMessageList.js +16 -1
- package/dist/components/biz-thread-detail/bot/BotButtonMessage.d.ts +3 -0
- package/dist/components/biz-thread-detail/bot/BotButtonMessage.d.ts.map +1 -0
- package/dist/components/biz-thread-detail/bot/BotButtonMessage.js +29 -0
- package/dist/components/biz-thread-detail/bot/BotFlowContext.d.ts +10 -0
- package/dist/components/biz-thread-detail/bot/BotFlowContext.d.ts.map +1 -0
- package/dist/components/biz-thread-detail/bot/BotFlowContext.js +11 -0
- package/dist/components/biz-thread-detail/bot/BotStartButton.d.ts +8 -0
- package/dist/components/biz-thread-detail/bot/BotStartButton.d.ts.map +1 -0
- package/dist/components/biz-thread-detail/bot/BotStartButton.js +11 -0
- package/dist/components/biz-thread-detail/bot/index.d.ts +6 -0
- package/dist/components/biz-thread-detail/bot/index.d.ts.map +1 -0
- package/dist/components/biz-thread-detail/bot/index.js +3 -0
- package/dist/components/message/footer/index.d.ts.map +1 -1
- package/dist/components/message/footer/index.js +0 -1
- package/dist/components/message/item/LinkCard.d.ts +2 -1
- package/dist/components/message/item/LinkCard.d.ts.map +1 -1
- package/dist/components/message/item/LinkCard.js +5 -3
- package/dist/components/message/item/UrlTextMessage.d.ts.map +1 -1
- package/dist/components/message/item/UrlTextMessage.js +10 -7
- package/dist/components/message/item/index.d.ts.map +1 -1
- package/dist/components/message/item/index.js +5 -0
- package/dist/constants/botFlow.d.ts +8 -0
- package/dist/constants/botFlow.d.ts.map +1 -0
- package/dist/constants/botFlow.js +13 -0
- package/dist/hooks/biz/useBotFlow.d.ts +16 -0
- package/dist/hooks/biz/useBotFlow.d.ts.map +1 -0
- package/dist/hooks/biz/useBotFlow.js +68 -0
- package/dist/hooks/biz/useConversationDetail.d.ts +3 -0
- package/dist/hooks/biz/useConversationDetail.d.ts.map +1 -0
- package/dist/hooks/biz/useConversationDetail.js +18 -0
- package/dist/hooks/biz/useResetBotFlow.d.ts +3 -0
- package/dist/hooks/biz/useResetBotFlow.d.ts.map +1 -0
- package/dist/hooks/biz/useResetBotFlow.js +14 -0
- package/dist/hooks/biz/useRunBotFlow.d.ts +6 -0
- package/dist/hooks/biz/useRunBotFlow.d.ts.map +1 -0
- package/dist/hooks/biz/useRunBotFlow.js +14 -0
- package/dist/hooks/message/useMessage.d.ts.map +1 -1
- package/dist/hooks/message/useMessage.js +2 -0
- package/dist/hooks/message/useSendMessage.d.ts.map +1 -1
- package/dist/hooks/message/useSendMessage.js +2 -1
- package/dist/locales/vi/biz-inbox.json +4 -0
- package/dist/screens/biz-thread-detail/index.d.ts.map +1 -1
- package/dist/screens/biz-thread-detail/index.js +19 -1
- package/dist/services/query.d.ts +3 -0
- package/dist/services/query.d.ts.map +1 -1
- package/dist/services/query.js +3 -0
- package/dist/services/routes.d.ts +3 -0
- package/dist/services/routes.d.ts.map +1 -1
- package/dist/services/routes.js +3 -0
- package/dist/styles/global.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/biz.d.ts +79 -0
- package/dist/types/biz.d.ts.map +1 -1
- package/dist/types/biz.js +13 -0
- package/dist/types/chat.d.ts +0 -1
- package/dist/types/chat.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BizMessageList.d.ts","sourceRoot":"","sources":["../../../src/components/biz-thread-detail/BizMessageList.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BizMessageList.d.ts","sourceRoot":"","sources":["../../../src/components/biz-thread-detail/BizMessageList.tsx"],"names":[],"mappings":"AAkBA,QAAA,MAAM,cAAc,+CAuFnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -11,11 +11,15 @@ import useBizConversationStore from "../../store/bizConversation";
|
|
|
11
11
|
import useConversationStore from "../../store/conversation";
|
|
12
12
|
import useAuthStore from "../../store/auth";
|
|
13
13
|
import { isBizGroupChat } from "../../utils/bizConversation";
|
|
14
|
+
import { buildBotButtonsMessage } from "../../constants/botFlow";
|
|
14
15
|
import emitter from "../../utils/events";
|
|
15
16
|
import MessageItem from "../../components/message/item";
|
|
17
|
+
import { useBotFlowContext } from "./bot";
|
|
16
18
|
const BizMessageList = () => {
|
|
19
|
+
var _a, _b;
|
|
17
20
|
const { t } = useTranslation("biz-inbox");
|
|
18
21
|
const { user } = useChatContext();
|
|
22
|
+
const { buttons, disabled } = useBotFlowContext();
|
|
19
23
|
const authUserID = useAuthStore((state) => state.userID);
|
|
20
24
|
const conversation = useBizConversationStore((state) => state.conversationData);
|
|
21
25
|
const selectedConversationId = useConversationStore((state) => state.selectedConversationId);
|
|
@@ -25,12 +29,23 @@ const BizMessageList = () => {
|
|
|
25
29
|
const { scrollRef, loadMoreOldMessage, handleInfiniteScroll, scrollToBottomIfAtBottom, } = useMessageListScroll(Object.assign({ conversationId, userId: (user === null || user === void 0 ? void 0 : user.userID) || authUserID }, messageController));
|
|
26
30
|
const { loadState, moreOldLoading } = messageController;
|
|
27
31
|
const isMessageLoading = !conversationId || loadState.initLoading;
|
|
32
|
+
const botSenderId = ((_a = loadState.messageList.find((message) => message.sendID !== authUserID)) === null || _a === void 0 ? void 0 : _a.sendID) ||
|
|
33
|
+
((_b = conversation === null || conversation === void 0 ? void 0 : conversation.peer) === null || _b === void 0 ? void 0 : _b.id) ||
|
|
34
|
+
"";
|
|
35
|
+
const botButtonsMessage = buttons.length > 0 && !disabled
|
|
36
|
+
? buildBotButtonsMessage({
|
|
37
|
+
sendID: botSenderId,
|
|
38
|
+
})
|
|
39
|
+
: null;
|
|
40
|
+
const renderedMessages = botButtonsMessage
|
|
41
|
+
? [botButtonsMessage, ...loadState.messageList]
|
|
42
|
+
: loadState.messageList;
|
|
28
43
|
useEffect(() => {
|
|
29
44
|
emitter.on("BIZ_CHAT_SCROLL_TO_BOTTOM_IF_AT_BOTTOM", scrollToBottomIfAtBottom);
|
|
30
45
|
return () => {
|
|
31
46
|
emitter.off("BIZ_CHAT_SCROLL_TO_BOTTOM_IF_AT_BOTTOM", scrollToBottomIfAtBottom);
|
|
32
47
|
};
|
|
33
48
|
}, [scrollToBottomIfAtBottom]);
|
|
34
|
-
return (_jsx("div", { "data-testid": "biz-message-list", className: "relative flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-white", children: isMessageLoading ? (_jsx("div", { className: "flex flex-1 items-center justify-center py-12", children: _jsx(Spin, {}) })) : (_jsx(MessageInfiniteScroll, { scrollRef: scrollRef, scrollableTargetId: "scrollableBizMessagesDiv", loadState: loadState, moreOldLoading: moreOldLoading, onLoadMoreOld: loadMoreOldMessage, onScroll: handleInfiniteScroll, containerClassName: "h-full", empty: _jsx("div", { className: "flex flex-1 items-center justify-center py-12", children: _jsx(Empty, { description: t("empty.no_messages") }) }), children:
|
|
49
|
+
return (_jsx("div", { "data-testid": "biz-message-list", className: "relative flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-white", children: isMessageLoading ? (_jsx("div", { className: "flex flex-1 items-center justify-center py-12", children: _jsx(Spin, {}) })) : (_jsx(MessageInfiniteScroll, { scrollRef: scrollRef, scrollableTargetId: "scrollableBizMessagesDiv", loadState: loadState, moreOldLoading: moreOldLoading, onLoadMoreOld: loadMoreOldMessage, onScroll: handleInfiniteScroll, containerClassName: "h-full", empty: _jsx("div", { className: "flex flex-1 items-center justify-center py-12", children: _jsx(Empty, { description: t("empty.no_messages") }) }), children: renderedMessages.map((message, _index, array) => (_jsx(MessageItem, { message: message, allMessages: array, isGroupChat: isGroupChat }, message.clientMsgID))) })) }));
|
|
35
50
|
};
|
|
36
51
|
export default BizMessageList;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BotButtonMessage.d.ts","sourceRoot":"","sources":["../../../../src/components/biz-thread-detail/bot/BotButtonMessage.tsx"],"names":[],"mappings":"AAaA,QAAA,MAAM,gBAAgB,+CAmErB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import { useTranslation } from "react-i18next";
|
|
5
|
+
import { Icon } from "../../../components/icon";
|
|
6
|
+
import { BOT_BUTTON_MENU_THRESHOLD, BOT_DEFAULT_BUTTON_ID, } from "../../../constants/botFlow";
|
|
7
|
+
import { useBotFlowContext } from "./BotFlowContext";
|
|
8
|
+
const CHEVRON_SIZE = 20;
|
|
9
|
+
const BotButtonMessage = () => {
|
|
10
|
+
const { t } = useTranslation("biz-inbox");
|
|
11
|
+
const { buttons, disabled, onSelect, onRestart } = useBotFlowContext();
|
|
12
|
+
const isMenuStyle = buttons.length > BOT_BUTTON_MENU_THRESHOLD;
|
|
13
|
+
const handleSelect = (actionId) => {
|
|
14
|
+
if (disabled)
|
|
15
|
+
return;
|
|
16
|
+
if (actionId === BOT_DEFAULT_BUTTON_ID) {
|
|
17
|
+
onRestart();
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
onSelect(actionId);
|
|
21
|
+
};
|
|
22
|
+
const optionsNode = isMenuStyle ? (_jsx("div", { className: "flex flex-col overflow-hidden rounded-xl bg-white", children: buttons.map((option, index) => (_jsxs("button", { type: "button", disabled: disabled, onClick: () => handleSelect(option.id), className: clsx("flex items-center gap-4 px-3 py-2 text-left transition-colors", index !== buttons.length - 1 && "border-b border-gray-25", disabled && "cursor-not-allowed opacity-60"), children: [_jsx("span", { className: "flex-1 text-[16px] font-medium leading-[1.6] text-gray-900", children: option.id === BOT_DEFAULT_BUTTON_ID
|
|
23
|
+
? t("thread_detail.bot.restart")
|
|
24
|
+
: option.label }), _jsx(Icon, { icon: "angle-right-o", size: CHEVRON_SIZE, className: "text-gray-900" })] }, option.id))) })) : (_jsx("div", { className: "flex flex-col gap-2", children: buttons.map((option) => (_jsx("button", { type: "button", disabled: disabled, onClick: () => handleSelect(option.id), className: clsx("flex flex-1 items-center justify-center gap-2 rounded-lg border border-primary-400 bg-primary-25 px-3 py-2", "text-center text-[14px] font-[510] leading-[160%] text-primary-400 transition-colors", disabled && "cursor-not-allowed opacity-60"), children: _jsx("span", { children: option.id === BOT_DEFAULT_BUTTON_ID
|
|
25
|
+
? t("thread_detail.bot.restart")
|
|
26
|
+
: option.label }) }, option.id))) }));
|
|
27
|
+
return optionsNode;
|
|
28
|
+
};
|
|
29
|
+
export default BotButtonMessage;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BotButtonOption } from "../../../types/biz";
|
|
2
|
+
export interface BotFlowContextValue {
|
|
3
|
+
buttons: BotButtonOption[];
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
onSelect: (actionId: string) => void;
|
|
6
|
+
onRestart: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const BotFlowProvider: import("react").Provider<BotFlowContextValue>;
|
|
9
|
+
export declare const useBotFlowContext: () => BotFlowContextValue;
|
|
10
|
+
//# sourceMappingURL=BotFlowContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BotFlowContext.d.ts","sourceRoot":"","sources":["../../../../src/components/biz-thread-detail/bot/BotFlowContext.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB;AAWD,eAAO,MAAM,eAAe,+CAA0B,CAAC;AAEvD,eAAO,MAAM,iBAAiB,2BAAmC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
const noop = () => { };
|
|
4
|
+
const BotFlowContext = createContext({
|
|
5
|
+
buttons: [],
|
|
6
|
+
disabled: false,
|
|
7
|
+
onSelect: noop,
|
|
8
|
+
onRestart: noop,
|
|
9
|
+
});
|
|
10
|
+
export const BotFlowProvider = BotFlowContext.Provider;
|
|
11
|
+
export const useBotFlowContext = () => useContext(BotFlowContext);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface BotStartButtonProps {
|
|
2
|
+
label: string;
|
|
3
|
+
onClick: () => void;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare const BotStartButton: ({ label, onClick, disabled }: BotStartButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export default BotStartButton;
|
|
8
|
+
//# sourceMappingURL=BotStartButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BotStartButton.d.ts","sourceRoot":"","sources":["../../../../src/components/biz-thread-detail/bot/BotStartButton.tsx"],"names":[],"mappings":"AAOA,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,cAAc,GAAI,8BAA8B,mBAAmB,4CAkBxE,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import { Icon } from "../../../components/icon";
|
|
5
|
+
const ICON_SIZE = 20;
|
|
6
|
+
const BotStartButton = ({ label, onClick, disabled }) => {
|
|
7
|
+
return (_jsxs("button", { type: "button", onClick: onClick, disabled: disabled, className: clsx("flex h-12 w-full items-center justify-center gap-2 rounded-lg", "text-[16px] font-medium leading-[1.6] text-white transition-colors", disabled
|
|
8
|
+
? "cursor-not-allowed bg-primary-400/60"
|
|
9
|
+
: "bg-primary-400 active:bg-primary-400/90"), children: [_jsx(Icon, { icon: "chat-square-o", size: ICON_SIZE, className: "text-white" }), _jsx("span", { children: label })] }));
|
|
10
|
+
};
|
|
11
|
+
export default BotStartButton;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as BotStartButton } from "./BotStartButton";
|
|
2
|
+
export type { BotStartButtonProps } from "./BotStartButton";
|
|
3
|
+
export { default as BotButtonMessage } from "./BotButtonMessage";
|
|
4
|
+
export { BotFlowProvider, useBotFlowContext } from "./BotFlowContext";
|
|
5
|
+
export type { BotFlowContextValue } from "./BotFlowContext";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/biz-thread-detail/bot/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACtE,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/message/footer/index.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAEL,wBAAwB,EAEzB,MAAM,cAAc,CAAC;AAStB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAkB/C,UAAU,kBAAkB;IAC1B,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAClC,qBAAqB,CAAC,EAAE,MAAM,IAAI,CAAC;CACpC;AASD,eAAO,MAAM,oBAAoB,mDAY/B,CAAC;AAEH,eAAO,MAAM,uBAAuB,gCAAyC,CAAC;AAE9E,QAAA,MAAM,qBAAqB,GAAI,4CAG5B,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/message/footer/index.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAEL,wBAAwB,EAEzB,MAAM,cAAc,CAAC;AAStB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAkB/C,UAAU,kBAAkB;IAC1B,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAClC,qBAAqB,CAAC,EAAE,MAAM,IAAI,CAAC;CACpC;AASD,eAAO,MAAM,oBAAoB,mDAY/B,CAAC;AAEH,eAAO,MAAM,uBAAuB,gCAAyC,CAAC;AAE9E,QAAA,MAAM,qBAAqB,GAAI,4CAG5B,kBAAkB,4CAsSpB,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -80,7 +80,6 @@ const MessageFooterProvider = ({ currentSession, openCreateCannedModal, }) => {
|
|
|
80
80
|
if (!showLinkPreview || !previewUrl || !previewMetadata)
|
|
81
81
|
return undefined;
|
|
82
82
|
return {
|
|
83
|
-
url: previewUrl,
|
|
84
83
|
title: previewMetadata.title,
|
|
85
84
|
description: previewMetadata.description,
|
|
86
85
|
image: previewMetadata.image,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { UrlMetadataInfo } from "../../../types/chat";
|
|
2
2
|
export interface LinkCardProps {
|
|
3
3
|
metadata: UrlMetadataInfo;
|
|
4
|
+
url?: string;
|
|
4
5
|
}
|
|
5
|
-
declare const LinkCard: ({ metadata }: LinkCardProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
6
|
+
declare const LinkCard: ({ metadata, url }: LinkCardProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
6
7
|
export default LinkCard;
|
|
7
8
|
//# sourceMappingURL=LinkCard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkCard.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/LinkCard.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"LinkCard.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/LinkCard.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,eAAe,CAAC;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,QAAA,MAAM,QAAQ,GAAI,mBAAmB,aAAa,mDA6CjD,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -3,15 +3,17 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useTranslation } from "react-i18next";
|
|
4
4
|
import { getHostLabel } from "../../../utils/link";
|
|
5
5
|
import { openLink } from "../../../utils/openLink";
|
|
6
|
-
const LinkCard = ({ metadata }) => {
|
|
6
|
+
const LinkCard = ({ metadata, url }) => {
|
|
7
7
|
const { t } = useTranslation("biz-inbox");
|
|
8
|
-
const {
|
|
8
|
+
const { title, description, image } = metadata;
|
|
9
9
|
if (!title && !description && !image) {
|
|
10
10
|
return null;
|
|
11
11
|
}
|
|
12
12
|
const handleOpen = () => {
|
|
13
|
+
if (!url)
|
|
14
|
+
return;
|
|
13
15
|
openLink(url, t);
|
|
14
16
|
};
|
|
15
|
-
return (_jsxs("button", { type: "button", onClick: handleOpen, "data-testid": "link-message-card", className: "flex w-full max-w-[292px] flex-col overflow-hidden rounded-[12px] border border-gray-900/10 bg-white text-left", children: [image && (_jsx("div", { className: "aspect-[16/9] w-full overflow-hidden", children: _jsx("img", { src: image, alt: "", className: "h-full w-full object-cover" }) })), _jsxs("div", { className: "flex flex-col px-3 py-2", children: [title && (_jsx("p", { className: "truncate text-[14px] font-medium leading-[1.6] text-gray-900", children: title })), _jsx("p", { className: "truncate text-[12px] font-medium leading-[1.6] tracking-[0.12px] text-primary-400", children: getHostLabel(url) }), description && (_jsx("p", { className: "line-clamp-2 text-[12px] leading-[1.6] text-gray-600", children: description }))] })] }));
|
|
17
|
+
return (_jsxs("button", { type: "button", onClick: handleOpen, "data-testid": "link-message-card", className: "flex w-full max-w-[292px] flex-col overflow-hidden rounded-[12px] border border-gray-900/10 bg-white text-left", children: [image && (_jsx("div", { className: "aspect-[16/9] w-full overflow-hidden", children: _jsx("img", { src: image, alt: "", className: "h-full w-full object-cover" }) })), _jsxs("div", { className: "flex flex-col px-3 py-2", children: [title && (_jsx("p", { className: "truncate text-[14px] font-medium leading-[1.6] text-gray-900", children: title })), url && (_jsx("p", { className: "truncate text-[12px] font-medium leading-[1.6] tracking-[0.12px] text-primary-400", children: getHostLabel(url) })), description && (_jsx("p", { className: "line-clamp-2 text-[12px] leading-[1.6] text-gray-600", children: description }))] })] }));
|
|
16
18
|
};
|
|
17
19
|
export default LinkCard;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UrlTextMessage.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/UrlTextMessage.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAatD,UAAU,uBAAuB;IAC/B,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,QAAA,MAAM,kBAAkB,GAAI,OAAO,uBAAuB,
|
|
1
|
+
{"version":3,"file":"UrlTextMessage.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/UrlTextMessage.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAatD,UAAU,uBAAuB;IAC/B,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,QAAA,MAAM,kBAAkB,GAAI,OAAO,uBAAuB,4CAuEzD,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -6,7 +6,7 @@ import LinkText from "./LinkText";
|
|
|
6
6
|
import LinkCard from "./LinkCard";
|
|
7
7
|
import { MESSAGE_TEXT_CLASS } from "./textStyle";
|
|
8
8
|
const UrlTextMessageItem = (props) => {
|
|
9
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
9
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
10
10
|
const { message } = props;
|
|
11
11
|
let extendMessageInfo = null;
|
|
12
12
|
try {
|
|
@@ -17,18 +17,21 @@ const UrlTextMessageItem = (props) => {
|
|
|
17
17
|
console.error("Failed to parse extendMessageInfo", error);
|
|
18
18
|
}
|
|
19
19
|
const richHtmlContent = ((_b = (_a = extendMessageInfo === null || extendMessageInfo === void 0 ? void 0 : extendMessageInfo.messageInfo) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.content) || "";
|
|
20
|
+
const urlMetadata = extendMessageInfo === null || extendMessageInfo === void 0 ? void 0 : extendMessageInfo.urlMetadata;
|
|
21
|
+
const metadataUrl = (_d = (_c = message === null || message === void 0 ? void 0 : message.urlTextElem) === null || _c === void 0 ? void 0 : _c.urls) === null || _d === void 0 ? void 0 : _d[0];
|
|
22
|
+
const hasUrlMetadata = !!(urlMetadata &&
|
|
23
|
+
(urlMetadata.title || urlMetadata.description || urlMetadata.image));
|
|
20
24
|
if (richHtmlContent && htmlHasFormatting(richHtmlContent)) {
|
|
21
25
|
const sanitizedContent = sanitizeHtml(wrapLinksInHtml(richHtmlContent));
|
|
22
|
-
return (_jsx("div", { className: clsx("break-normal whitespace-pre-line flex-1", MESSAGE_TEXT_CLASS), style: { overflowWrap: "anywhere" }, dangerouslySetInnerHTML: { __html: sanitizedContent } }));
|
|
26
|
+
return (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("div", { className: clsx("break-normal whitespace-pre-line flex-1", MESSAGE_TEXT_CLASS), style: { overflowWrap: "anywhere" }, dangerouslySetInnerHTML: { __html: sanitizedContent } }), hasUrlMetadata && urlMetadata && (_jsx(LinkCard, { metadata: urlMetadata, url: metadataUrl }))] }));
|
|
23
27
|
}
|
|
24
|
-
const text = (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return (_jsxs("div", { className: "flex max-w-[292px] flex-col gap-2", children: [text && _jsx(LinkText, { text: text }), _jsx(LinkCard, { metadata: urlMetadata })] }));
|
|
28
|
+
const text = (_k = (_j = (_h = (_f = (_e = message === null || message === void 0 ? void 0 : message.textElem) === null || _e === void 0 ? void 0 : _e.content) !== null && _f !== void 0 ? _f : (_g = message === null || message === void 0 ? void 0 : message.urlTextElem) === null || _g === void 0 ? void 0 : _g.content) !== null && _h !== void 0 ? _h : message === null || message === void 0 ? void 0 : message.content) !== null && _j !== void 0 ? _j : stripHtml(richHtmlContent)) !== null && _k !== void 0 ? _k : "";
|
|
29
|
+
if (hasUrlMetadata && urlMetadata) {
|
|
30
|
+
return (_jsxs("div", { className: "flex max-w-[292px] flex-col gap-2", children: [text && _jsx(LinkText, { text: text }), _jsx(LinkCard, { metadata: urlMetadata, url: metadataUrl })] }));
|
|
28
31
|
}
|
|
29
32
|
if (text) {
|
|
30
33
|
return _jsx(LinkText, { text: text });
|
|
31
34
|
}
|
|
32
|
-
return (_jsx("span", { className: clsx("break-normal whitespace-pre-line flex-1", MESSAGE_TEXT_CLASS), style: { overflowWrap: "anywhere" }, children: ((
|
|
35
|
+
return (_jsx("span", { className: clsx("break-normal whitespace-pre-line flex-1", MESSAGE_TEXT_CLASS), style: { overflowWrap: "anywhere" }, children: ((_m = (_l = message === null || message === void 0 ? void 0 : message.urlTextElem) === null || _l === void 0 ? void 0 : _l.urls) === null || _m === void 0 ? void 0 : _m[0]) || "" }));
|
|
33
36
|
};
|
|
34
37
|
export default UrlTextMessageItem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,WAAW,IAAI,eAAe,EAG/B,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,WAAW,IAAI,eAAe,EAG/B,MAAM,yBAAyB,CAAC;AA+BjC,UAAU,gBAAgB;IACxB,OAAO,EAAE,eAAe,CAAC;IACzB,WAAW,EAAE,eAAe,EAAE,CAAC;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,uBAAuB,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAClD,eAAe,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;IACpD,mBAAmB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;CACrD;AAeD,QAAA,MAAM,WAAW,GAAI,wIASlB,gBAAgB,mDAkRlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -25,6 +25,8 @@ import RevokeMessageItem from "./RevokeMessage";
|
|
|
25
25
|
import QuoteMessageItem from "./QuoteMessage";
|
|
26
26
|
import SystemLogMessageItem from "./SystemLogMessage";
|
|
27
27
|
import { isSystemLogMessageType } from "../../../utils/messageLog";
|
|
28
|
+
import { BOT_BUTTONS_MESSAGE_TYPE } from "../../../constants/botFlow";
|
|
29
|
+
import BotButtonMessage from "../../../components/biz-thread-detail/bot/BotButtonMessage";
|
|
28
30
|
const MessageAvatar = ({ avatarUrl }) => avatarUrl ? (_jsx("img", { src: avatarUrl, alt: "", className: "h-6 w-6 shrink-0 self-end rounded-full object-cover" })) : (_jsx("div", { className: "flex h-6 w-6 shrink-0 items-center justify-center self-end rounded-full bg-chat-avatar", children: _jsx(Icon, { icon: "droppii-o-1", size: 14, className: "text-white" }) }));
|
|
29
31
|
const MessageItem = ({ message, allMessages, isGroupChat = false, contextMenuOpen, onContextMenuOpenChange, onRevokeMessage, onQuoteMessage, onPressQuoteMessage, }) => {
|
|
30
32
|
var _a;
|
|
@@ -52,6 +54,8 @@ const MessageItem = ({ message, allMessages, isGroupChat = false, contextMenuOpe
|
|
|
52
54
|
return _jsx(SystemLogMessageItem, { message: item });
|
|
53
55
|
case MessageType.RevokeMessage:
|
|
54
56
|
return _jsx(RevokeMessageItem, {});
|
|
57
|
+
case BOT_BUTTONS_MESSAGE_TYPE:
|
|
58
|
+
return _jsx(BotButtonMessage, {});
|
|
55
59
|
default:
|
|
56
60
|
return _jsx(TextMessageItem, { message: item });
|
|
57
61
|
}
|
|
@@ -69,6 +73,7 @@ const MessageItem = ({ message, allMessages, isGroupChat = false, contextMenuOpe
|
|
|
69
73
|
}, [userID, message]);
|
|
70
74
|
const contextMenuItems = useMemo(() => {
|
|
71
75
|
if ((message === null || message === void 0 ? void 0 : message.contentType) === MessageType.RevokeMessage ||
|
|
76
|
+
(message === null || message === void 0 ? void 0 : message.contentType) === BOT_BUTTONS_MESSAGE_TYPE ||
|
|
72
77
|
isSystemLogMessageType(message === null || message === void 0 ? void 0 : message.contentType)) {
|
|
73
78
|
return [];
|
|
74
79
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MessageItem, MessageType } from "@openim/wasm-client-sdk";
|
|
2
|
+
export declare const BOT_DEFAULT_BUTTON_ID = "default-item-button";
|
|
3
|
+
export declare const BOT_BUTTON_MENU_THRESHOLD = 3;
|
|
4
|
+
export declare const BOT_BUTTONS_MESSAGE_TYPE: MessageType;
|
|
5
|
+
export declare const buildBotButtonsMessage: ({ sendID, }: {
|
|
6
|
+
sendID: string;
|
|
7
|
+
}) => MessageItem;
|
|
8
|
+
//# sourceMappingURL=botFlow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"botFlow.d.ts","sourceRoot":"","sources":["../../src/constants/botFlow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAEX,WAAW,EACZ,MAAM,yBAAyB,CAAC;AAEjC,eAAO,MAAM,qBAAqB,wBAAwB,CAAC;AAE3D,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAE3C,eAAO,MAAM,wBAAwB,EAAwB,WAAW,CAAC;AAEzE,eAAO,MAAM,sBAAsB,GAAI,aAEpC;IACD,MAAM,EAAE,MAAM,CAAC;CAChB,KAAG,WAS0B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MessageStatus, } from "@openim/wasm-client-sdk";
|
|
2
|
+
export const BOT_DEFAULT_BUTTON_ID = "default-item-button";
|
|
3
|
+
export const BOT_BUTTON_MENU_THRESHOLD = 3;
|
|
4
|
+
export const BOT_BUTTONS_MESSAGE_TYPE = 990001;
|
|
5
|
+
export const buildBotButtonsMessage = ({ sendID, }) => ({
|
|
6
|
+
clientMsgID: "bot-buttons",
|
|
7
|
+
contentType: BOT_BUTTONS_MESSAGE_TYPE,
|
|
8
|
+
sendID,
|
|
9
|
+
sendTime: Date.now(),
|
|
10
|
+
status: MessageStatus.Succeed,
|
|
11
|
+
isInternal: false,
|
|
12
|
+
ex: "",
|
|
13
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type BotInputButtonsBlock } from "../../types/biz";
|
|
2
|
+
export type BotFlowStatus = "idle" | "not_started" | "running" | "waiting" | "ended";
|
|
3
|
+
interface UseBotFlowParams {
|
|
4
|
+
conversationId: string;
|
|
5
|
+
isBotThread: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const useBotFlow: ({ conversationId, isBotThread, }: UseBotFlowParams) => {
|
|
8
|
+
status: "running" | "not_started";
|
|
9
|
+
isProcessing: boolean;
|
|
10
|
+
currentButtonsBlock: BotInputButtonsBlock | null;
|
|
11
|
+
start: () => Promise<void>;
|
|
12
|
+
selectButton: (actionId: string) => Promise<void>;
|
|
13
|
+
restart: () => Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=useBotFlow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBotFlow.d.ts","sourceRoot":"","sources":["../../../src/hooks/biz/useBotFlow.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,KAAK,oBAAoB,EAC1B,MAAM,aAAa,CAAC;AAKrB,MAAM,MAAM,aAAa,GACrB,MAAM,GACN,aAAa,GACb,SAAS,GACT,SAAS,GACT,OAAO,CAAC;AAEZ,UAAU,gBAAgB;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;CACtB;AAYD,eAAO,MAAM,UAAU,GAAI,kCAGxB,gBAAgB;;;;;6BA0DqB,MAAM;;CAkB7C,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { BotBlockType, BotFlowNodeType, } from "../../types/biz";
|
|
4
|
+
import { useConversationDetail } from "./useConversationDetail";
|
|
5
|
+
import { useRunBotFlow } from "./useRunBotFlow";
|
|
6
|
+
import { useResetBotFlow } from "./useResetBotFlow";
|
|
7
|
+
const INITIAL_BOT_FLOW_STATE = {
|
|
8
|
+
conversationId: "",
|
|
9
|
+
flowCurrentStep: null,
|
|
10
|
+
};
|
|
11
|
+
export const useBotFlow = ({ conversationId, isBotThread, }) => {
|
|
12
|
+
var _a;
|
|
13
|
+
const [botFlowState, setBotFlowState] = useState(INITIAL_BOT_FLOW_STATE);
|
|
14
|
+
const { conversationId: storedConversationId, flowCurrentStep, } = botFlowState;
|
|
15
|
+
const detailQuery = useConversationDetail(conversationId, isBotThread);
|
|
16
|
+
const runMutation = useRunBotFlow();
|
|
17
|
+
const resetMutation = useResetBotFlow();
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (!isBotThread) {
|
|
20
|
+
setBotFlowState(INITIAL_BOT_FLOW_STATE);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (detailQuery.data) {
|
|
24
|
+
setBotFlowState({
|
|
25
|
+
conversationId,
|
|
26
|
+
flowCurrentStep: detailQuery.data.flowCurrentStep,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}, [isBotThread, conversationId, detailQuery.data]);
|
|
30
|
+
const activeStep = storedConversationId === conversationId ? flowCurrentStep : null;
|
|
31
|
+
const currentButtonsBlock = (_a = activeStep === null || activeStep === void 0 ? void 0 : activeStep.data.children.find((child) => child.type === BotBlockType.InputButtons)) !== null && _a !== void 0 ? _a : null;
|
|
32
|
+
const isProcessing = runMutation.isPending || resetMutation.isPending;
|
|
33
|
+
const status = (activeStep === null || activeStep === void 0 ? void 0 : activeStep.type) === BotFlowNodeType.Start ? "not_started" : "running";
|
|
34
|
+
const runStep = async (step, actionId = null) => {
|
|
35
|
+
const result = await runMutation.mutateAsync({
|
|
36
|
+
conversationId,
|
|
37
|
+
groupId: step.id,
|
|
38
|
+
childId: null,
|
|
39
|
+
actionId,
|
|
40
|
+
});
|
|
41
|
+
setBotFlowState({
|
|
42
|
+
conversationId,
|
|
43
|
+
flowCurrentStep: result.flowNextStep,
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
const start = async () => {
|
|
47
|
+
if (!activeStep)
|
|
48
|
+
return;
|
|
49
|
+
await runStep(activeStep);
|
|
50
|
+
};
|
|
51
|
+
const selectButton = async (actionId) => {
|
|
52
|
+
if (!activeStep)
|
|
53
|
+
return;
|
|
54
|
+
await runStep(activeStep, actionId);
|
|
55
|
+
};
|
|
56
|
+
const restart = async () => {
|
|
57
|
+
const resetDetail = await resetMutation.mutateAsync(conversationId);
|
|
58
|
+
await runStep(resetDetail.flowCurrentStep);
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
status,
|
|
62
|
+
isProcessing,
|
|
63
|
+
currentButtonsBlock,
|
|
64
|
+
start,
|
|
65
|
+
selectButton,
|
|
66
|
+
restart,
|
|
67
|
+
};
|
|
68
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { BizBotConversationDetail } from "../../types/biz";
|
|
2
|
+
export declare const useConversationDetail: (conversationId: string, enabled: boolean) => import("@tanstack/react-query").UseQueryResult<BizBotConversationDetail, Error>;
|
|
3
|
+
//# sourceMappingURL=useConversationDetail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useConversationDetail.d.ts","sourceRoot":"","sources":["../../../src/hooks/biz/useConversationDetail.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE5D,eAAO,MAAM,qBAAqB,GAChC,gBAAgB,MAAM,EACtB,SAAS,OAAO,oFAejB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { apiInstance } from "../../services/api";
|
|
4
|
+
import { ENDPOINTS } from "../../services/routes";
|
|
5
|
+
import { QUERY_KEYS } from "../../services/query";
|
|
6
|
+
export const useConversationDetail = (conversationId, enabled) => {
|
|
7
|
+
return useQuery({
|
|
8
|
+
queryKey: [QUERY_KEYS.GET_BIZ_CONVERSATION_DETAIL, conversationId],
|
|
9
|
+
queryFn: async () => {
|
|
10
|
+
const res = await apiInstance.get(ENDPOINTS.chatService.getBizConversationDetail(conversationId));
|
|
11
|
+
return res.data.data;
|
|
12
|
+
},
|
|
13
|
+
enabled: enabled && !!conversationId,
|
|
14
|
+
staleTime: 0,
|
|
15
|
+
refetchOnWindowFocus: false,
|
|
16
|
+
refetchOnReconnect: false,
|
|
17
|
+
});
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResetBotFlow.d.ts","sourceRoot":"","sources":["../../../src/hooks/biz/useResetBotFlow.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE5D,eAAO,MAAM,eAAe,2GAY3B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation } from "@tanstack/react-query";
|
|
3
|
+
import { apiInstance } from "../../services/api";
|
|
4
|
+
import { ENDPOINTS } from "../../services/routes";
|
|
5
|
+
import { QUERY_KEYS } from "../../services/query";
|
|
6
|
+
export const useResetBotFlow = () => {
|
|
7
|
+
return useMutation({
|
|
8
|
+
mutationKey: [QUERY_KEYS.RESET_BOT_FLOW],
|
|
9
|
+
mutationFn: async (conversationId) => {
|
|
10
|
+
const res = await apiInstance.post(ENDPOINTS.chatService.resetBotFlow(conversationId));
|
|
11
|
+
return res.data.data;
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RunBotFlowBody, RunBotFlowResponse } from "../../types/biz";
|
|
2
|
+
export interface RunBotFlowParams extends RunBotFlowBody {
|
|
3
|
+
conversationId: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const useRunBotFlow: () => import("@tanstack/react-query").UseMutationResult<RunBotFlowResponse, Error, RunBotFlowParams, unknown>;
|
|
6
|
+
//# sourceMappingURL=useRunBotFlow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRunBotFlow.d.ts","sourceRoot":"","sources":["../../../src/hooks/biz/useRunBotFlow.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtE,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACtD,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,aAAa,+GAgBzB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation } from "@tanstack/react-query";
|
|
3
|
+
import { apiInstance } from "../../services/api";
|
|
4
|
+
import { ENDPOINTS } from "../../services/routes";
|
|
5
|
+
import { QUERY_KEYS } from "../../services/query";
|
|
6
|
+
export const useRunBotFlow = () => {
|
|
7
|
+
return useMutation({
|
|
8
|
+
mutationKey: [QUERY_KEYS.RUN_BOT_FLOW],
|
|
9
|
+
mutationFn: async ({ conversationId, groupId, childId, actionId, }) => {
|
|
10
|
+
const res = await apiInstance.post(ENDPOINTS.chatService.runBotFlow(conversationId), { groupId, childId, actionId });
|
|
11
|
+
return res.data.data;
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMessage.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useMessage.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,WAAW,EACX,WAAW,EAEZ,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"useMessage.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useMessage.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,WAAW,EACX,WAAW,EAEZ,MAAM,yBAAyB,CAAC;AAWjC,eAAO,MAAM,kBAAkB,eAiB9B,CAAC;AAEF,eAAO,MAAM,UAAU,GACrB,iBAAiB,MAAM,EACvB,oBAAoB,MAAM,EAC1B,iBAAc;;;;;qBAeO,WAAW,EAAE;;;;;;qBAAb,WAAW,EAAE;;;;;;CA0QnC,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,SAAS,WAAW,SACpB,CAAC;AAChC,eAAO,MAAM,gBAAgB,GAAI,SAAS,WAAW,SACpB,CAAC;AAClC,eAAO,MAAM,gBAAgB,GAAI,aAAa,MAAM,SACf,CAAC;AAEtC,eAAO,MAAM,kBAAkB,GAC7B,aAAa,WAAW,EAAE,EAC1B,SAAS,WAAW,EACpB,WAAW,MAAM,GAAG,MAAM,KACzB,WAAW,GAAG,SAkBhB,CAAC"}
|
|
@@ -8,6 +8,7 @@ import isEmpty from "lodash/isEmpty";
|
|
|
8
8
|
import { useChatContext } from "../../context/ChatContext";
|
|
9
9
|
import useAuthStore from "../../store/auth";
|
|
10
10
|
import { ConnectStatus, SyncStatus } from "../../types/chat";
|
|
11
|
+
import { BOT_BUTTONS_MESSAGE_TYPE } from "../../constants/botFlow";
|
|
11
12
|
export const visibleTypeMessage = [
|
|
12
13
|
MessageType.TextMessage,
|
|
13
14
|
MessageType.PictureMessage,
|
|
@@ -24,6 +25,7 @@ export const visibleTypeMessage = [
|
|
|
24
25
|
MessageType.UrlTextMessage,
|
|
25
26
|
MessageType.RevokeMessage,
|
|
26
27
|
MessageType.LogTextMessage,
|
|
28
|
+
BOT_BUTTONS_MESSAGE_TYPE,
|
|
27
29
|
];
|
|
28
30
|
export const useMessage = (conversationId, searchClientMsgID, enabled = true) => {
|
|
29
31
|
const { connectStatus, syncStatus } = useChatContext();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSendMessage.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useSendMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,WAAW,EAGZ,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACrB,MAAM,cAAc,CAAC;AAWtB,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAQlC,OAAO,EAAgB,gBAAgB,EAAyB,MAAM,aAAa,CAAC;AAkBpF,eAAO,MAAM,iBAAiB,GAAI,SAAS;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB,YAE0C,CAAC;AAE5C,eAAO,MAAM,iBAAiB,GAAU,MAAM,MAAM,gCAanD,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAU,MAAM,oBAAoB,gCAaxE,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAU,iBAAiB,eAAe,gCAazE,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAU,MAAM,oBAAoB,gCAaxE,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAU,MAAM,mBAAmB,gCAatE,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAU,MAAM,MAAM,EAAE,MAAM,MAAM,EAAE,gCActE,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,MAAM,MAAM,EACZ,eAAe,WAAW,gCAc3B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAC9B,4BAA4B,GAC5B,wCAAwC,CAAC;AAE7C,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,EAAE,sBAAsB,CAAC;IACrC,sBAAsB,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,eAAe,CAAC;CACxE;AAED,eAAO,MAAM,cAAc,GAAI,UAAU,qBAAqB;iGAgPvD;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;QACrB,cAAc,CAAC,EAAE,gBAAgB,CAAC;QAClC,UAAU,EAAE,OAAO,CAAC;QACpB,WAAW,CAAC,EAAE,eAAe,CAAC;KAC/B,KAAG,OAAO,CAAC,OAAO,CAAC;mCAtHE,WAAW;CA2SpC,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAI,4CAIvC;IACD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,cAAc,CAAC,EAAE,gBAAgB,CAAC;CACnC,
|
|
1
|
+
{"version":3,"file":"useSendMessage.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useSendMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,WAAW,EAGZ,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACrB,MAAM,cAAc,CAAC;AAWtB,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAQlC,OAAO,EAAgB,gBAAgB,EAAyB,MAAM,aAAa,CAAC;AAkBpF,eAAO,MAAM,iBAAiB,GAAI,SAAS;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB,YAE0C,CAAC;AAE5C,eAAO,MAAM,iBAAiB,GAAU,MAAM,MAAM,gCAanD,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAU,MAAM,oBAAoB,gCAaxE,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAU,iBAAiB,eAAe,gCAazE,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAU,MAAM,oBAAoB,gCAaxE,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAU,MAAM,mBAAmB,gCAatE,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAU,MAAM,MAAM,EAAE,MAAM,MAAM,EAAE,gCActE,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,MAAM,MAAM,EACZ,eAAe,WAAW,gCAc3B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAC9B,4BAA4B,GAC5B,wCAAwC,CAAC;AAE7C,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,EAAE,sBAAsB,CAAC;IACrC,sBAAsB,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,eAAe,CAAC;CACxE;AAED,eAAO,MAAM,cAAc,GAAI,UAAU,qBAAqB;iGAgPvD;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;QACrB,cAAc,CAAC,EAAE,gBAAgB,CAAC;QAClC,UAAU,EAAE,OAAO,CAAC;QACpB,WAAW,CAAC,EAAE,eAAe,CAAC;KAC/B,KAAG,OAAO,CAAC,OAAO,CAAC;mCAtHE,WAAW;CA2SpC,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAI,4CAIvC;IACD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,cAAc,CAAC,EAAE,gBAAgB,CAAC;CACnC,sBA0BA,CAAC"}
|
|
@@ -455,7 +455,8 @@ export const generateExtendMessageInfo = ({ richText, urlMetadata, currentSessio
|
|
|
455
455
|
},
|
|
456
456
|
};
|
|
457
457
|
}
|
|
458
|
-
if (urlMetadata
|
|
458
|
+
if (urlMetadata &&
|
|
459
|
+
(urlMetadata.title || urlMetadata.description || urlMetadata.image)) {
|
|
459
460
|
extendMessageInfo.urlMetadata = urlMetadata;
|
|
460
461
|
}
|
|
461
462
|
return extendMessageInfo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screens/biz-thread-detail/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/screens/biz-thread-detail/index.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAQhF,MAAM,WAAW,yBAA0B,SAAQ,yBAAyB;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,QAAA,MAAM,oBAAoB,GAAI,gDAK3B,yBAAyB,mDAkE3B,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -12,15 +12,26 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
};
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
|
15
|
+
import { useTranslation } from "react-i18next";
|
|
15
16
|
import clsx from "clsx";
|
|
16
17
|
import useBizConversationStore from "../../store/bizConversation";
|
|
17
18
|
import { BizMessageList, BizThreadDetailHeader, BizThreadDetailInput, } from "../../components/biz-thread-detail";
|
|
19
|
+
import { BotFlowProvider, BotStartButton, } from "../../components/biz-thread-detail/bot";
|
|
20
|
+
import { useBotFlow } from "../../hooks/biz/useBotFlow";
|
|
21
|
+
import { isBizBotCrmChat } from "../../utils/bizConversation";
|
|
18
22
|
const DChatBizThreadDetail = (_a) => {
|
|
23
|
+
var _b, _c, _d;
|
|
19
24
|
var { className, children, onBack } = _a, inputProps = __rest(_a, ["className", "children", "onBack"]);
|
|
25
|
+
const { t } = useTranslation("biz-inbox");
|
|
20
26
|
const router = useRouter();
|
|
21
27
|
const pathname = usePathname();
|
|
22
28
|
const searchParams = useSearchParams();
|
|
23
29
|
const conversation = useBizConversationStore((state) => state.conversationData);
|
|
30
|
+
const isBotThread = conversation ? isBizBotCrmChat(conversation) : false;
|
|
31
|
+
const botFlow = useBotFlow({
|
|
32
|
+
conversationId: (_b = conversation === null || conversation === void 0 ? void 0 : conversation.conversationId) !== null && _b !== void 0 ? _b : "",
|
|
33
|
+
isBotThread,
|
|
34
|
+
});
|
|
24
35
|
const handleBack = () => {
|
|
25
36
|
const newSearchParams = new URLSearchParams(searchParams);
|
|
26
37
|
newSearchParams.delete("threadId");
|
|
@@ -31,6 +42,13 @@ const DChatBizThreadDetail = (_a) => {
|
|
|
31
42
|
if (!conversation) {
|
|
32
43
|
return null;
|
|
33
44
|
}
|
|
34
|
-
|
|
45
|
+
const isBotNotStarted = isBotThread && botFlow.status === "not_started";
|
|
46
|
+
const footer = isBotNotStarted ? (_jsx("div", { className: "bg-white p-6", children: _jsx(BotStartButton, { label: t("thread_detail.bot.start"), onClick: botFlow.start, disabled: botFlow.isProcessing }) })) : (_jsx(BizThreadDetailInput, Object.assign({}, inputProps)));
|
|
47
|
+
return (_jsx(BotFlowProvider, { value: {
|
|
48
|
+
buttons: (_d = (_c = botFlow.currentButtonsBlock) === null || _c === void 0 ? void 0 : _c.data.buttons) !== null && _d !== void 0 ? _d : [],
|
|
49
|
+
disabled: botFlow.isProcessing,
|
|
50
|
+
onSelect: botFlow.selectButton,
|
|
51
|
+
onRestart: botFlow.restart,
|
|
52
|
+
}, children: _jsxs("div", { "data-testid": "biz-thread-detail-root", className: clsx("relative flex h-full w-full flex-col overflow-hidden bg-white", className), children: [_jsx(BizThreadDetailHeader, { conversation: conversation, onBack: handleBack }), _jsx("div", { className: "flex min-h-0 flex-1 flex-col", children: children !== null && children !== void 0 ? children : _jsx(BizMessageList, {}) }), footer] }) }));
|
|
35
53
|
};
|
|
36
54
|
export default DChatBizThreadDetail;
|