@droppii-org/chat-mobile 0.2.29 → 0.2.30

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 (153) hide show
  1. package/lib/module/components/flows/inputButtons/index.js +6 -3
  2. package/lib/module/components/flows/inputButtons/index.js.map +1 -1
  3. package/lib/module/config/api-endpoints.js +2 -1
  4. package/lib/module/config/api-endpoints.js.map +1 -1
  5. package/lib/module/context/ChatDetailContext.js +35 -2
  6. package/lib/module/context/ChatDetailContext.js.map +1 -1
  7. package/lib/module/context/index.js +1 -0
  8. package/lib/module/context/index.js.map +1 -1
  9. package/lib/module/hooks/conversation/useGetConversationDetail.js +58 -0
  10. package/lib/module/hooks/conversation/useGetConversationDetail.js.map +1 -0
  11. package/lib/module/hooks/flows/useFlow.js +1 -1
  12. package/lib/module/hooks/flows/useFlow.js.map +1 -1
  13. package/lib/module/hooks/flows/useGetConversationFlowMainMenu.js +17 -0
  14. package/lib/module/hooks/flows/useGetConversationFlowMainMenu.js.map +1 -0
  15. package/lib/module/hooks/message/useSendMessage.js +32 -7
  16. package/lib/module/hooks/message/useSendMessage.js.map +1 -1
  17. package/lib/module/hooks/query-keys.js +4 -1
  18. package/lib/module/hooks/query-keys.js.map +1 -1
  19. package/lib/module/hooks/useChatCompose.js +0 -1
  20. package/lib/module/hooks/useChatCompose.js.map +1 -1
  21. package/lib/module/index.js +4 -2
  22. package/lib/module/index.js.map +1 -1
  23. package/lib/module/screens/chat-detail/ChatAttachmentPanel.js +4 -14
  24. package/lib/module/screens/chat-detail/ChatAttachmentPanel.js.map +1 -1
  25. package/lib/module/screens/chat-detail/ChatComposer.js +26 -15
  26. package/lib/module/screens/chat-detail/ChatComposer.js.map +1 -1
  27. package/lib/module/screens/chat-detail/ChatDetail.js +58 -71
  28. package/lib/module/screens/chat-detail/ChatDetail.js.map +1 -1
  29. package/lib/module/screens/chat-detail/ChatDetailHeader.js +7 -10
  30. package/lib/module/screens/chat-detail/ChatDetailHeader.js.map +1 -1
  31. package/lib/module/screens/chat-detail/ChatListLegend.js +1 -1
  32. package/lib/module/screens/chat-detail/ChatListLegend.js.map +1 -1
  33. package/lib/module/screens/chat-detail/ChatLoadEarlier.js.map +1 -1
  34. package/lib/module/screens/chat-detail/ChatQuickActions.js +2 -1
  35. package/lib/module/screens/chat-detail/ChatQuickActions.js.map +1 -1
  36. package/lib/module/screens/chat-detail/constants.js +30 -24
  37. package/lib/module/screens/chat-detail/constants.js.map +1 -1
  38. package/lib/module/screens/chat-detail/index.js +2 -2
  39. package/lib/module/screens/chat-detail/index.js.map +1 -1
  40. package/lib/module/screens/chat-detail/types.js +15 -1
  41. package/lib/module/screens/chat-detail/types.js.map +1 -1
  42. package/lib/module/services/attachmentHandlers/imageAttachmentHandler.js +2 -2
  43. package/lib/module/services/attachmentHandlers/imageAttachmentHandler.js.map +1 -1
  44. package/lib/module/services/endpoints.js +3 -1
  45. package/lib/module/services/endpoints.js.map +1 -1
  46. package/lib/module/translation/resources/i18n.js +7 -1
  47. package/lib/module/translation/resources/i18n.js.map +1 -1
  48. package/lib/module/types/chat.js +9 -0
  49. package/lib/module/types/chat.js.map +1 -1
  50. package/lib/module/types/flows.js +5 -0
  51. package/lib/module/types/flows.js.map +1 -1
  52. package/lib/module/utils/flows.js +5 -0
  53. package/lib/module/utils/flows.js.map +1 -1
  54. package/lib/module/utils/imageUtils.js +0 -3
  55. package/lib/module/utils/imageUtils.js.map +1 -1
  56. package/lib/module/utils/messageUtils.js +5 -19
  57. package/lib/module/utils/messageUtils.js.map +1 -1
  58. package/lib/typescript/src/components/flows/inputButtons/index.d.ts.map +1 -1
  59. package/lib/typescript/src/config/api-endpoints.d.ts +1 -0
  60. package/lib/typescript/src/config/api-endpoints.d.ts.map +1 -1
  61. package/lib/typescript/src/context/ChatDetailContext.d.ts +1 -1
  62. package/lib/typescript/src/context/ChatDetailContext.d.ts.map +1 -1
  63. package/lib/typescript/src/context/index.d.ts +1 -0
  64. package/lib/typescript/src/context/index.d.ts.map +1 -1
  65. package/lib/typescript/src/hooks/conversation/useGetConversationDetail.d.ts +17 -0
  66. package/lib/typescript/src/hooks/conversation/useGetConversationDetail.d.ts.map +1 -0
  67. package/lib/typescript/src/hooks/flows/useGetConversationFlowMainMenu.d.ts +3 -0
  68. package/lib/typescript/src/hooks/flows/useGetConversationFlowMainMenu.d.ts.map +1 -0
  69. package/lib/typescript/src/hooks/message/useSendMessage.d.ts +5 -4
  70. package/lib/typescript/src/hooks/message/useSendMessage.d.ts.map +1 -1
  71. package/lib/typescript/src/hooks/query-keys.d.ts +3 -0
  72. package/lib/typescript/src/hooks/query-keys.d.ts.map +1 -1
  73. package/lib/typescript/src/index.d.ts +6 -4
  74. package/lib/typescript/src/index.d.ts.map +1 -1
  75. package/lib/typescript/src/screens/chat-detail/ChatAttachmentPanel.d.ts +2 -2
  76. package/lib/typescript/src/screens/chat-detail/ChatAttachmentPanel.d.ts.map +1 -1
  77. package/lib/typescript/src/screens/chat-detail/ChatComposer.d.ts +3 -1
  78. package/lib/typescript/src/screens/chat-detail/ChatComposer.d.ts.map +1 -1
  79. package/lib/typescript/src/screens/chat-detail/ChatDetail.d.ts +1 -1
  80. package/lib/typescript/src/screens/chat-detail/ChatDetail.d.ts.map +1 -1
  81. package/lib/typescript/src/screens/chat-detail/ChatDetailHeader.d.ts +1 -1
  82. package/lib/typescript/src/screens/chat-detail/ChatDetailHeader.d.ts.map +1 -1
  83. package/lib/typescript/src/screens/chat-detail/ChatLoadEarlier.d.ts +3 -2
  84. package/lib/typescript/src/screens/chat-detail/ChatLoadEarlier.d.ts.map +1 -1
  85. package/lib/typescript/src/screens/chat-detail/ChatQuickActions.d.ts +1 -1
  86. package/lib/typescript/src/screens/chat-detail/ChatQuickActions.d.ts.map +1 -1
  87. package/lib/typescript/src/screens/chat-detail/constants.d.ts +3 -3
  88. package/lib/typescript/src/screens/chat-detail/constants.d.ts.map +1 -1
  89. package/lib/typescript/src/screens/chat-detail/index.d.ts +3 -3
  90. package/lib/typescript/src/screens/chat-detail/index.d.ts.map +1 -1
  91. package/lib/typescript/src/screens/chat-detail/types.d.ts +28 -19
  92. package/lib/typescript/src/screens/chat-detail/types.d.ts.map +1 -1
  93. package/lib/typescript/src/services/endpoints.d.ts +2 -0
  94. package/lib/typescript/src/services/endpoints.d.ts.map +1 -1
  95. package/lib/typescript/src/store/conversation.d.ts +1 -1
  96. package/lib/typescript/src/store/conversation.d.ts.map +1 -1
  97. package/lib/typescript/src/translation/resources/i18n.d.ts.map +1 -1
  98. package/lib/typescript/src/types/chat.d.ts +26 -2
  99. package/lib/typescript/src/types/chat.d.ts.map +1 -1
  100. package/lib/typescript/src/types/flows.d.ts +3 -0
  101. package/lib/typescript/src/types/flows.d.ts.map +1 -1
  102. package/lib/typescript/src/utils/flows.d.ts +2 -0
  103. package/lib/typescript/src/utils/flows.d.ts.map +1 -1
  104. package/lib/typescript/src/utils/imageUtils.d.ts +0 -1
  105. package/lib/typescript/src/utils/imageUtils.d.ts.map +1 -1
  106. package/lib/typescript/src/utils/messageUtils.d.ts +1 -1
  107. package/lib/typescript/src/utils/messageUtils.d.ts.map +1 -1
  108. package/package.json +3 -5
  109. package/src/components/flows/inputButtons/index.tsx +11 -3
  110. package/src/config/api-endpoints.ts +2 -0
  111. package/src/context/ChatDetailContext.tsx +57 -4
  112. package/src/context/index.ts +1 -0
  113. package/src/hooks/conversation/useGetConversationDetail.ts +78 -0
  114. package/src/hooks/flows/useFlow.ts +1 -1
  115. package/src/hooks/flows/useGetConversationFlowMainMenu.ts +19 -0
  116. package/src/hooks/message/useSendMessage.ts +43 -14
  117. package/src/hooks/query-keys.ts +6 -0
  118. package/src/hooks/useChatCompose.ts +1 -1
  119. package/src/index.tsx +15 -6
  120. package/src/screens/chat-detail/ChatAttachmentPanel.tsx +8 -25
  121. package/src/screens/chat-detail/ChatComposer.tsx +26 -21
  122. package/src/screens/chat-detail/ChatDetail.tsx +61 -77
  123. package/src/screens/chat-detail/ChatDetailHeader.tsx +7 -18
  124. package/src/screens/chat-detail/ChatListLegend.tsx +1 -1
  125. package/src/screens/chat-detail/ChatLoadEarlier.tsx +1 -2
  126. package/src/screens/chat-detail/ChatQuickActions.tsx +6 -2
  127. package/src/screens/chat-detail/constants.ts +33 -27
  128. package/src/screens/chat-detail/index.ts +5 -8
  129. package/src/screens/chat-detail/types.ts +30 -28
  130. package/src/services/attachmentHandlers/imageAttachmentHandler.ts +2 -2
  131. package/src/services/endpoints.ts +4 -0
  132. package/src/store/conversation.ts +1 -1
  133. package/src/translation/resources/i18n.ts +6 -0
  134. package/src/types/chat.ts +31 -1
  135. package/src/types/flows.ts +4 -0
  136. package/src/utils/flows.ts +7 -0
  137. package/src/utils/imageUtils.ts +0 -4
  138. package/src/utils/messageUtils.ts +7 -22
  139. package/lib/module/screens/chat-detail/ChatDay.js +0 -65
  140. package/lib/module/screens/chat-detail/ChatDay.js.map +0 -1
  141. package/lib/module/types/message.js +0 -17
  142. package/lib/module/types/message.js.map +0 -1
  143. package/lib/module/utils/resolveMessageType.js +0 -47
  144. package/lib/module/utils/resolveMessageType.js.map +0 -1
  145. package/lib/typescript/src/screens/chat-detail/ChatDay.d.ts +0 -3
  146. package/lib/typescript/src/screens/chat-detail/ChatDay.d.ts.map +0 -1
  147. package/lib/typescript/src/types/message.d.ts +0 -16
  148. package/lib/typescript/src/types/message.d.ts.map +0 -1
  149. package/lib/typescript/src/utils/resolveMessageType.d.ts +0 -4
  150. package/lib/typescript/src/utils/resolveMessageType.d.ts.map +0 -1
  151. package/src/screens/chat-detail/ChatDay.tsx +0 -73
  152. package/src/types/message.ts +0 -18
  153. package/src/utils/resolveMessageType.ts +0 -51
@@ -10,13 +10,10 @@ import { AvatarSection } from '../../components/ThreadCard/AvatarSection';
10
10
  import { NamePrefixIcon } from '../../components/ThreadCard/NamePrefixIcon';
11
11
  import type { ChatDetailHeaderProps } from './types';
12
12
  import { useConversation } from '../../store';
13
+ import { getConversationSubtitle } from './conversationHeader.utils';
13
14
 
14
15
  const ChatDetailHeader = memo(
15
16
  ({
16
- title,
17
- subtitle,
18
- avatarUri,
19
- avatarFullName,
20
17
  showAddMember = false,
21
18
  conversationId,
22
19
  onBack,
@@ -79,8 +76,8 @@ const ChatDetailHeader = memo(
79
76
  activeOpacity={0.7}
80
77
  >
81
78
  <AvatarSection
82
- avatar={avatarUri ?? null}
83
- fullName={avatarFullName ?? title}
79
+ avatar={conversation?.faceURL ?? null}
80
+ fullName={conversation?.showName || ''}
84
81
  peerType={conversation?.peerType}
85
82
  />
86
83
 
@@ -93,31 +90,23 @@ const ChatDetailHeader = memo(
93
90
  numberOfLines={1}
94
91
  flex
95
92
  >
96
- {title}
93
+ {conversation?.showName || ''}
97
94
  </KLabel.Text>
98
95
  </KContainer.View>
99
- {!!subtitle && (
96
+ {!!conversation && (
100
97
  <KLabel.Text
101
98
  typo="TextSmNormal"
102
99
  color={KColors.palette.gray.w500}
103
100
  numberOfLines={1}
104
101
  >
105
- {subtitle}
102
+ {getConversationSubtitle(conversation)}
106
103
  </KLabel.Text>
107
104
  )}
108
105
  </KContainer.View>
109
106
  </KContainer.Touchable>
110
107
  </KContainer.View>
111
108
  ),
112
- [
113
- avatarFullName,
114
- avatarUri,
115
- onBack,
116
- onPressAvatar,
117
- subtitle,
118
- title,
119
- conversation?.peerType,
120
- ]
109
+ [onBack, onPressAvatar, conversation]
121
110
  );
122
111
 
123
112
  return (
@@ -374,7 +374,7 @@ export const ChatListLegend = memo(
374
374
  renderItem={renderItem}
375
375
  estimatedItemSize={avgItemHeightRef.current}
376
376
  keyExtractor={(item) => String(item.clientMsgID || item.serverMsgID)}
377
- recycleItems={true}
377
+ recycleItems={false}
378
378
  extraData={`${conversationFlow?.flowCurrentStep?.id ?? ''}-${lastMessageId ?? ''}`}
379
379
  alignItemsAtEnd
380
380
  maintainVisibleContentPosition={maintainVisiblePositionConfig}
@@ -1,10 +1,9 @@
1
1
  import { memo } from 'react';
2
2
  import { ActivityIndicator } from 'react-native';
3
3
  import { KContainer, KColors } from '@droppii/libs';
4
- import type { LoadEarlierMessagesProps } from 'react-native-gifted-chat';
5
4
 
6
5
  export const ChatLoadEarlier = memo(
7
- ({ isLoading = false }: LoadEarlierMessagesProps) => {
6
+ ({ isLoading = false }: { isLoading: boolean }) => {
8
7
  if (!isLoading) {
9
8
  return null;
10
9
  }
@@ -8,7 +8,11 @@ import {
8
8
  KSpacingValue,
9
9
  } from '@droppii/libs';
10
10
  import { useChatActionPress } from './useChatActionPress';
11
- import type { DChatQuickAction, ChatQuickActionsProps } from './types';
11
+ import {
12
+ type DChatQuickAction,
13
+ type ChatQuickActionsProps,
14
+ DChatQuickActionItemType,
15
+ } from './types';
12
16
  import { useResetFlow } from '../../hooks/flows/useFlow';
13
17
 
14
18
  const QuickActionItem = memo(
@@ -76,7 +80,7 @@ export const ChatQuickActions = memo(
76
80
  ({ item }) => {
77
81
  const onPress = () => {
78
82
  handleActionPress(item);
79
- if (item.id === 'restart') {
83
+ if (item.id === DChatQuickActionItemType.Restart) {
80
84
  resetFlow?.();
81
85
  }
82
86
  };
@@ -1,5 +1,11 @@
1
1
  import { KColors } from '@droppii/libs';
2
- import type { DChatQuickAction, DChatAttachmentAction } from './types';
2
+ import {
3
+ type DChatQuickAction,
4
+ type DChatPannelAction,
5
+ DChatQuickActionItemType,
6
+ DChatPannelActionItemType,
7
+ } from './types';
8
+ import { trans } from '../../translation';
3
9
  import { opacityToSolid } from '../../utils/ui';
4
10
 
5
11
  export const CHAT_BUBBLE_COLORS = {
@@ -10,19 +16,19 @@ export const CHAT_BUBBLE_COLORS = {
10
16
  dayLabel: KColors.gray.light,
11
17
  } as const;
12
18
 
13
- export const DEFAULT_Chat_QUICK_ACTIONS: DChatQuickAction[] = [
19
+ export const DEFAULT_QUICK_ACTIONS: DChatQuickAction[] = [
14
20
  {
15
- id: 'restart',
21
+ id: DChatQuickActionItemType.Restart,
16
22
  label: 'Bắt đầu lại',
17
23
  iconName: 'refresh',
18
24
  },
19
25
  {
20
- id: 'send-order',
26
+ id: DChatQuickActionItemType.SendOrder,
21
27
  label: 'Gửi đơn hàng',
22
28
  iconName: 'file-document-outline',
23
29
  },
24
30
  {
25
- id: 'scam-warning',
31
+ id: DChatQuickActionItemType.ScamWarning,
26
32
  label: 'Cảnh báo lừa đảo/g...',
27
33
  iconName: 'alert-outline',
28
34
  },
@@ -43,35 +49,35 @@ export const getAttachmentPanelHeight = (
43
49
  /** @deprecated use getAttachmentPanelHeight */
44
50
  export const DEFAULT_ATTACHMENT_PANEL_HEIGHT = getAttachmentPanelHeight(6);
45
51
 
46
- export const DEFAULT_ATTACHMENT_ACTIONS: DChatAttachmentAction[] = [
52
+ export const DEFAULT_PANNEL_ACTIONS: DChatPannelAction[] = [
47
53
  {
48
- id: 'gallery',
49
- label: 'Ảnh/Video',
54
+ id: DChatPannelActionItemType.Gallery,
55
+ label: trans('gallery'),
50
56
  iconName: 'image-02-o',
51
57
  },
52
58
  {
53
- id: 'camera',
54
- label: 'Chụp ảnh',
59
+ id: DChatPannelActionItemType.Camera,
60
+ label: trans('camera'),
55
61
  iconName: 'camera-o',
56
62
  },
57
63
  {
58
- id: 'file',
59
- label: 'Tài liệu',
64
+ id: DChatPannelActionItemType.Documents,
65
+ label: trans('documents'),
60
66
  iconName: 'paperclip-o',
61
67
  },
62
- {
63
- id: 'order',
64
- label: 'Gửi đơn hàng',
65
- iconName: 'receipt-o',
66
- },
67
- {
68
- id: 'product',
69
- label: 'Gửi sản phẩm',
70
- iconName: 'shopping-basket-o',
71
- },
72
- {
73
- id: 'calendar',
74
- label: 'Tạo lịch hẹn',
75
- iconName: 'calendar-active-o',
76
- },
68
+ // {
69
+ // id: DChatPannelActionItemType.SendOrder,
70
+ // label: trans('send_order'),
71
+ // iconName: 'receipt-o',
72
+ // },
73
+ // {
74
+ // id: DChatPannelActionItemType.SendProduct,
75
+ // label: trans('send_product'),
76
+ // iconName: 'shopping-basket-o',
77
+ // },
78
+ // {
79
+ // id: DChatPannelActionItemType.CreateAppointment,
80
+ // label: trans('create_appointment'),
81
+ // iconName: 'calendar-active-o',
82
+ // },
77
83
  ];
@@ -4,8 +4,8 @@ export { ChatComposer } from './ChatComposer';
4
4
  export { ChatQuickActions } from './ChatQuickActions';
5
5
  export { ChatAttachmentPanel } from './ChatAttachmentPanel';
6
6
  export {
7
- DEFAULT_Chat_QUICK_ACTIONS,
8
- DEFAULT_ATTACHMENT_ACTIONS,
7
+ DEFAULT_QUICK_ACTIONS,
8
+ DEFAULT_PANNEL_ACTIONS,
9
9
  DEFAULT_ATTACHMENT_PANEL_HEIGHT,
10
10
  } from './constants';
11
11
  export {
@@ -18,17 +18,14 @@ export type {
18
18
  DChatActionItem,
19
19
  DChatActionIconProvider,
20
20
  DChatQuickAction,
21
- DChatAttachmentAction,
21
+ DChatPannelAction,
22
22
  ChatDetailProps,
23
23
  ChatDetailHeaderProps,
24
24
  ChatListProps,
25
25
  ChatComposerProps,
26
26
  ChatQuickActionsProps,
27
27
  ChatQuickActionsRenderParams,
28
- ChatAttachmentPanelProps,
28
+ ChatPanelProps,
29
29
  } from './types';
30
30
 
31
- export {
32
- DChatMessageType,
33
- CUSTOM_MESSAGE_DATA_TYPE,
34
- } from '../../types/message';
31
+ export { DChatPannelActionItemType, DChatQuickActionItemType } from './types';
@@ -1,13 +1,27 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import type { MediaItem } from '../../hooks/useMediaViewer';
3
3
  import type { DMessageItem } from '../../types/chat';
4
- import type { ConversationItem } from '@droppii/openim-rn-client-sdk';
5
4
  import type { MeasuredRect } from './messageToolbox/types';
6
5
 
7
6
  export type DChatActionIconProvider = 'MaterialCommunityIcons' | 'DroppiiNew';
8
7
 
8
+ export enum DChatPannelActionItemType {
9
+ Gallery = 'Gallery',
10
+ Camera = 'Camera',
11
+ Documents = 'Documents',
12
+ SendOrder = 'SendOrder',
13
+ SendProduct = 'SendProduct',
14
+ CreateAppointment = 'CreateAppointment',
15
+ }
16
+
17
+ export enum DChatQuickActionItemType {
18
+ Restart = 'Restart',
19
+ SendOrder = 'SendOrder',
20
+ ScamWarning = 'ScamWarning',
21
+ }
22
+
9
23
  export interface DChatActionItem {
10
- id: string;
24
+ id: DChatQuickActionItemType | DChatPannelActionItemType;
11
25
  label: string;
12
26
  iconName: string;
13
27
  iconProvider?: DChatActionIconProvider;
@@ -16,14 +30,14 @@ export interface DChatActionItem {
16
30
  meta?: Record<string, unknown>;
17
31
  }
18
32
 
19
- export type DChatQuickAction = DChatActionItem;
20
- export type DChatAttachmentAction = DChatActionItem;
33
+ export interface DChatQuickAction extends DChatActionItem {
34
+ id: DChatQuickActionItemType;
35
+ }
36
+ export interface DChatPannelAction extends DChatActionItem {
37
+ id: DChatPannelActionItemType;
38
+ }
21
39
 
22
40
  export interface ChatDetailHeaderProps {
23
- title: string;
24
- subtitle?: string;
25
- avatarUri?: string | null;
26
- avatarFullName?: string;
27
41
  showAddMember?: boolean;
28
42
  onBack?: () => void;
29
43
  onPressSearch?: () => void;
@@ -46,14 +60,9 @@ export interface ChatQuickActionsProps {
46
60
  renderQuickActions?: (params: ChatQuickActionsRenderParams) => ReactNode;
47
61
  }
48
62
 
49
- export interface ChatAttachmentPanelProps {
50
- actions?: DChatAttachmentAction[];
63
+ export interface ChatPanelProps {
64
+ actions?: DChatPannelAction[];
51
65
  columns?: number;
52
- onActionPress?: (action: DChatAttachmentAction) => void;
53
- renderAction?: (
54
- action: DChatAttachmentAction,
55
- onPress: () => void
56
- ) => ReactNode;
57
66
  }
58
67
 
59
68
  export interface ChatComposerProps {
@@ -78,22 +87,15 @@ export interface ChatListProps {
78
87
 
79
88
  export interface ChatDetailProps extends Omit<
80
89
  ChatDetailHeaderProps,
81
- | 'title'
82
- | 'subtitle'
83
- | 'avatarUri'
84
- | 'avatarFullName'
85
- | 'applicationType'
86
- | 'showAddMember'
87
- | 'conversationId'
90
+ 'showAddMember' | 'conversationId'
88
91
  > {
89
- conversationId: string;
92
+ targetConversationId?: string;
93
+ targetUserId?: string;
94
+ targetGroupId?: string;
95
+ targetBotId?: string;
90
96
  enabled?: boolean;
91
- title?: string;
92
- subtitle?: string;
93
- avatarUri?: string | null;
94
- avatarFullName?: string;
95
97
  showAddMember?: boolean;
96
- getSubtitle?: (conversation: ConversationItem) => string | undefined;
97
98
  onPressUrl?: (url: string) => void;
98
99
  customMessageItemFactory?: (item: DMessageItem) => ReactNode;
100
+ pannelActions?: DChatPannelAction[];
99
101
  }
@@ -1,7 +1,7 @@
1
1
  import type { ImageAttachment } from '../../types/attachment';
2
2
  import type { IAttachmentHandler } from '../../types/attachmentHandler';
3
- import { generateUUID } from '../../utils/imageUtils';
4
3
  import { UPLOAD_LIMITS } from '../../config/uploadLimits';
4
+ import uuid from 'react-native-uuid';
5
5
 
6
6
  export const ImageAttachmentHandler: IAttachmentHandler = {
7
7
  validate(attachment: ImageAttachment) {
@@ -42,7 +42,7 @@ export const ImageAttachmentHandler: IAttachmentHandler = {
42
42
  });
43
43
 
44
44
  const picInfo = {
45
- uuid: generateUUID(),
45
+ uuid: uuid.v4(),
46
46
  type: attachment.sourceFile.mimeType,
47
47
  size: attachment.sourceFile.size,
48
48
  width: attachment.metadata.width,
@@ -22,6 +22,10 @@ export const ENDPOINTS = {
22
22
  `${getApiEndpoint('conversationFlow')}/${id}/bot-flows/reset`,
23
23
  runConversationFlow: (id: string) =>
24
24
  `${getApiEndpoint('conversationFlow')}/${id}/bot-flows/run`,
25
+ getConversationByBotId: (botId: string) =>
26
+ `${getApiEndpoint('bot')}/${botId}/conversation`,
27
+ conversationFlowMainMenu: (id: string) =>
28
+ `${getApiEndpoint('conversationFlow')}/${id}/bot-flows/main-menu`,
25
29
  },
26
30
  uploaderService: {
27
31
  get uploadImage() {
@@ -6,7 +6,7 @@ type ConversationID = string;
6
6
 
7
7
  export interface ConversationStore {
8
8
  currentConversationId?: ConversationID;
9
- setCurrentConversation(id: ConversationID): void;
9
+ setCurrentConversation(id?: ConversationID): void;
10
10
  getCurrentConversation(): ConversationItem | undefined;
11
11
  list: ConversationID[];
12
12
  map: Record<ConversationID, ConversationItem>;
@@ -52,6 +52,12 @@ const i18nKey: Record<string, string> = {
52
52
  'chat:unmute_toast_success': 'Đã bật thông báo',
53
53
  'start': 'Bắt đầu',
54
54
  'restart': 'Bắt đầu lại',
55
+ 'gallery': 'Ảnh/Video',
56
+ 'camera': 'Chụp ảnh',
57
+ 'documents': 'Tài liệu',
58
+ 'send_order': 'Gửi đơn hàng',
59
+ 'send_product': 'Gửi sản phẩm',
60
+ 'create_appointment': 'Tạo lịch hẹn',
55
61
  };
56
62
 
57
63
  export default {
package/src/types/chat.ts CHANGED
@@ -1,7 +1,11 @@
1
- import { type MessageItem } from '@droppii/openim-rn-client-sdk';
1
+ import {
2
+ type ConversationItem,
3
+ type MessageItem,
4
+ } from '@droppii/openim-rn-client-sdk';
2
5
  import type { PropsWithChildren } from 'react';
3
6
  import type { IUrlMetadata } from './common';
4
7
  import type {
8
+ DFlowContext,
5
9
  IConversationFlow,
6
10
  IConversationFlowStep,
7
11
  IRunConversationFlowPayload,
@@ -55,6 +59,11 @@ export enum DMemberRole {
55
59
  MEMBER = 'MEMBER',
56
60
  }
57
61
 
62
+ export enum DFlowState {
63
+ BOT = 1,
64
+ CS = 2,
65
+ }
66
+
58
67
  export interface DConversationPeerUser {
59
68
  id: string;
60
69
  username?: string;
@@ -139,6 +148,9 @@ export interface ChatDetailContextType {
139
148
  refetchConversationFlow: () => void;
140
149
  isBotConversation: boolean;
141
150
  setConverationFlowStep: (step?: IConversationFlowStep) => void;
151
+ flowState?: DFlowState;
152
+ runButtonContext: (stringContext: DFlowContext) => Promise<boolean>;
153
+ conversation?: ConversationItem;
142
154
  }
143
155
 
144
156
  export interface ChatDetailProviderProps extends PropsWithChildren {}
@@ -154,3 +166,21 @@ export interface IConversationItemEx {
154
166
  };
155
167
  chatCategory: DChatCategory;
156
168
  }
169
+
170
+ export const CustomMessageType = {
171
+ Order: 'Order',
172
+ Product: 'Product',
173
+ } as const;
174
+
175
+ export type CustomMessageType =
176
+ (typeof CustomMessageType)[keyof typeof CustomMessageType];
177
+
178
+ export type CustomElemOrderData = {
179
+ id: string;
180
+ orderCode: string;
181
+ timestamp: number;
182
+ };
183
+
184
+ export type CustomMessagePayload =
185
+ | { type: typeof CustomMessageType.Order; data: CustomElemOrderData }
186
+ | { type: typeof CustomMessageType.Product; data: Record<string, unknown> };
@@ -1,6 +1,10 @@
1
1
  import type { PeerType } from '@droppii/openim-rn-client-sdk';
2
2
  import type { DChatApplicationType, DChatCategory } from './chat';
3
3
 
4
+ export enum DFlowContext {
5
+ CHAT_WITH_CS = 'chat_with_cs',
6
+ }
7
+
4
8
  /** START NODE TYPE */
5
9
  export const NodeTypes = {
6
10
  BubbleText: 'bubble-text',
@@ -16,3 +16,10 @@ export const getFlowInputButtonsNode = (
16
16
  };
17
17
 
18
18
  export const DEFAULT_BUTTON_ID = 'default-item-button';
19
+
20
+ export const CONTEXT_BUTTON_PREFIX = 'context:';
21
+
22
+ export const isContextButton = (label: string) => {
23
+ if (!label) return false;
24
+ return label?.trim?.()?.startsWith?.(CONTEXT_BUTTON_PREFIX) || false;
25
+ };
@@ -2,10 +2,6 @@ import type { ImageFile } from '../types/imageUpload';
2
2
  import Images from '../assets/images';
3
3
  import { UPLOAD_LIMITS } from '../config/uploadLimits';
4
4
 
5
- export const generateUUID = (): string => {
6
- return `${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
7
- };
8
-
9
5
  export const isVideoFile = (filename: string | undefined): boolean => {
10
6
  if (!filename) return false;
11
7
  const mimeType = getMimeType(filename);
@@ -7,8 +7,7 @@ import {
7
7
  PeerType,
8
8
  type ConversationItem,
9
9
  } from '@droppii/openim-rn-client-sdk';
10
- import type { DMessageItem } from '../types/chat';
11
- import { DChatMessageType } from '../types/message';
10
+ import { type DMessageItem } from '../types/chat';
12
11
  import { formatDuration } from './dateTimeUtils';
13
12
  import { trans } from '../translation';
14
13
 
@@ -26,26 +25,6 @@ export const extractTextContent = (message: DMessageItem): string => {
26
25
  };
27
26
 
28
27
  export const getMessagePreview = (message: DMessageItem): string => {
29
- // Check custom message type first
30
- if (message.contentType === MessageType.CustomMessage) {
31
- try {
32
- const data = JSON.parse(message.content);
33
- const dataType = data.dataType || data.type;
34
-
35
- if (dataType === DChatMessageType.Link) {
36
- const linkText = data.content || data.title || 'Link';
37
- return linkText;
38
- }
39
-
40
- if (dataType === DChatMessageType.Order) {
41
- const orderCode = data.orderCode || data.code || '';
42
- return `[Đơn hàng] ${orderCode}`;
43
- }
44
- } catch {
45
- // Fall through to default
46
- }
47
- }
48
-
49
28
  // Handle standard message types
50
29
  switch (message.contentType) {
51
30
  case MessageType.TextMessage:
@@ -103,6 +82,12 @@ export const getMessagePreview = (message: DMessageItem): string => {
103
82
  case MessageType.RevokeMessage:
104
83
  return trans('msg_type_revoke');
105
84
 
85
+ case MessageType.CustomMessage:
86
+ if (message?.customElem?.description) {
87
+ return message?.customElem?.description;
88
+ }
89
+ break;
90
+
106
91
  default:
107
92
  return '[Tin nhắn không được hỗ trợ]';
108
93
  }
@@ -1,65 +0,0 @@
1
- "use strict";
2
-
3
- import { memo, useMemo } from 'react';
4
- import { KContainer, KLabel } from '@droppii/libs';
5
- import { CHAT_BUBBLE_COLORS } from "./constants.js";
6
- import { jsx as _jsx } from "react/jsx-runtime";
7
- const formatTime = date => date.toLocaleTimeString('vi-VN', {
8
- hour: '2-digit',
9
- minute: '2-digit',
10
- hour12: false
11
- });
12
- const formatDayLabel = createdAt => {
13
- const date = new Date(createdAt);
14
- if (Number.isNaN(date.getTime())) {
15
- return null;
16
- }
17
- const today = new Date();
18
- today.setHours(0, 0, 0, 0);
19
- const messageDay = new Date(date);
20
- messageDay.setHours(0, 0, 0, 0);
21
- if (messageDay.getTime() === today.getTime()) {
22
- return `${formatTime(date)} Hôm nay`;
23
- }
24
- const yesterday = new Date(today);
25
- yesterday.setDate(yesterday.getDate() - 1);
26
- if (messageDay.getTime() === yesterday.getTime()) {
27
- return `${formatTime(date)} Hôm qua`;
28
- }
29
- if (messageDay.getFullYear() === today.getFullYear()) {
30
- return `${formatTime(date)} ${date.toLocaleDateString('vi-VN', {
31
- day: 'numeric',
32
- month: 'long'
33
- })}`;
34
- }
35
- return `${formatTime(date)} ${date.toLocaleDateString('vi-VN', {
36
- day: 'numeric',
37
- month: 'long',
38
- year: 'numeric'
39
- })}`;
40
- };
41
- export const ChatDay = /*#__PURE__*/memo(({
42
- createdAt,
43
- containerStyle,
44
- wrapperStyle
45
- }) => {
46
- const dateStr = useMemo(() => createdAt == null ? null : formatDayLabel(createdAt), [createdAt]);
47
- if (!dateStr) {
48
- return null;
49
- }
50
- return /*#__PURE__*/_jsx(KContainer.View, {
51
- center: true,
52
- marginV: "0.5rem",
53
- style: containerStyle,
54
- children: /*#__PURE__*/_jsx(KContainer.View, {
55
- style: wrapperStyle,
56
- children: /*#__PURE__*/_jsx(KLabel.Text, {
57
- typo: "TextXsNormal",
58
- color: CHAT_BUBBLE_COLORS.dayLabel,
59
- children: dateStr
60
- })
61
- })
62
- });
63
- });
64
- ChatDay.displayName = 'ChatDay';
65
- //# sourceMappingURL=ChatDay.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["memo","useMemo","KContainer","KLabel","CHAT_BUBBLE_COLORS","jsx","_jsx","formatTime","date","toLocaleTimeString","hour","minute","hour12","formatDayLabel","createdAt","Date","Number","isNaN","getTime","today","setHours","messageDay","yesterday","setDate","getDate","getFullYear","toLocaleDateString","day","month","year","ChatDay","containerStyle","wrapperStyle","dateStr","View","center","marginV","style","children","Text","typo","color","dayLabel","displayName"],"sourceRoot":"../../../../src","sources":["screens/chat-detail/ChatDay.tsx"],"mappings":"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","ignoreList":[]}
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- export const DChatMessageType = {
4
- Text: 'TEXT',
5
- Link: 'LINK',
6
- Image: 'IMAGE',
7
- Video: 'VIDEO',
8
- File: 'FILE',
9
- Merged: 'MERGED',
10
- Order: 'ORDER',
11
- Unsupported: 'UNSUPPORTED'
12
- };
13
- export const CUSTOM_MESSAGE_DATA_TYPE = {
14
- LINK: 'LINK',
15
- ORDER: 'ORDER'
16
- };
17
- //# sourceMappingURL=message.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["DChatMessageType","Text","Link","Image","Video","File","Merged","Order","Unsupported","CUSTOM_MESSAGE_DATA_TYPE","LINK","ORDER"],"sourceRoot":"../../../src","sources":["types/message.ts"],"mappings":";;AAAA,OAAO,MAAMA,gBAAgB,GAAG;EAC9BC,IAAI,EAAE,MAAM;EACZC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,OAAO;EACdC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE,QAAQ;EAChBC,KAAK,EAAE,OAAO;EACdC,WAAW,EAAE;AACf,CAAU;AAKV,OAAO,MAAMC,wBAAwB,GAAG;EACtCC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE;AACT,CAAU","ignoreList":[]}
@@ -1,47 +0,0 @@
1
- "use strict";
2
-
3
- import { MessageType } from '@droppii/openim-rn-client-sdk';
4
- import { CUSTOM_MESSAGE_DATA_TYPE, DChatMessageType } from "../types/message.js";
5
- const parseCustomDataType = message => {
6
- const data = message.customElem?.data;
7
- if (!data) {
8
- return undefined;
9
- }
10
- try {
11
- const parsed = JSON.parse(data);
12
- return parsed.type ?? parsed.messageType;
13
- } catch {
14
- return undefined;
15
- }
16
- };
17
- export const resolveChatMessageType = message => {
18
- switch (message.contentType) {
19
- case MessageType.TextMessage:
20
- case MessageType.AtTextMessage:
21
- case MessageType.QuoteMessage:
22
- return DChatMessageType.Text;
23
- case MessageType.PictureMessage:
24
- return DChatMessageType.Image;
25
- case MessageType.VideoMessage:
26
- return DChatMessageType.Video;
27
- case MessageType.FileMessage:
28
- return DChatMessageType.File;
29
- case 107:
30
- // MergerMessage (merged/grouped messages)
31
- return DChatMessageType.Merged;
32
- case MessageType.CustomMessage:
33
- {
34
- const customType = parseCustomDataType(message);
35
- if (customType === CUSTOM_MESSAGE_DATA_TYPE.ORDER) {
36
- return DChatMessageType.Order;
37
- }
38
- if (customType === CUSTOM_MESSAGE_DATA_TYPE.LINK) {
39
- return DChatMessageType.Link;
40
- }
41
- return DChatMessageType.Unsupported;
42
- }
43
- default:
44
- return DChatMessageType.Unsupported;
45
- }
46
- };
47
- //# sourceMappingURL=resolveMessageType.js.map