@droppii-org/chat-sdk 0.1.54 → 0.1.56

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.
Files changed (178) hide show
  1. package/dist/components/biz-inbox/BizThreadAvatar.d.ts +3 -3
  2. package/dist/components/biz-inbox/BizThreadAvatar.d.ts.map +1 -1
  3. package/dist/components/biz-inbox/BizThreadAvatar.js +5 -5
  4. package/dist/components/biz-inbox/BizThreadCard.d.ts +3 -3
  5. package/dist/components/biz-inbox/BizThreadCard.d.ts.map +1 -1
  6. package/dist/components/biz-inbox/BizThreadCard.js +7 -8
  7. package/dist/components/biz-inbox/BizThreadList.d.ts +3 -3
  8. package/dist/components/biz-inbox/BizThreadList.d.ts.map +1 -1
  9. package/dist/components/biz-inbox/BizThreadList.js +4 -8
  10. package/dist/components/biz-inbox/BizThreadTitle.d.ts +3 -3
  11. package/dist/components/biz-inbox/BizThreadTitle.d.ts.map +1 -1
  12. package/dist/components/biz-inbox/BizThreadTitle.js +5 -5
  13. package/dist/components/biz-thread-detail/BizMessageList.d.ts +5 -1
  14. package/dist/components/biz-thread-detail/BizMessageList.d.ts.map +1 -1
  15. package/dist/components/biz-thread-detail/BizMessageList.js +7 -23
  16. package/dist/components/biz-thread-detail/BizThreadDetailHeader.d.ts +2 -2
  17. package/dist/components/biz-thread-detail/BizThreadDetailHeader.d.ts.map +1 -1
  18. package/dist/components/biz-thread-detail/BizThreadDetailHeader.js +7 -5
  19. package/dist/components/biz-thread-detail/BizThreadDetailInput.d.ts.map +1 -1
  20. package/dist/components/biz-thread-detail/BizThreadDetailInput.js +8 -13
  21. package/dist/components/biz-thread-detail/bot/BotButtonMessage.d.ts +8 -1
  22. package/dist/components/biz-thread-detail/bot/BotButtonMessage.d.ts.map +1 -1
  23. package/dist/components/biz-thread-detail/bot/BotButtonMessage.js +5 -4
  24. package/dist/components/biz-thread-detail/bot/index.d.ts +1 -2
  25. package/dist/components/biz-thread-detail/bot/index.d.ts.map +1 -1
  26. package/dist/components/biz-thread-detail/bot/index.js +0 -1
  27. package/dist/components/conversation-detail/ConversationDetailHeader.d.ts +8 -0
  28. package/dist/components/conversation-detail/ConversationDetailHeader.d.ts.map +1 -0
  29. package/dist/components/conversation-detail/ConversationDetailHeader.js +18 -0
  30. package/dist/components/conversation-detail/ConversationDetailInput.d.ts +8 -0
  31. package/dist/components/conversation-detail/ConversationDetailInput.d.ts.map +1 -0
  32. package/dist/components/conversation-detail/ConversationDetailInput.js +258 -0
  33. package/dist/components/conversation-detail/ConversationMessageList.d.ts +7 -0
  34. package/dist/components/conversation-detail/ConversationMessageList.d.ts.map +1 -0
  35. package/dist/components/conversation-detail/ConversationMessageList.js +35 -0
  36. package/dist/components/conversation-detail/ConversationMoreOptionItem.d.ts +8 -0
  37. package/dist/components/conversation-detail/ConversationMoreOptionItem.d.ts.map +1 -0
  38. package/dist/components/conversation-detail/ConversationMoreOptionItem.js +19 -0
  39. package/dist/components/conversation-detail/ConversationMoreOptionPanel.d.ts +10 -0
  40. package/dist/components/conversation-detail/ConversationMoreOptionPanel.d.ts.map +1 -0
  41. package/dist/components/conversation-detail/ConversationMoreOptionPanel.js +20 -0
  42. package/dist/components/conversation-detail/bot/BotButtonMessage.d.ts +10 -0
  43. package/dist/components/conversation-detail/bot/BotButtonMessage.d.ts.map +1 -0
  44. package/dist/components/conversation-detail/bot/BotButtonMessage.js +30 -0
  45. package/dist/components/conversation-detail/bot/BotStartButton.d.ts +8 -0
  46. package/dist/components/conversation-detail/bot/BotStartButton.d.ts.map +1 -0
  47. package/dist/components/conversation-detail/bot/BotStartButton.js +11 -0
  48. package/dist/components/conversation-detail/bot/BotSuggest.d.ts +7 -0
  49. package/dist/components/conversation-detail/bot/BotSuggest.d.ts.map +1 -0
  50. package/dist/components/conversation-detail/bot/BotSuggest.js +11 -0
  51. package/dist/components/conversation-detail/bot/index.d.ts +7 -0
  52. package/dist/components/conversation-detail/bot/index.d.ts.map +1 -0
  53. package/dist/components/conversation-detail/bot/index.js +3 -0
  54. package/dist/components/conversation-detail/index.d.ts +10 -0
  55. package/dist/components/conversation-detail/index.d.ts.map +1 -0
  56. package/dist/components/conversation-detail/index.js +5 -0
  57. package/dist/components/conversation-inbox/ConversationInboxHeader.d.ts +3 -0
  58. package/dist/components/conversation-inbox/ConversationInboxHeader.d.ts.map +1 -0
  59. package/dist/components/conversation-inbox/ConversationInboxHeader.js +8 -0
  60. package/dist/components/conversation-inbox/ConversationInboxItem.d.ts +8 -0
  61. package/dist/components/conversation-inbox/ConversationInboxItem.d.ts.map +1 -0
  62. package/dist/components/conversation-inbox/ConversationInboxItem.js +30 -0
  63. package/dist/components/conversation-inbox/ConversationInboxList.d.ts +12 -0
  64. package/dist/components/conversation-inbox/ConversationInboxList.d.ts.map +1 -0
  65. package/dist/components/conversation-inbox/ConversationInboxList.js +36 -0
  66. package/dist/components/conversation-inbox/ConversationInboxTitle.d.ts +9 -0
  67. package/dist/components/conversation-inbox/ConversationInboxTitle.d.ts.map +1 -0
  68. package/dist/components/conversation-inbox/ConversationInboxTitle.js +7 -0
  69. package/dist/components/conversation-inbox/ConversationPeerAvatar.d.ts +10 -0
  70. package/dist/components/conversation-inbox/ConversationPeerAvatar.d.ts.map +1 -0
  71. package/dist/components/conversation-inbox/ConversationPeerAvatar.js +10 -0
  72. package/dist/components/conversation-inbox/index.d.ts +10 -0
  73. package/dist/components/conversation-inbox/index.d.ts.map +1 -0
  74. package/dist/components/conversation-inbox/index.js +5 -0
  75. package/dist/components/message/footer/LinkInputPreview.js +1 -1
  76. package/dist/components/message/item/ImageMessage.js +1 -1
  77. package/dist/components/message/item/LinkCard.js +1 -1
  78. package/dist/components/message/item/LinkText.js +1 -1
  79. package/dist/components/message/item/VideoMessage.js +1 -1
  80. package/dist/components/message/item/index.d.ts +2 -1
  81. package/dist/components/message/item/index.d.ts.map +1 -1
  82. package/dist/components/message/item/index.js +2 -7
  83. package/dist/components/message/item/mediaSize.d.ts.map +1 -1
  84. package/dist/components/message/item/mediaSize.js +8 -8
  85. package/dist/constants/botFlow.d.ts +0 -5
  86. package/dist/constants/botFlow.d.ts.map +1 -1
  87. package/dist/constants/botFlow.js +0 -11
  88. package/dist/constants/moreOption.d.ts +9 -0
  89. package/dist/constants/moreOption.d.ts.map +1 -0
  90. package/dist/constants/moreOption.js +37 -0
  91. package/dist/hooks/biz/useBotFlow.d.ts +3 -2
  92. package/dist/hooks/biz/useBotFlow.d.ts.map +1 -1
  93. package/dist/hooks/biz/useBotFlow.js +61 -2
  94. package/dist/hooks/biz/useRunBotFlow.d.ts +3 -2
  95. package/dist/hooks/biz/useRunBotFlow.d.ts.map +1 -1
  96. package/dist/hooks/conversation/useActiveConversation.d.ts +3 -0
  97. package/dist/hooks/conversation/useActiveConversation.d.ts.map +1 -0
  98. package/dist/hooks/conversation/useActiveConversation.js +31 -0
  99. package/dist/hooks/conversation/useBotConversationDetail.d.ts +3 -0
  100. package/dist/hooks/conversation/useBotConversationDetail.d.ts.map +1 -0
  101. package/dist/hooks/conversation/useBotConversationDetail.js +18 -0
  102. package/dist/hooks/conversation/useBotFlow.d.ts +18 -0
  103. package/dist/hooks/conversation/useBotFlow.d.ts.map +1 -0
  104. package/dist/hooks/conversation/useBotFlow.js +150 -0
  105. package/dist/hooks/conversation/useConversationList.d.ts +15 -0
  106. package/dist/hooks/conversation/useConversationList.d.ts.map +1 -0
  107. package/dist/hooks/conversation/useConversationList.js +70 -0
  108. package/dist/hooks/conversation/useCreateConversation.d.ts +8 -0
  109. package/dist/hooks/conversation/useCreateConversation.d.ts.map +1 -0
  110. package/dist/hooks/conversation/useCreateConversation.js +15 -0
  111. package/dist/hooks/conversation/useResetBotFlow.d.ts +3 -0
  112. package/dist/hooks/conversation/useResetBotFlow.d.ts.map +1 -0
  113. package/dist/hooks/conversation/useResetBotFlow.js +14 -0
  114. package/dist/hooks/conversation/useRunBotFlow.d.ts +7 -0
  115. package/dist/hooks/conversation/useRunBotFlow.d.ts.map +1 -0
  116. package/dist/hooks/conversation/useRunBotFlow.js +14 -0
  117. package/dist/hooks/global/useGlobalEvent.d.ts.map +1 -1
  118. package/dist/hooks/global/useGlobalEvent.js +15 -7
  119. package/dist/hooks/message/useMessage.d.ts.map +1 -1
  120. package/dist/hooks/message/useMessage.js +0 -2
  121. package/dist/hooks/message/useSendMessage.d.ts +6 -4
  122. package/dist/hooks/message/useSendMessage.d.ts.map +1 -1
  123. package/dist/hooks/message/useSendMessage.js +6 -2
  124. package/dist/hooks/user/useAuth.js +2 -2
  125. package/dist/index.d.ts +12 -11
  126. package/dist/index.d.ts.map +1 -1
  127. package/dist/index.js +7 -6
  128. package/dist/locales/i18n.js +3 -3
  129. package/dist/locales/i18n.ts +3 -3
  130. package/dist/locales/vi/biz-inbox.json +39 -39
  131. package/dist/locales/vi/conversation-inbox.json +39 -0
  132. package/dist/screens/biz-message/index.d.ts +3 -4
  133. package/dist/screens/biz-message/index.d.ts.map +1 -1
  134. package/dist/screens/biz-message/index.js +5 -9
  135. package/dist/screens/biz-thread-detail/index.d.ts.map +1 -1
  136. package/dist/screens/biz-thread-detail/index.js +10 -14
  137. package/dist/screens/conversation-detail/index.d.ts +9 -0
  138. package/dist/screens/conversation-detail/index.d.ts.map +1 -0
  139. package/dist/screens/conversation-detail/index.js +53 -0
  140. package/dist/screens/conversation-inbox/index.d.ts +8 -0
  141. package/dist/screens/conversation-inbox/index.d.ts.map +1 -0
  142. package/dist/screens/conversation-inbox/index.js +30 -0
  143. package/dist/services/query.d.ts +0 -1
  144. package/dist/services/query.d.ts.map +1 -1
  145. package/dist/services/query.js +0 -1
  146. package/dist/services/routes.d.ts +0 -1
  147. package/dist/services/routes.d.ts.map +1 -1
  148. package/dist/services/routes.js +0 -1
  149. package/dist/store/conversation.d.ts.map +1 -1
  150. package/dist/store/conversation.js +14 -5
  151. package/dist/store/messageDraft.d.ts +9 -0
  152. package/dist/store/messageDraft.d.ts.map +1 -0
  153. package/dist/store/messageDraft.js +35 -0
  154. package/dist/store/type.d.ts +6 -1
  155. package/dist/store/type.d.ts.map +1 -1
  156. package/dist/styles/global.css +1 -1
  157. package/dist/tsconfig.tsbuildinfo +1 -1
  158. package/dist/types/biz.d.ts +1 -5
  159. package/dist/types/biz.d.ts.map +1 -1
  160. package/dist/types/chat.d.ts +6 -0
  161. package/dist/types/chat.d.ts.map +1 -1
  162. package/dist/types/conversation.d.ts +116 -0
  163. package/dist/types/conversation.d.ts.map +1 -0
  164. package/dist/types/conversation.js +33 -0
  165. package/dist/utils/common.d.ts +1 -1
  166. package/dist/utils/common.d.ts.map +1 -1
  167. package/dist/utils/common.js +5 -3
  168. package/dist/utils/conversation.d.ts +12 -0
  169. package/dist/utils/conversation.d.ts.map +1 -0
  170. package/dist/utils/conversation.js +53 -0
  171. package/dist/utils/events.d.ts +1 -1
  172. package/dist/utils/events.d.ts.map +1 -1
  173. package/dist/utils/fileValidation.d.ts +2 -1
  174. package/dist/utils/fileValidation.d.ts.map +1 -1
  175. package/dist/utils/fileValidation.js +10 -1
  176. package/dist/utils/imCommon.d.ts +1 -0
  177. package/dist/utils/imCommon.d.ts.map +1 -1
  178. package/package.json +1 -1
@@ -0,0 +1,36 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { usePathname, useRouter, useSearchParams } from "next/navigation";
4
+ import { useTranslation } from "react-i18next";
5
+ import { Empty, Spin } from "antd";
6
+ import InfiniteScroll from "react-infinite-scroll-component";
7
+ import useConversationStore from "../../store/conversation";
8
+ import { Icon } from "../../components/icon";
9
+ import ConversationInboxItem from "./ConversationInboxItem";
10
+ const FooterSkeleton = () => (_jsxs("div", { className: "flex items-center gap-3 p-3", children: [_jsx("div", { className: "h-10 w-10 animate-pulse rounded-full bg-neutral-200" }), _jsxs("div", { className: "flex flex-1 flex-col gap-2", children: [_jsx("div", { className: "h-3 w-1/2 animate-pulse rounded bg-neutral-200" }), _jsx("div", { className: "h-2.5 w-1/3 animate-pulse rounded bg-neutral-200" })] })] }));
11
+ const ConversationInboxList = ({ items, isLoading, isFetchingNextPage, hasNextPage, onLoadMore, onSelectThread, }) => {
12
+ const { t } = useTranslation("conversation-inbox");
13
+ const router = useRouter();
14
+ const pathname = usePathname();
15
+ const searchParams = useSearchParams();
16
+ const setConversationData = useConversationStore((state) => state.setConversationData);
17
+ const setSelectedConversationId = useConversationStore((state) => state.setSelectedConversationId);
18
+ const handleSelectThread = (item) => {
19
+ const newSearchParams = new URLSearchParams(searchParams);
20
+ newSearchParams.set("threadId", item.conversationID);
21
+ router.push(`${pathname}?${newSearchParams.toString()}`);
22
+ setSelectedConversationId(item.conversationID);
23
+ setConversationData(item);
24
+ onSelectThread === null || onSelectThread === void 0 ? void 0 : onSelectThread(item);
25
+ };
26
+ const handleEndReached = () => {
27
+ if (hasNextPage && !isFetchingNextPage) {
28
+ onLoadMore();
29
+ }
30
+ };
31
+ if (isLoading) {
32
+ return (_jsx("div", { "data-testid": "conversation-inbox-thread-list", className: "flex flex-1 items-center justify-center py-12", children: _jsx(Spin, {}) }));
33
+ }
34
+ return (_jsx("div", { id: "scrollableConversationThreadsDiv", "data-testid": "conversation-inbox-thread-list", className: "min-h-0 w-full flex-1 overflow-auto", children: _jsx(InfiniteScroll, { dataLength: items.length, next: handleEndReached, hasMore: hasNextPage, loader: isFetchingNextPage ? _jsx(FooterSkeleton, {}) : null, scrollableTarget: "scrollableConversationThreadsDiv", children: items.length === 0 ? (_jsx("div", { className: "flex items-center justify-center py-12", children: _jsx(Empty, { image: _jsx(Icon, { icon: "chat-square-b", size: 80, className: "text-gray-300" }), description: t("empty.no_conversations") }) })) : (items.map((item) => (_jsx(ConversationInboxItem, { item: item, onClick: handleSelectThread }, item.conversationID)))) }) }));
35
+ };
36
+ export default ConversationInboxList;
@@ -0,0 +1,9 @@
1
+ import { PeerType } from "../../types/conversation";
2
+ export interface ConversationInboxTitleProps {
3
+ peerType: PeerType;
4
+ displayName: string;
5
+ hasUnread?: boolean;
6
+ }
7
+ declare const ConversationInboxTitle: ({ peerType, displayName, hasUnread, }: ConversationInboxTitleProps) => import("react/jsx-runtime").JSX.Element;
8
+ export default ConversationInboxTitle;
9
+ //# sourceMappingURL=ConversationInboxTitle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConversationInboxTitle.d.ts","sourceRoot":"","sources":["../../../src/components/conversation-inbox/ConversationInboxTitle.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,QAAA,MAAM,sBAAsB,GAAI,uCAI7B,2BAA2B,4CAmB7B,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
@@ -0,0 +1,7 @@
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
+ import { PeerType } from "../../types/conversation";
6
+ const ConversationInboxTitle = ({ peerType, displayName, hasUnread = false, }) => (_jsxs("div", { className: "flex min-w-0 items-center gap-1", children: [peerType === PeerType.GROUP && (_jsx(Icon, { icon: "user-two-b", size: 12, className: "shrink-0 text-black" })), peerType === PeerType.BOT && (_jsx("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-black text-white", children: _jsx(Icon, { icon: "droppii-o-1", size: 8 }) })), _jsx("span", { className: clsx("min-w-0 truncate text-[16px] leading-[160%] text-black [font-feature-settings:'liga'_off,'clig'_off]", hasUnread ? "font-bold tracking-[0.16px]" : "font-[510]"), children: displayName })] }));
7
+ export default ConversationInboxTitle;
@@ -0,0 +1,10 @@
1
+ import { PeerType } from "../../types/conversation";
2
+ export interface ConversationPeerAvatarProps {
3
+ peerType: PeerType;
4
+ displayName: string;
5
+ avatarUrl: string | null;
6
+ badgeLabel: string;
7
+ }
8
+ declare const ConversationPeerAvatar: ({ peerType, displayName, avatarUrl, badgeLabel, }: ConversationPeerAvatarProps) => import("react/jsx-runtime").JSX.Element;
9
+ export default ConversationPeerAvatar;
10
+ //# sourceMappingURL=ConversationPeerAvatar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConversationPeerAvatar.d.ts","sourceRoot":"","sources":["../../../src/components/conversation-inbox/ConversationPeerAvatar.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,sBAAsB,GAAI,mDAK7B,2BAA2B,4CAyB7B,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import clsx from "clsx";
4
+ import { Avatar } from "antd";
5
+ import { resolvePeerBadgeColor } from "../../utils/conversation";
6
+ const ConversationPeerAvatar = ({ peerType, displayName, avatarUrl, badgeLabel, }) => {
7
+ const badge = badgeLabel ? (_jsx("span", { className: clsx("absolute -bottom-px -right-px flex h-[17px] items-center justify-center gap-2 rounded-md border border-white px-1 text-[10px] font-semibold leading-3 text-white shadow-badge-inset", resolvePeerBadgeColor(peerType)), children: badgeLabel })) : null;
8
+ return (_jsxs("div", { className: "relative h-12 w-12 shrink-0", children: [_jsx(Avatar, { size: 48, src: avatarUrl || undefined, alt: displayName, className: "uppercase", children: (displayName === null || displayName === void 0 ? void 0 : displayName.charAt(0)) || "A" }), badge] }));
9
+ };
10
+ export default ConversationPeerAvatar;
@@ -0,0 +1,10 @@
1
+ export { default as ConversationInboxHeader } from "./ConversationInboxHeader";
2
+ export { default as ConversationPeerAvatar } from "./ConversationPeerAvatar";
3
+ export type { ConversationPeerAvatarProps } from "./ConversationPeerAvatar";
4
+ export { default as ConversationInboxTitle } from "./ConversationInboxTitle";
5
+ export type { ConversationInboxTitleProps } from "./ConversationInboxTitle";
6
+ export { default as ConversationInboxItem } from "./ConversationInboxItem";
7
+ export type { ConversationInboxItemProps } from "./ConversationInboxItem";
8
+ export { default as ConversationInboxList } from "./ConversationInboxList";
9
+ export type { ConversationInboxListProps } from "./ConversationInboxList";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/conversation-inbox/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAE/E,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,YAAY,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAE5E,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,YAAY,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAE5E,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,YAAY,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAE1E,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,YAAY,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { default as ConversationInboxHeader } from "./ConversationInboxHeader";
2
+ export { default as ConversationPeerAvatar } from "./ConversationPeerAvatar";
3
+ export { default as ConversationInboxTitle } from "./ConversationInboxTitle";
4
+ export { default as ConversationInboxItem } from "./ConversationInboxItem";
5
+ export { default as ConversationInboxList } from "./ConversationInboxList";
@@ -6,7 +6,7 @@ import { getHostLabel } from "../../../utils/link";
6
6
  import { openLink } from "../../../utils/openLink";
7
7
  import { useTranslation } from "react-i18next";
8
8
  const LinkInputPreview = ({ url, onRemove }) => {
9
- const { t } = useTranslation("biz-inbox");
9
+ const { t } = useTranslation("conversation-inbox");
10
10
  const { data, isLoading, isError } = useFetchUrlMetadata(url);
11
11
  const handleOpen = () => {
12
12
  openLink(url, t);
@@ -17,7 +17,7 @@ const ImageMessageItem = (props) => {
17
17
  snapshotHeight: (_k = pictureElem === null || pictureElem === void 0 ? void 0 : pictureElem.snapshotPicture) === null || _k === void 0 ? void 0 : _k.height,
18
18
  });
19
19
  const isSending = message.status === MessageStatus.Sending;
20
- return (_jsx(Spin, { spinning: isSending, children: _jsx("div", { className: "relative max-w-[200px]", style: minStyle, children: _jsx(Image, { src: sourceUrl, width: minStyle.width, className: "cursor-pointer rounded-xl object-contain", preview: {
20
+ return (_jsx(Spin, { spinning: isSending, children: _jsx("div", { className: "relative flex max-w-[200px] overflow-hidden rounded-xl", style: minStyle, children: _jsx(Image, { src: sourceUrl, width: minStyle.width, className: "block cursor-pointer rounded-xl object-cover", preview: {
21
21
  src: bigUrl,
22
22
  toolbarRender: (originalNode, info) => { var _a; return renderImagePreviewToolbar(originalNode, (_a = info === null || info === void 0 ? void 0 : info.image) === null || _a === void 0 ? void 0 : _a.url, t); },
23
23
  }, placeholder: _jsx("div", { className: "flex items-center justify-center rounded-xl bg-black/10", style: minStyle, children: _jsx(Spin, {}) }) }) }) }));
@@ -4,7 +4,7 @@ import { useTranslation } from "react-i18next";
4
4
  import { getHostLabel } from "../../../utils/link";
5
5
  import { openLink } from "../../../utils/openLink";
6
6
  const LinkCard = ({ metadata, url }) => {
7
- const { t } = useTranslation("biz-inbox");
7
+ const { t } = useTranslation("conversation-inbox");
8
8
  const { title, description, image } = metadata;
9
9
  if (!title && !description && !image) {
10
10
  return null;
@@ -6,7 +6,7 @@ import { parseTextWithLinks } from "../../../utils/link";
6
6
  import { openLink } from "../../../utils/openLink";
7
7
  import { MESSAGE_TEXT_CLASS } from "./textStyle";
8
8
  const LinkText = ({ text }) => {
9
- const { t } = useTranslation("biz-inbox");
9
+ const { t } = useTranslation("conversation-inbox");
10
10
  const segments = parseTextWithLinks(text);
11
11
  return (_jsx("span", { className: clsx("min-w-0 whitespace-pre-wrap text-left [overflow-wrap:anywhere]", MESSAGE_TEXT_CLASS), children: segments.map((segment, index) => segment.type === "link" ? (_jsx("button", { type: "button", onClick: () => openLink(segment.url, t), className: "inline text-left font-medium text-primary-400 underline-offset-2 hover:underline", children: segment.value }, `${segment.url}-${index}`)) : (_jsx("span", { children: segment.value }, `text-${index}`))) }));
12
12
  };
@@ -13,6 +13,6 @@ const VideoMessageItem = (props) => {
13
13
  snapshotHeight: videoElem === null || videoElem === void 0 ? void 0 : videoElem.snapshotHeight,
14
14
  });
15
15
  const isSending = message.status === MessageStatus.Sending;
16
- return (_jsx(Spin, { spinning: isSending, children: _jsx("div", { className: "relative max-w-[200px]", style: minStyle, children: _jsx("video", { src: videoUrl, poster: posterUrl, controls: true, className: "rounded-xl object-cover", style: { width: minStyle.width } }) }) }));
16
+ return (_jsx(Spin, { spinning: isSending, children: _jsx("div", { className: "relative max-w-[200px] overflow-hidden rounded-xl", style: minStyle, children: _jsx("video", { src: videoUrl, poster: posterUrl, controls: true, className: "block rounded-xl object-cover", style: { width: minStyle.width } }) }) }));
17
17
  };
18
18
  export default VideoMessageItem;
@@ -3,12 +3,13 @@ interface MessageItemProps {
3
3
  message: MessageItemType;
4
4
  allMessages: MessageItemType[];
5
5
  isGroupChat?: boolean;
6
+ forceHideTip?: boolean;
6
7
  contextMenuOpen?: boolean;
7
8
  onContextMenuOpenChange?: (open: boolean) => void;
8
9
  onRevokeMessage?: (clientMsgID: string) => void;
9
10
  onQuoteMessage?: (message: MessageItemType) => void;
10
11
  onPressQuoteMessage?: (clientMsgID: string) => void;
11
12
  }
12
- declare const MessageItem: ({ message, allMessages, isGroupChat, contextMenuOpen, onContextMenuOpenChange, onRevokeMessage, onQuoteMessage, onPressQuoteMessage, }: MessageItemProps) => import("react/jsx-runtime").JSX.Element | null;
13
+ declare const MessageItem: ({ message, allMessages, isGroupChat, forceHideTip, contextMenuOpen, onContextMenuOpenChange, onRevokeMessage, onQuoteMessage, onPressQuoteMessage, }: MessageItemProps) => import("react/jsx-runtime").JSX.Element | null;
13
14
  export default MessageItem;
14
15
  //# sourceMappingURL=index.d.ts.map
@@ -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;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"}
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;AA6BjC,UAAU,gBAAgB;IACxB,OAAO,EAAE,eAAe,CAAC;IACzB,WAAW,EAAE,eAAe,EAAE,CAAC;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,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,sJAUlB,gBAAgB,mDA+QlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -25,10 +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";
30
28
  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" }) }));
31
- const MessageItem = ({ message, allMessages, isGroupChat = false, contextMenuOpen, onContextMenuOpenChange, onRevokeMessage, onQuoteMessage, onPressQuoteMessage, }) => {
29
+ const MessageItem = ({ message, allMessages, isGroupChat = false, forceHideTip = false, contextMenuOpen, onContextMenuOpenChange, onRevokeMessage, onQuoteMessage, onPressQuoteMessage, }) => {
32
30
  var _a;
33
31
  const { t } = useTranslation();
34
32
  const { resendMessage } = useSendMessage();
@@ -54,8 +52,6 @@ const MessageItem = ({ message, allMessages, isGroupChat = false, contextMenuOpe
54
52
  return _jsx(SystemLogMessageItem, { message: item });
55
53
  case MessageType.RevokeMessage:
56
54
  return _jsx(RevokeMessageItem, {});
57
- case BOT_BUTTONS_MESSAGE_TYPE:
58
- return _jsx(BotButtonMessage, {});
59
55
  default:
60
56
  return _jsx(TextMessageItem, { message: item });
61
57
  }
@@ -73,7 +69,6 @@ const MessageItem = ({ message, allMessages, isGroupChat = false, contextMenuOpe
73
69
  }, [userID, message]);
74
70
  const contextMenuItems = useMemo(() => {
75
71
  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 ||
77
72
  isSystemLogMessageType(message === null || message === void 0 ? void 0 : message.contentType)) {
78
73
  return [];
79
74
  }
@@ -132,7 +127,7 @@ const MessageItem = ({ message, allMessages, isGroupChat = false, contextMenuOpe
132
127
  const showPeerInfo = isGroupChat || showSenderInfo;
133
128
  const showAvatar = showPeerInfo && !isMine && !nextSameUser;
134
129
  const showSenderName = showPeerInfo && !isMine && !prevSameUser;
135
- const showTip = !nextSameUser;
130
+ const showTip = forceHideTip ? false : !nextSameUser;
136
131
  if (!isCrm && isInternalMessage) {
137
132
  return null;
138
133
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mediaSize.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/mediaSize.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,2BAA2B;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,uBAAuB,GAAI,8CAIrC,2BAA2B;;;;CAoB7B,CAAC;AAEF,eAAO,MAAM,uBAAuB,iDAtBjC,2BAA2B;;;;CAsBgC,CAAC"}
1
+ {"version":3,"file":"mediaSize.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/mediaSize.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,2BAA2B;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,uBAAuB,GAAI,8CAIrC,2BAA2B;;;;CAmB7B,CAAC;AAEF,eAAO,MAAM,uBAAuB,iDArBjC,2BAA2B;;;;CAqBgC,CAAC"}
@@ -2,19 +2,19 @@ const IMAGE_MAX_WIDTH = 200;
2
2
  export const getImageMessageMinStyle = ({ imageWidth, imageHeight, snapshotHeight, }) => {
3
3
  if (!imageWidth || !imageHeight || imageWidth <= 0 || imageHeight <= 0) {
4
4
  return {
5
- minHeight: "210px",
6
- minWidth: "210px",
5
+ minHeight: `${IMAGE_MAX_WIDTH}px`,
6
+ minWidth: `${IMAGE_MAX_WIDTH}px`,
7
7
  width: IMAGE_MAX_WIDTH,
8
8
  };
9
9
  }
10
10
  const snapshotMaxHeight = snapshotHeight !== null && snapshotHeight !== void 0 ? snapshotHeight : imageHeight;
11
- const minHeight = Math.min(IMAGE_MAX_WIDTH, imageWidth) * (imageHeight / imageWidth) + 2;
12
- const adaptedHeight = Math.min(minHeight, snapshotMaxHeight) + 10;
13
- const adaptedWidth = Math.min(imageWidth, IMAGE_MAX_WIDTH) + 10;
11
+ const displayWidth = Math.min(imageWidth, IMAGE_MAX_WIDTH);
12
+ const aspectHeight = displayWidth * (imageHeight / imageWidth);
13
+ const displayHeight = Math.min(aspectHeight, snapshotMaxHeight);
14
14
  return {
15
- minHeight: `${adaptedHeight}px`,
16
- minWidth: `${adaptedWidth}px`,
17
- width: Math.min(imageWidth, IMAGE_MAX_WIDTH),
15
+ minHeight: `${displayHeight}px`,
16
+ minWidth: `${displayWidth}px`,
17
+ width: displayWidth,
18
18
  };
19
19
  };
20
20
  export const getVideoMessageMinStyle = getImageMessageMinStyle;
@@ -1,8 +1,3 @@
1
- import { MessageItem, MessageType } from "@openim/wasm-client-sdk";
2
1
  export declare const BOT_DEFAULT_BUTTON_ID = "default-item-button";
3
2
  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
3
  //# sourceMappingURL=botFlow.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"botFlow.d.ts","sourceRoot":"","sources":["../../src/constants/botFlow.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,wBAAwB,CAAC;AAE3D,eAAO,MAAM,yBAAyB,IAAI,CAAC"}
@@ -1,13 +1,2 @@
1
- import { MessageStatus, } from "@openim/wasm-client-sdk";
2
1
  export const BOT_DEFAULT_BUTTON_ID = "default-item-button";
3
2
  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,9 @@
1
+ export interface MoreOptionConfig {
2
+ icon: string;
3
+ labelKey: string;
4
+ enabled: boolean;
5
+ }
6
+ export declare const DEFAULT_MORE_OPTIONS: MoreOptionConfig[];
7
+ export declare function createMoreOptions(extraOptions?: MoreOptionConfig[]): MoreOptionConfig[];
8
+ export declare const MORE_OPTIONS: MoreOptionConfig[];
9
+ //# sourceMappingURL=moreOption.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moreOption.d.ts","sourceRoot":"","sources":["../../src/constants/moreOption.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,eAAO,MAAM,oBAAoB,EAAE,gBAAgB,EAgBlD,CAAC;AAEF,wBAAgB,iBAAiB,CAC/B,YAAY,GAAE,gBAAgB,EAAO,GACpC,gBAAgB,EAAE,CAEpB;AAED,eAAO,MAAM,YAAY,EAAE,gBAAgB,EAgBzC,CAAC"}
@@ -0,0 +1,37 @@
1
+ export const DEFAULT_MORE_OPTIONS = [
2
+ {
3
+ icon: "image-02-o",
4
+ labelKey: "thread_detail.more_option.media",
5
+ enabled: true,
6
+ },
7
+ {
8
+ icon: "camera-o",
9
+ labelKey: "thread_detail.more_option.camera",
10
+ enabled: false,
11
+ },
12
+ {
13
+ icon: "paperclip-o",
14
+ labelKey: "thread_detail.more_option.document",
15
+ enabled: true,
16
+ },
17
+ ];
18
+ export function createMoreOptions(extraOptions = []) {
19
+ return [...DEFAULT_MORE_OPTIONS, ...extraOptions];
20
+ }
21
+ export const MORE_OPTIONS = createMoreOptions([
22
+ {
23
+ icon: "receipt-o",
24
+ labelKey: "thread_detail.more_option.order",
25
+ enabled: false,
26
+ },
27
+ {
28
+ icon: "shopping-basket-o",
29
+ labelKey: "thread_detail.more_option.product",
30
+ enabled: false,
31
+ },
32
+ {
33
+ icon: "calendar-active-o",
34
+ labelKey: "thread_detail.more_option.appointment",
35
+ enabled: false,
36
+ },
37
+ ]);
@@ -1,12 +1,13 @@
1
1
  import { type BotInputButtonsBlock } from "../../types/biz";
2
- export type BotFlowStatus = "idle" | "not_started" | "running" | "waiting" | "ended";
2
+ export type BotFlowStatus = "running" | "not_started";
3
3
  interface UseBotFlowParams {
4
4
  conversationId: string;
5
5
  isBotThread: boolean;
6
6
  }
7
7
  export declare const useBotFlow: ({ conversationId, isBotThread, }: UseBotFlowParams) => {
8
- status: "running" | "not_started";
8
+ status: BotFlowStatus;
9
9
  isProcessing: boolean;
10
+ shouldShowButtons: boolean;
10
11
  currentButtonsBlock: BotInputButtonsBlock | null;
11
12
  start: () => Promise<void>;
12
13
  selectButton: (actionId: string) => Promise<void>;
@@ -1 +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"}
1
+ {"version":3,"file":"useBotFlow.d.ts","sourceRoot":"","sources":["../../../src/hooks/biz/useBotFlow.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,KAAK,oBAAoB,EAC1B,MAAM,aAAa,CAAC;AASrB,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,aAAa,CAAC;AAEtD,UAAU,gBAAgB;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;CACtB;AAoBD,eAAO,MAAM,UAAU,GAAI,kCAGxB,gBAAgB;;;;;;6BAoGqB,MAAM;;CAqC7C,CAAC"}
@@ -1,6 +1,9 @@
1
1
  "use client";
2
- import { useEffect, useState } from "react";
2
+ import { useEffect, useRef, useState } from "react";
3
3
  import { BotBlockType, BotFlowNodeType, } from "../../types/biz";
4
+ import { useSendMessage } from "../../hooks/message/useSendMessage";
5
+ import useAuthStore from "../../store/auth";
6
+ import emitter from "../../utils/events";
4
7
  import { useConversationDetail } from "./useConversationDetail";
5
8
  import { useRunBotFlow } from "./useRunBotFlow";
6
9
  import { useResetBotFlow } from "./useResetBotFlow";
@@ -8,16 +11,33 @@ const INITIAL_BOT_FLOW_STATE = {
8
11
  conversationId: "",
9
12
  flowCurrentStep: null,
10
13
  };
14
+ const parseMessageFlowGroupId = (ex) => {
15
+ var _a;
16
+ try {
17
+ return (_a = JSON.parse(ex || "{}").flow) === null || _a === void 0 ? void 0 : _a.groupId;
18
+ }
19
+ catch (_b) {
20
+ return undefined;
21
+ }
22
+ };
11
23
  export const useBotFlow = ({ conversationId, isBotThread, }) => {
12
24
  var _a;
13
25
  const [botFlowState, setBotFlowState] = useState(INITIAL_BOT_FLOW_STATE);
14
- const { conversationId: storedConversationId, flowCurrentStep, } = botFlowState;
26
+ const { conversationId: storedConversationId, flowCurrentStep } = botFlowState;
27
+ const [pendingGroupId, setPendingGroupId] = useState(null);
28
+ const latestBotFlowGroupIdRef = useRef(null);
29
+ const authUserID = useAuthStore((state) => state.userID);
15
30
  const detailQuery = useConversationDetail(conversationId, isBotThread);
16
31
  const runMutation = useRunBotFlow();
17
32
  const resetMutation = useResetBotFlow();
33
+ const { sendMergeMessage } = useSendMessage({
34
+ scrollEvent: "BIZ_CHAT_SCROLL_TO_BOTTOM_IF_AT_BOTTOM",
35
+ });
18
36
  useEffect(() => {
19
37
  if (!isBotThread) {
20
38
  setBotFlowState(INITIAL_BOT_FLOW_STATE);
39
+ setPendingGroupId(null);
40
+ latestBotFlowGroupIdRef.current = null;
21
41
  return;
22
42
  }
23
43
  if (detailQuery.data) {
@@ -25,13 +45,32 @@ export const useBotFlow = ({ conversationId, isBotThread, }) => {
25
45
  conversationId,
26
46
  flowCurrentStep: detailQuery.data.flowCurrentStep,
27
47
  });
48
+ setPendingGroupId(null);
49
+ latestBotFlowGroupIdRef.current = null;
28
50
  }
29
51
  }, [isBotThread, conversationId, detailQuery.data]);
52
+ useEffect(() => {
53
+ const handleNewMessage = (message) => {
54
+ if (message.sendID === authUserID)
55
+ return;
56
+ const groupId = parseMessageFlowGroupId(message.ex);
57
+ if (!groupId)
58
+ return;
59
+ latestBotFlowGroupIdRef.current = groupId;
60
+ setPendingGroupId((currentGroupId) => currentGroupId === groupId ? null : currentGroupId);
61
+ };
62
+ emitter.on("PUSH_NEW_MSG", handleNewMessage);
63
+ return () => {
64
+ emitter.off("PUSH_NEW_MSG", handleNewMessage);
65
+ };
66
+ }, [authUserID]);
30
67
  const activeStep = storedConversationId === conversationId ? flowCurrentStep : null;
31
68
  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
69
  const isProcessing = runMutation.isPending || resetMutation.isPending;
70
+ const shouldShowButtons = !!currentButtonsBlock && !isProcessing && !pendingGroupId;
33
71
  const status = (activeStep === null || activeStep === void 0 ? void 0 : activeStep.type) === BotFlowNodeType.Start ? "not_started" : "running";
34
72
  const runStep = async (step, actionId = null) => {
73
+ latestBotFlowGroupIdRef.current = null;
35
74
  const result = await runMutation.mutateAsync({
36
75
  conversationId,
37
76
  groupId: step.id,
@@ -42,6 +81,11 @@ export const useBotFlow = ({ conversationId, isBotThread, }) => {
42
81
  conversationId,
43
82
  flowCurrentStep: result.flowNextStep,
44
83
  });
84
+ const nextGroupId = result.flowNextStep.id;
85
+ setPendingGroupId(result.havingBotMessage &&
86
+ latestBotFlowGroupIdRef.current !== nextGroupId
87
+ ? nextGroupId
88
+ : null);
45
89
  };
46
90
  const start = async () => {
47
91
  if (!activeStep)
@@ -51,6 +95,20 @@ export const useBotFlow = ({ conversationId, isBotThread, }) => {
51
95
  const selectButton = async (actionId) => {
52
96
  if (!activeStep)
53
97
  return;
98
+ const flow = {
99
+ groupId: activeStep.id,
100
+ childId: null,
101
+ actionId,
102
+ };
103
+ const selectedButton = currentButtonsBlock === null || currentButtonsBlock === void 0 ? void 0 : currentButtonsBlock.data.buttons.find((button) => button.id === actionId);
104
+ if (selectedButton) {
105
+ await sendMergeMessage({
106
+ plainText: selectedButton.label,
107
+ richText: "",
108
+ isInternal: false,
109
+ flow,
110
+ });
111
+ }
54
112
  await runStep(activeStep, actionId);
55
113
  };
56
114
  const restart = async () => {
@@ -60,6 +118,7 @@ export const useBotFlow = ({ conversationId, isBotThread, }) => {
60
118
  return {
61
119
  status,
62
120
  isProcessing,
121
+ shouldShowButtons,
63
122
  currentButtonsBlock,
64
123
  start,
65
124
  selectButton,
@@ -1,5 +1,6 @@
1
- import type { RunBotFlowBody, RunBotFlowResponse } from "../../types/biz";
2
- export interface RunBotFlowParams extends RunBotFlowBody {
1
+ import type { BotFlowMeta } from "../../types/chat";
2
+ import type { RunBotFlowResponse } from "../../types/biz";
3
+ export interface RunBotFlowParams extends BotFlowMeta {
3
4
  conversationId: string;
4
5
  }
5
6
  export declare const useRunBotFlow: () => import("@tanstack/react-query").UseMutationResult<RunBotFlowResponse, Error, RunBotFlowParams, unknown>;
@@ -1 +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"}
1
+ {"version":3,"file":"useRunBotFlow.d.ts","sourceRoot":"","sources":["../../../src/hooks/biz/useRunBotFlow.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,aAAa,+GAgBzB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ConversationListItem } from "../../types/conversation";
2
+ export declare const useActiveConversation: (conversationItems: ConversationListItem[]) => void;
3
+ //# sourceMappingURL=useActiveConversation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useActiveConversation.d.ts","sourceRoot":"","sources":["../../../src/hooks/conversation/useActiveConversation.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,eAAO,MAAM,qBAAqB,GAChC,mBAAmB,oBAAoB,EAAE,SAuC1C,CAAC"}
@@ -0,0 +1,31 @@
1
+ "use client";
2
+ import { useEffect } from "react";
3
+ import { useSearchParams } from "next/navigation";
4
+ import useConversationStore from "../../store/conversation";
5
+ export const useActiveConversation = (conversationItems) => {
6
+ const searchParams = useSearchParams();
7
+ const threadId = searchParams.get("threadId");
8
+ const setSelectedConversationId = useConversationStore((state) => state.setSelectedConversationId);
9
+ const setConversationData = useConversationStore((state) => state.setConversationData);
10
+ const clearSelectedConversation = useConversationStore((state) => state.clearSelectedConversation);
11
+ useEffect(() => {
12
+ if (!threadId) {
13
+ clearSelectedConversation();
14
+ return;
15
+ }
16
+ setSelectedConversationId(threadId);
17
+ const matchedThread = conversationItems.find((item) => item.conversationID === threadId);
18
+ if (!matchedThread)
19
+ return;
20
+ const currentData = useConversationStore.getState().conversationData;
21
+ if ((currentData === null || currentData === void 0 ? void 0 : currentData.conversationID) !== threadId) {
22
+ setConversationData(matchedThread);
23
+ }
24
+ }, [
25
+ threadId,
26
+ conversationItems,
27
+ setSelectedConversationId,
28
+ setConversationData,
29
+ clearSelectedConversation,
30
+ ]);
31
+ };
@@ -0,0 +1,3 @@
1
+ import type { BotConversationDetail } from "../../types/conversation";
2
+ export declare const useBotConversationDetail: (conversationId: string, enabled: boolean) => import("@tanstack/react-query").UseQueryResult<BotConversationDetail, Error>;
3
+ //# sourceMappingURL=useBotConversationDetail.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBotConversationDetail.d.ts","sourceRoot":"","sources":["../../../src/hooks/conversation/useBotConversationDetail.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAElE,eAAO,MAAM,wBAAwB,GACnC,gBAAgB,MAAM,EACtB,SAAS,OAAO,iFAejB,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 useBotConversationDetail = (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,18 @@
1
+ import { type BotInputButtonsBlock } from "../../types/conversation";
2
+ export type BotFlowStatus = "running" | "not_started";
3
+ interface UseBotFlowParams {
4
+ conversationId: string;
5
+ isBotThread: boolean;
6
+ }
7
+ export declare const useBotFlow: ({ conversationId, isBotThread, }: UseBotFlowParams) => {
8
+ status: BotFlowStatus;
9
+ flowIsEnd: boolean;
10
+ isProcessing: boolean;
11
+ shouldShowButtons: boolean;
12
+ currentButtonsBlock: BotInputButtonsBlock | null;
13
+ start: () => Promise<void>;
14
+ selectButton: (actionId: string) => Promise<void>;
15
+ restart: () => Promise<void>;
16
+ };
17
+ export {};
18
+ //# sourceMappingURL=useBotFlow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBotFlow.d.ts","sourceRoot":"","sources":["../../../src/hooks/conversation/useBotFlow.ts"],"names":[],"mappings":"AAKA,OAAO,EAIL,KAAK,oBAAoB,EAC1B,MAAM,sBAAsB,CAAC;AAU9B,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,aAAa,CAAC;AAEtD,UAAU,gBAAgB;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;CACtB;AAsBD,eAAO,MAAM,UAAU,GAAI,kCAGxB,gBAAgB;;;;;;;6BA0GqB,MAAM;;CAiD7C,CAAC"}