@phonghq/go-chat 1.0.24 β†’ 1.0.25

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 (42) hide show
  1. package/dist/assets/icons/IconCloseCircle.vue.d.ts +2 -0
  2. package/dist/chat/page/home/ChatList.vue.d.ts +5 -2
  3. package/dist/chat/page/home/ChatMessage.vue.d.ts +2 -0
  4. package/dist/chat/page/home/ChatMessageItem.vue.d.ts +10 -3
  5. package/dist/chat/page/home/Home.vue.d.ts +1 -0
  6. package/dist/chat/page/setting/Setting.vue.d.ts +2 -0
  7. package/dist/components/chat/call/Calling.vue.d.ts +2 -2
  8. package/dist/components/chat/select/SelectBase.vue.d.ts +2 -0
  9. package/dist/components/common/drawer/DrawerBase.vue.d.ts +1 -1
  10. package/dist/components/common/drawer/DrawerBaseCustom.vue.d.ts +1 -0
  11. package/dist/composable/useCallHelper.d.ts +2 -0
  12. package/dist/composable/useListConversations.d.ts +4 -2
  13. package/dist/go-chat.es.js +10481 -10545
  14. package/dist/go-chat.umd.js +13 -13
  15. package/dist/style.css +1 -1
  16. package/dist/test/assets/icons/IconCloseCircle.vue.js +36 -0
  17. package/dist/test/chat/App.vue.js +97 -21
  18. package/dist/test/chat/page/customer-detail/CustomerDetail.vue.js +0 -3
  19. package/dist/test/chat/page/home/ChatList.vue.js +20 -34
  20. package/dist/test/chat/page/home/ChatMessage.vue.js +30 -21
  21. package/dist/test/chat/page/home/ChatMessageItem.vue.js +51 -37
  22. package/dist/test/chat/page/home/Home.vue.js +27 -60
  23. package/dist/test/chat/page/home/HomeHeader.vue.js +0 -6
  24. package/dist/test/chat/page/home/InputChat.vue.js +0 -1
  25. package/dist/test/chat/page/setting/Setting.vue.js +125 -0
  26. package/dist/test/components/chat/call/Calling.vue.js +21 -6
  27. package/dist/test/components/chat/select/SelectBase.vue.js +13 -3
  28. package/dist/test/components/common/drawer/DrawerBaseCustom.vue.js +9 -4
  29. package/dist/test/composable/useDigibot.js +2 -1
  30. package/dist/test/composable/useInitData.js +0 -6
  31. package/dist/test/composable/useListConversations.js +6 -4
  32. package/dist/test/composable/usePlivo.js +9 -3
  33. package/dist/test/types/chat/call.js +3 -1
  34. package/dist/test/utils/chat/auth.js +4 -3
  35. package/dist/test/utils/chat/conversation.js +57 -0
  36. package/dist/types/chat/call.d.ts +2 -0
  37. package/dist/types/chat/global.d.ts +1 -0
  38. package/dist/types/conversation.d.ts +2 -1
  39. package/dist/types/message.d.ts +1 -0
  40. package/dist/utils/chat/conversation.d.ts +7 -0
  41. package/dist/utils/chat/user.d.ts +2 -0
  42. package/package.json +1 -1
@@ -1,9 +1,10 @@
1
1
  /// <reference types="C:/phonghq/go-chat-v2/node_modules/.vue-global-types/vue_3.5_0.d.ts" />
2
+ import { dataProfile } from '../../../utils/chat/auth';
2
3
  import { nextTick, ref } from 'vue';
3
4
  import ScrollEvent from '../../../components/chat/ScrollEvent/ScrollEvent.vue';
4
- import { MessageState } from '../../../constant/message';
5
5
  import NewCustomer from '../../../chat/page/home/NewCustomer.vue';
6
6
  import ChatMessageItem from '../../../chat/page/home/ChatMessageItem.vue';
7
+ import dayjs from 'dayjs';
7
8
  const props = withDefaults(defineProps(), {});
8
9
  const emit = defineEmits();
9
10
  const scrollEventRef = ref(null);
@@ -25,6 +26,13 @@ const isEndMessage = (index) => {
25
26
  return true;
26
27
  return props.message[index + 1].sender_id !== props.message[index].sender_id;
27
28
  };
29
+ const isChatFinished = (index) => {
30
+ if (isEndMessage(index))
31
+ return true;
32
+ const time1 = dayjs(props.message[index].created_at);
33
+ const time2 = dayjs(props.message[index + 1].created_at);
34
+ return time2.diff(time1, 'minute') > 10;
35
+ };
28
36
  const handleScrollTop = () => {
29
37
  emit('scrollTop');
30
38
  };
@@ -34,23 +42,6 @@ const hideScrollEvent = () => {
34
42
  const fixedScroll = () => {
35
43
  scrollEventRef.value?.fixedScroll();
36
44
  };
37
- const getMessageStateText = (item) => {
38
- const state = item.state;
39
- switch (state) {
40
- case MessageState.Sending:
41
- return 'Sending...';
42
- case MessageState.Uploading:
43
- return 'Uploading...';
44
- case MessageState.Sent:
45
- return '';
46
- case MessageState.Read:
47
- return 'Seen';
48
- case MessageState.Failed:
49
- return item.error || 'Message failed';
50
- default:
51
- return '';
52
- }
53
- };
54
45
  const __VLS_exposed = { scrollBottom, hideScrollEvent, fixedScroll };
55
46
  defineExpose(__VLS_exposed);
56
47
  debugger; /* PartiallyEnd: #3632/scriptSetup.vue */
@@ -116,27 +107,45 @@ __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
116
107
  ...{ class: "chat-padding-page" },
117
108
  });
118
109
  for (const [item, index] of __VLS_getVForSourceType((__VLS_ctx.message))) {
119
- (item.id);
120
110
  // @ts-ignore
121
111
  [message,];
122
112
  /** @type {[typeof ChatMessageItem, ]} */ ;
123
113
  // @ts-ignore
124
114
  const __VLS_13 = __VLS_asFunctionalComponent(ChatMessageItem, new ChatMessageItem({
115
+ ...{ 'onCallAgain': {} },
125
116
  message: (item),
126
117
  index: (index),
127
118
  listMessage: (__VLS_ctx.message),
128
119
  responsive: (__VLS_ctx.responsive),
120
+ isMyMessage: (item.sender_id == __VLS_ctx.dataProfile?.id),
129
121
  data: (__VLS_ctx.data),
122
+ shouldShowAvatar: (__VLS_ctx.shouldShowAvatar(index)),
123
+ isLastMessage: (index == __VLS_ctx.message.length - 1),
124
+ isEndMessage: (__VLS_ctx.isEndMessage(index)),
125
+ isChatFinished: (__VLS_ctx.isChatFinished(index)),
130
126
  }));
131
127
  const __VLS_14 = __VLS_13({
128
+ ...{ 'onCallAgain': {} },
132
129
  message: (item),
133
130
  index: (index),
134
131
  listMessage: (__VLS_ctx.message),
135
132
  responsive: (__VLS_ctx.responsive),
133
+ isMyMessage: (item.sender_id == __VLS_ctx.dataProfile?.id),
136
134
  data: (__VLS_ctx.data),
135
+ shouldShowAvatar: (__VLS_ctx.shouldShowAvatar(index)),
136
+ isLastMessage: (index == __VLS_ctx.message.length - 1),
137
+ isEndMessage: (__VLS_ctx.isEndMessage(index)),
138
+ isChatFinished: (__VLS_ctx.isChatFinished(index)),
137
139
  }, ...__VLS_functionalComponentArgsRest(__VLS_13));
138
- // @ts-ignore
139
- [data, message, responsive,];
140
+ let __VLS_16;
141
+ let __VLS_17;
142
+ const __VLS_18 = ({ callAgain: {} },
143
+ { onCallAgain: (...[$event]) => {
144
+ __VLS_ctx.emit('callBack');
145
+ // @ts-ignore
146
+ [data, message, message, responsive, dataProfile, shouldShowAvatar, isEndMessage, isChatFinished, emit,];
147
+ } });
148
+ var __VLS_15;
140
149
  }
141
150
  var __VLS_2;
142
151
  /** @type {__VLS_StyleScopedClasses['relative']} */ ;
@@ -1,15 +1,16 @@
1
1
  /// <reference types="C:/phonghq/go-chat-v2/node_modules/.vue-global-types/vue_3.5_0.d.ts" />
2
2
  import Avatar from '../../../components/chat/customer/Avatar.vue';
3
- import { dataProfile } from '../../../utils/chat/auth';
4
3
  import { computed, nextTick } from 'vue';
5
4
  import { MessageState } from '../../../constant/message';
6
5
  import IconPhoneCancel from '../../../assets/icons/call/IconPhoneCancel.vue';
7
6
  import { PLIVO_CALL_STATUS } from '../../../types/chat/call';
8
7
  import IconPhone from '../../../assets/icons/customer-detail/IconPhone.vue';
8
+ import dayjs from 'dayjs';
9
+ import { DATE_FORMATS } from '../../../constant/datetime';
9
10
  const props = withDefaults(defineProps(), {});
10
- const isMyMessage = computed(() => props.message.sender_id == dataProfile.value?.id);
11
+ const emit = defineEmits();
11
12
  const callTitle = computed(() => {
12
- if (isMyMessage.value) {
13
+ if (props.isMyMessage) {
13
14
  if (props.message?.call_status == PLIVO_CALL_STATUS.CONNECT_FAILED) {
14
15
  return 'Call canceled';
15
16
  }
@@ -21,7 +22,11 @@ const callTitle = computed(() => {
21
22
  }
22
23
  }
23
24
  else {
24
- if (props.message?.call_status == PLIVO_CALL_STATUS.CONNECT_FAILED) {
25
+ if (props.message?.call_status == PLIVO_CALL_STATUS.CONNECT_FAILED ||
26
+ props.message?.call_status == PLIVO_CALL_STATUS.TIME_OUT ||
27
+ props.message?.call_status == PLIVO_CALL_STATUS.CANCEL ||
28
+ props.message?.call_status == PLIVO_CALL_STATUS.NO_ANSWER ||
29
+ props.message?.call_status == PLIVO_CALL_STATUS.BUSY) {
25
30
  return 'Call missed';
26
31
  }
27
32
  else if (props.message?.call_status == PLIVO_CALL_STATUS.CALL_END) {
@@ -43,16 +48,6 @@ const getCallDuration = (seconds) => {
43
48
  const secs = seconds % 60;
44
49
  return `${min} min${min > 1 ? 's' : ''} ${secs} sec`;
45
50
  };
46
- const shouldShowAvatar = (index) => {
47
- if (index === 0)
48
- return true;
49
- return props.listMessage[index - 1].sender_id !== props.listMessage[index].sender_id;
50
- };
51
- const isEndMessage = (index) => {
52
- if (props.listMessage?.length == index + 1)
53
- return true;
54
- return props.listMessage[index + 1].sender_id !== props.listMessage[index].sender_id;
55
- };
56
51
  const getMessageStateText = (item) => {
57
52
  const state = item.state;
58
53
  switch (state) {
@@ -77,6 +72,7 @@ const __VLS_ctx = {
77
72
  ...{},
78
73
  ...{},
79
74
  ...{},
75
+ ...{},
80
76
  };
81
77
  let __VLS_elements;
82
78
  let __VLS_components;
@@ -84,22 +80,22 @@ let __VLS_directives;
84
80
  __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
85
81
  ...{ class: "flex items-end mt-2" },
86
82
  ...{ class: ({
87
- 'mt-4': __VLS_ctx.shouldShowAvatar(__VLS_ctx.index),
83
+ 'mt-4': __VLS_ctx.shouldShowAvatar,
88
84
  'flex-col justify-end pl-[60px]': __VLS_ctx.isMyMessage,
89
85
  'gap-2': !__VLS_ctx.isMyMessage
90
86
  }) },
91
87
  });
92
88
  // @ts-ignore
93
- [shouldShowAvatar, index, isMyMessage, isMyMessage,];
89
+ [shouldShowAvatar, isMyMessage, isMyMessage,];
94
90
  if (__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending) {
95
91
  // @ts-ignore
96
92
  [message, MessageState,];
97
93
  if (!__VLS_ctx.isMyMessage) {
98
94
  // @ts-ignore
99
95
  [isMyMessage,];
100
- if (__VLS_ctx.shouldShowAvatar(__VLS_ctx.index)) {
96
+ if (__VLS_ctx.shouldShowAvatar) {
101
97
  // @ts-ignore
102
- [shouldShowAvatar, index,];
98
+ [shouldShowAvatar,];
103
99
  /** @type {[typeof Avatar, ]} */ ;
104
100
  // @ts-ignore
105
101
  const __VLS_0 = __VLS_asFunctionalComponent(Avatar, new Avatar({
@@ -133,17 +129,17 @@ if (__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending) {
133
129
  __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
134
130
  ...{ class: "px-3 py-2 rounded-2xl max-w-xs" },
135
131
  ...{ class: ({
136
- 'rounded-tl-none': !__VLS_ctx.shouldShowAvatar(__VLS_ctx.index) && !__VLS_ctx.isMyMessage,
137
- 'rounded-bl-none': !__VLS_ctx.isEndMessage(__VLS_ctx.index) && !__VLS_ctx.isMyMessage,
138
- 'rounded-tr-none': !__VLS_ctx.shouldShowAvatar(__VLS_ctx.index) && __VLS_ctx.isMyMessage,
139
- 'rounded-br-none': !__VLS_ctx.isEndMessage(__VLS_ctx.index) && __VLS_ctx.isMyMessage,
132
+ 'rounded-tl-none': !__VLS_ctx.shouldShowAvatar && !__VLS_ctx.isMyMessage,
133
+ 'rounded-bl-none': !__VLS_ctx.isEndMessage && !__VLS_ctx.isMyMessage,
134
+ 'rounded-tr-none': !__VLS_ctx.shouldShowAvatar && __VLS_ctx.isMyMessage,
135
+ 'rounded-br-none': !__VLS_ctx.isEndMessage && __VLS_ctx.isMyMessage,
140
136
  '!text-[#14532D] !bg-[#d4f8d4]': __VLS_ctx.message.message_uuid && !__VLS_ctx.message.is_call,
141
137
  'bg-[#D0DFEC] text-[#266699]': __VLS_ctx.isMyMessage,
142
138
  'bg-[#E4E4E4D4] text-chat-haze-600 text-left w-max ': !__VLS_ctx.isMyMessage
143
139
  }) },
144
140
  });
145
141
  // @ts-ignore
146
- [shouldShowAvatar, shouldShowAvatar, index, index, index, index, isMyMessage, isMyMessage, isMyMessage, isMyMessage, isMyMessage, isMyMessage, message, message, isEndMessage, isEndMessage,];
142
+ [shouldShowAvatar, shouldShowAvatar, isMyMessage, isMyMessage, isMyMessage, isMyMessage, isMyMessage, isMyMessage, message, message, isEndMessage, isEndMessage,];
147
143
  if (__VLS_ctx.message.is_call == 1) {
148
144
  // @ts-ignore
149
145
  [message,];
@@ -151,7 +147,7 @@ if (__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending) {
151
147
  ...{ class: "flex flex-col gap-2 w-[200px]" },
152
148
  });
153
149
  __VLS_asFunctionalElement(__VLS_elements.p, __VLS_elements.p)({
154
- ...{ class: "font-medium " },
150
+ ...{ class: "font-medium" },
155
151
  ...{ class: ({ 'text-chat-error': __VLS_ctx.message.call_status !== __VLS_ctx.PLIVO_CALL_STATUS.CALL_END }) },
156
152
  });
157
153
  // @ts-ignore
@@ -193,20 +189,28 @@ if (__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending) {
193
189
  ...{ class: "w-5 h-5" },
194
190
  }, ...__VLS_functionalComponentArgsRest(__VLS_8));
195
191
  }
192
+ __VLS_asFunctionalElement(__VLS_elements.span, __VLS_elements.span)({});
196
193
  (__VLS_ctx.getCallDuration(__VLS_ctx.message?.duration ?? 0));
197
194
  // @ts-ignore
198
195
  [message, getCallDuration,];
199
- __VLS_asFunctionalElement(__VLS_elements.p, __VLS_elements.p)({
200
- ...{ class: "text-sm text-red-600 mt-1" },
201
- });
202
- __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
196
+ __VLS_asFunctionalElement(__VLS_elements.button, __VLS_elements.button)({
197
+ ...{ onClick: (...[$event]) => {
198
+ if (!(__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending))
199
+ return;
200
+ if (!(__VLS_ctx.message.is_call == 1))
201
+ return;
202
+ __VLS_ctx.emit('callAgain');
203
+ // @ts-ignore
204
+ [emit,];
205
+ } },
203
206
  ...{ class: "flex-center h-10 rounded-xl bg-chat-haze-200 font-semibold" },
204
207
  });
205
- __VLS_asFunctionalElement(__VLS_elements.button, __VLS_elements.button)({});
208
+ __VLS_asFunctionalElement(__VLS_elements.p, __VLS_elements.p)({});
206
209
  }
207
210
  else if (__VLS_ctx.message.message) {
208
211
  // @ts-ignore
209
212
  [message,];
213
+ __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({});
210
214
  __VLS_asFunctionalElement(__VLS_elements.div)({
211
215
  ...{ style: ({ wordBreak: 'break-word' }) },
212
216
  });
@@ -214,13 +218,13 @@ if (__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending) {
214
218
  // @ts-ignore
215
219
  [message,];
216
220
  }
217
- else if (__VLS_ctx.message.attachments.length) {
221
+ else if (__VLS_ctx.message?.attachments?.length) {
218
222
  // @ts-ignore
219
223
  [message,];
220
224
  __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({});
221
225
  __VLS_asFunctionalElement(__VLS_elements.img)({
222
226
  ...{ onLoad: (() => {
223
- if (__VLS_ctx.index == __VLS_ctx.listMessage.length - 1) {
227
+ if (__VLS_ctx.isLastMessage) {
224
228
  __VLS_ctx.scrollBottom();
225
229
  }
226
230
  }) },
@@ -228,15 +232,25 @@ if (__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending) {
228
232
  alt: "avatar",
229
233
  });
230
234
  // @ts-ignore
231
- [index, message, listMessage, scrollBottom,];
235
+ [message, isLastMessage, scrollBottom,];
236
+ }
237
+ if (__VLS_ctx.isChatFinished) {
238
+ // @ts-ignore
239
+ [isChatFinished,];
240
+ __VLS_asFunctionalElement(__VLS_elements.p, __VLS_elements.p)({
241
+ ...{ class: "text-sm mt-1" },
242
+ });
243
+ (__VLS_ctx.dayjs(__VLS_ctx.message?.created_at).format(__VLS_ctx.DATE_FORMATS.TIME_12_FORMAT));
244
+ // @ts-ignore
245
+ [message, dayjs, DATE_FORMATS,];
232
246
  }
233
247
  if (__VLS_ctx.isMyMessage) {
234
248
  // @ts-ignore
235
249
  [isMyMessage,];
236
- if ((__VLS_ctx.index == __VLS_ctx.listMessage.length - 1 && __VLS_ctx.getMessageStateText(__VLS_ctx.message)) ||
250
+ if ((__VLS_ctx.isLastMessage && __VLS_ctx.getMessageStateText(__VLS_ctx.message)) ||
237
251
  __VLS_ctx.message.state == __VLS_ctx.MessageState.Failed) {
238
252
  // @ts-ignore
239
- [index, message, message, MessageState, listMessage, getMessageStateText,];
253
+ [message, message, MessageState, isLastMessage, getMessageStateText,];
240
254
  __VLS_asFunctionalElement(__VLS_elements.span, __VLS_elements.span)({
241
255
  ...{ class: "text-chat-haze-200 text-xs mt-1" },
242
256
  ...{ class: ({ '!text-chat-error': __VLS_ctx.message.state == __VLS_ctx.MessageState.Failed }) },
@@ -302,19 +316,19 @@ if (__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending) {
302
316
  /** @type {__VLS_StyleScopedClasses['h-full']} */ ;
303
317
  /** @type {__VLS_StyleScopedClasses['w-5']} */ ;
304
318
  /** @type {__VLS_StyleScopedClasses['h-5']} */ ;
305
- /** @type {__VLS_StyleScopedClasses['text-sm']} */ ;
306
- /** @type {__VLS_StyleScopedClasses['text-red-600']} */ ;
307
- /** @type {__VLS_StyleScopedClasses['mt-1']} */ ;
308
319
  /** @type {__VLS_StyleScopedClasses['flex-center']} */ ;
309
320
  /** @type {__VLS_StyleScopedClasses['h-10']} */ ;
310
321
  /** @type {__VLS_StyleScopedClasses['rounded-xl']} */ ;
311
322
  /** @type {__VLS_StyleScopedClasses['bg-chat-haze-200']} */ ;
312
323
  /** @type {__VLS_StyleScopedClasses['font-semibold']} */ ;
324
+ /** @type {__VLS_StyleScopedClasses['text-sm']} */ ;
325
+ /** @type {__VLS_StyleScopedClasses['mt-1']} */ ;
313
326
  /** @type {__VLS_StyleScopedClasses['text-chat-haze-200']} */ ;
314
327
  /** @type {__VLS_StyleScopedClasses['text-xs']} */ ;
315
328
  /** @type {__VLS_StyleScopedClasses['mt-1']} */ ;
316
329
  /** @type {__VLS_StyleScopedClasses['!text-chat-error']} */ ;
317
330
  const __VLS_export = (await import('vue')).defineComponent({
331
+ __typeEmits: {},
318
332
  __typeProps: {},
319
333
  props: {},
320
334
  });
@@ -2,15 +2,13 @@
2
2
  import HomeHeader from '../../../chat/page/home/HomeHeader.vue';
3
3
  import NewCustomer from '../../../chat/page/home/NewCustomer.vue';
4
4
  import InputChat from '../../../chat/page/home/InputChat.vue';
5
- import { getCountUnread, getDetailReceiver, getMessage, sendMessage, upLoadImage } from '../../../utils/chat/message';
5
+ import { getDetailReceiver, getMessage, sendMessage, upLoadImage } from '../../../utils/chat/message';
6
6
  import { nextTick, onMounted, onUnmounted, ref, shallowRef } from 'vue';
7
7
  import ChatMessage from '../../../chat/page/home/ChatMessage.vue';
8
8
  import { addHandleMqttMessage, connectMqtt, publishMessage, removeHandleMqttMessage, subscribeToTopic, unsubscribeFromTopic } from '../../../plugins/mqtt';
9
- import { TOPIC_DETAIL_CHAT, TOPIC_HOME } from '../../../constant/mqtt';
10
- import { dataProfile } from '../../../utils/chat/auth';
11
- import dayjs from 'dayjs';
12
- import { DATE_FORMATS, TIME_ZONE_UTC } from '../../../constant/datetime';
9
+ import { TOPIC_DETAIL_CHAT } from '../../../constant/mqtt';
13
10
  import { MessageState } from '../../../constant/message';
11
+ import { publicTopicConversationUpdate } from '../../../utils/chat/conversation';
14
12
  const props = withDefaults(defineProps(), {});
15
13
  const emit = defineEmits();
16
14
  let page = 1;
@@ -42,8 +40,8 @@ const handleDisconnectMqtt = async () => {
42
40
  removeHandleMqttMessage('chat-home');
43
41
  };
44
42
  const mqttMessageHandler = (topic, message) => {
45
- if ((infoUser.value?.id && message?.sender_id?.toString() == infoUser.value?.id?.toString()) ||
46
- true) {
43
+ console.log(message);
44
+ if ((infoUser.value?.id && message?.sender_id?.toString() == infoUser.value?.id?.toString())) {
47
45
  const index = listMessage.value.findIndex((item) => item.id === message?.id);
48
46
  if (index < 0) {
49
47
  listMessage.value.push(message);
@@ -53,6 +51,7 @@ const mqttMessageHandler = (topic, message) => {
53
51
  }
54
52
  chatMessageRef.value?.scrollBottom();
55
53
  }
54
+ console.log(listMessage.value);
56
55
  };
57
56
  const handleGetMessage = async (option) => {
58
57
  try {
@@ -89,7 +88,7 @@ const handleScrollTop = async () => {
89
88
  const handleGetDetailReceiver = async (data) => {
90
89
  const id = props.receiverId;
91
90
  if (data)
92
- infoUser.value = data;
91
+ infoUser.value = { ...data, conversation_id: data.id };
93
92
  const res = (await getDetailReceiver(props.receiverId)) ?? null;
94
93
  if (id == props.receiverId) {
95
94
  infoUser.value = res;
@@ -100,7 +99,8 @@ const getData = async (data) => {
100
99
  try {
101
100
  isLoading.value = true;
102
101
  listMessage.value = [];
103
- await Promise.allSettled([handleGetMessage(), handleGetDetailReceiver(data)]);
102
+ handleGetDetailReceiver(data);
103
+ await Promise.allSettled([handleGetMessage()]);
104
104
  // readMessages(infoUser.value?.conversation_id)
105
105
  await nextTick();
106
106
  chatMessageRef.value?.scrollBottom();
@@ -153,7 +153,7 @@ const handleSendMessage = async (data) => {
153
153
  : []
154
154
  });
155
155
  updateMessageItem(data.id, { state: MessageState.Sent });
156
- publicTopicConversationUpdate(false, data?.message ?? '');
156
+ publicTopicConversationUpdate({ message: data?.message ?? '', isSendImg: !!file_upload?.length, infoUser: infoUser.value });
157
157
  }
158
158
  catch (error) {
159
159
  updateMessageItem(data.id, {
@@ -174,49 +174,12 @@ const handleUploadImage = async (file) => {
174
174
  const res = await upLoadImage(formData);
175
175
  return res;
176
176
  };
177
- const publicTopicConversationUpdate = async (isSendImg, message) => {
178
- const res = await getCountUnread({
179
- conversation_id: infoUser.value?.conversation_id ?? 0,
180
- receiver_id: Number(infoUser.value?.id)
181
- });
182
- const current = dayjs().tz(TIME_ZONE_UTC).format(DATE_FORMATS['DATE_FORMAT_FULL']);
183
- const dataMessageForReceiver = {
184
- id: infoUser.value?.conversation_id ?? 0,
185
- receiver_id: Number(dataProfile.value?.id ?? 0),
186
- username: dataProfile.value?.username ?? '',
187
- customer_phone: dataProfile.value?.phone ?? '',
188
- avatar: dataProfile.value?.avatar ?? '',
189
- last_message: isSendImg ? `${infoUser.value?.username} sent images` : message,
190
- last_message_time: current,
191
- created_at: current,
192
- updated_at: current,
193
- unread_count: (res?.unread_count ?? 0) + 1,
194
- status: 1,
195
- color: dataProfile.value?.color ?? ''
196
- };
197
- publishMessage(`${TOPIC_HOME[0] + Number(infoUser.value?.id)}`, JSON.stringify(dataMessageForReceiver));
198
- const dataMessageMyself = {
199
- id: infoUser.value?.conversation_id ?? 0,
200
- receiver_id: Number(dataProfile.value?.id ?? 0),
201
- username: infoUser.value?.username ?? '',
202
- customer_phone: infoUser.value?.phone ?? '',
203
- avatar: infoUser.value?.avatar ?? '',
204
- last_message: isSendImg ? `${infoUser.value?.username} sent images` : message,
205
- last_message_time: current,
206
- created_at: current,
207
- updated_at: current,
208
- unread_count: 0,
209
- status: 1,
210
- color: infoUser.value?.color
211
- };
212
- publishMessage(`${TOPIC_HOME[0] + Number(dataProfile.value?.id)}`, JSON.stringify(dataMessageMyself));
213
- };
214
177
  const call = () => {
215
178
  if (infoUser.value) {
216
179
  emit('call', infoUser.value);
217
180
  }
218
181
  };
219
- const __VLS_exposed = { getData, handleGetMessage };
182
+ const __VLS_exposed = { getData, handleGetMessage, infoUser };
220
183
  defineExpose(__VLS_exposed);
221
184
  debugger; /* PartiallyEnd: #3632/scriptSetup.vue */
222
185
  const __VLS_defaults = {};
@@ -259,6 +222,7 @@ if (__VLS_ctx.listMessage?.length) {
259
222
  // @ts-ignore
260
223
  const __VLS_7 = __VLS_asFunctionalComponent(ChatMessage, new ChatMessage({
261
224
  ...{ 'onScrollTop': {} },
225
+ ...{ 'onCallBack': {} },
262
226
  ref: "chatMessageRef",
263
227
  data: (__VLS_ctx.infoUser),
264
228
  message: (__VLS_ctx.listMessage),
@@ -268,6 +232,7 @@ if (__VLS_ctx.listMessage?.length) {
268
232
  }));
269
233
  const __VLS_8 = __VLS_7({
270
234
  ...{ 'onScrollTop': {} },
235
+ ...{ 'onCallBack': {} },
271
236
  ref: "chatMessageRef",
272
237
  data: (__VLS_ctx.infoUser),
273
238
  message: (__VLS_ctx.listMessage),
@@ -279,10 +244,12 @@ if (__VLS_ctx.listMessage?.length) {
279
244
  let __VLS_11;
280
245
  const __VLS_12 = ({ scrollTop: {} },
281
246
  { onScrollTop: (__VLS_ctx.handleScrollTop) });
247
+ const __VLS_13 = ({ callBack: {} },
248
+ { onCallBack: (__VLS_ctx.call) });
282
249
  /** @type {typeof __VLS_ctx.chatMessageRef} */ ;
283
- var __VLS_13 = {};
250
+ var __VLS_14 = {};
284
251
  // @ts-ignore
285
- [infoUser, listMessage, responsive, page, pageCount, handleScrollTop, chatMessageRef,];
252
+ [infoUser, call, listMessage, responsive, page, pageCount, handleScrollTop, chatMessageRef,];
286
253
  var __VLS_9;
287
254
  }
288
255
  else if (!__VLS_ctx.isLoading) {
@@ -290,14 +257,14 @@ else if (!__VLS_ctx.isLoading) {
290
257
  [isLoading,];
291
258
  /** @type {[typeof NewCustomer, ]} */ ;
292
259
  // @ts-ignore
293
- const __VLS_16 = __VLS_asFunctionalComponent(NewCustomer, new NewCustomer({
260
+ const __VLS_17 = __VLS_asFunctionalComponent(NewCustomer, new NewCustomer({
294
261
  data: (__VLS_ctx.infoUser),
295
262
  ...{ class: "grow" },
296
263
  }));
297
- const __VLS_17 = __VLS_16({
264
+ const __VLS_18 = __VLS_17({
298
265
  data: (__VLS_ctx.infoUser),
299
266
  ...{ class: "grow" },
300
- }, ...__VLS_functionalComponentArgsRest(__VLS_16));
267
+ }, ...__VLS_functionalComponentArgsRest(__VLS_17));
301
268
  // @ts-ignore
302
269
  [infoUser,];
303
270
  }
@@ -308,23 +275,23 @@ else {
308
275
  }
309
276
  /** @type {[typeof InputChat, ]} */ ;
310
277
  // @ts-ignore
311
- const __VLS_20 = __VLS_asFunctionalComponent(InputChat, new InputChat({
278
+ const __VLS_21 = __VLS_asFunctionalComponent(InputChat, new InputChat({
312
279
  ...{ 'onSendMessage': {} },
313
280
  data: (__VLS_ctx.infoUser),
314
281
  ...{ class: "p-6" },
315
282
  }));
316
- const __VLS_21 = __VLS_20({
283
+ const __VLS_22 = __VLS_21({
317
284
  ...{ 'onSendMessage': {} },
318
285
  data: (__VLS_ctx.infoUser),
319
286
  ...{ class: "p-6" },
320
- }, ...__VLS_functionalComponentArgsRest(__VLS_20));
321
- let __VLS_23;
287
+ }, ...__VLS_functionalComponentArgsRest(__VLS_21));
322
288
  let __VLS_24;
323
- const __VLS_25 = ({ sendMessage: {} },
289
+ let __VLS_25;
290
+ const __VLS_26 = ({ sendMessage: {} },
324
291
  { onSendMessage: (__VLS_ctx.handleSendMessage) });
325
292
  // @ts-ignore
326
293
  [infoUser, handleSendMessage,];
327
- var __VLS_22;
294
+ var __VLS_23;
328
295
  /** @type {__VLS_StyleScopedClasses['h-full']} */ ;
329
296
  /** @type {__VLS_StyleScopedClasses['flex']} */ ;
330
297
  /** @type {__VLS_StyleScopedClasses['flex-col']} */ ;
@@ -335,7 +302,7 @@ var __VLS_22;
335
302
  /** @type {__VLS_StyleScopedClasses['grow']} */ ;
336
303
  /** @type {__VLS_StyleScopedClasses['p-6']} */ ;
337
304
  // @ts-ignore
338
- var __VLS_14 = __VLS_13;
305
+ var __VLS_15 = __VLS_14;
339
306
  const __VLS_export = (await import('vue')).defineComponent({
340
307
  setup: () => (__VLS_exposed),
341
308
  __typeEmits: {},
@@ -79,9 +79,6 @@ __VLS_asFunctionalElement(__VLS_elements.p, __VLS_elements.p)({
79
79
  (__VLS_ctx.data?.username ?? 'n/a');
80
80
  // @ts-ignore
81
81
  [data,];
82
- __VLS_asFunctionalElement(__VLS_elements.p, __VLS_elements.p)({
83
- ...{ class: "text-sm text-chat-gray-3 truncate" },
84
- });
85
82
  if (__VLS_ctx.data?.id && __VLS_ctx.data?.id != __VLS_ctx.digibotId.toString() && __VLS_ctx.dataProfile?.user_type == 'tenant') {
86
83
  // @ts-ignore
87
84
  [dataProfile, data, data, digibotId,];
@@ -116,9 +113,6 @@ if (__VLS_ctx.data?.id && __VLS_ctx.data?.id != __VLS_ctx.digibotId.toString() &
116
113
  /** @type {__VLS_StyleScopedClasses['flex']} */ ;
117
114
  /** @type {__VLS_StyleScopedClasses['items-center']} */ ;
118
115
  /** @type {__VLS_StyleScopedClasses['font-semibold']} */ ;
119
- /** @type {__VLS_StyleScopedClasses['text-sm']} */ ;
120
- /** @type {__VLS_StyleScopedClasses['text-chat-gray-3']} */ ;
121
- /** @type {__VLS_StyleScopedClasses['truncate']} */ ;
122
116
  /** @type {__VLS_StyleScopedClasses['flex-center']} */ ;
123
117
  /** @type {__VLS_StyleScopedClasses['text-[#0051E6]']} */ ;
124
118
  /** @type {__VLS_StyleScopedClasses['bg-chat-haze-200']} */ ;
@@ -42,7 +42,6 @@ const handleSendMessage = async (type) => {
42
42
  keyword.value = '';
43
43
  chatId++;
44
44
  const id = props.data?.id.toString() + '-' + chatId;
45
- console.log(dayjs().tz(TIME_ZONE_UTC).format(DATE_FORMATS['DATE_FORMAT_FULL']));
46
45
  const data = {
47
46
  conversation_id: 135,
48
47
  created_at: dayjs().tz(TIME_ZONE_UTC).format(DATE_FORMATS['DATE_FORMAT_FULL']),
@@ -0,0 +1,125 @@
1
+ /// <reference types="C:/phonghq/go-chat-v2/node_modules/.vue-global-types/vue_3.5_0.d.ts" />
2
+ import { ref } from 'vue';
3
+ import SelectBase from '../../../components/chat/select/SelectBase.vue';
4
+ const open = ref(false);
5
+ const phoneValue = ref('');
6
+ const countries = [
7
+ // { value: 'VN', label: 'Vietnam', dial: 84, flag: 'πŸ‡»πŸ‡³' },
8
+ { value: 'US', label: '+1 US', dial: 1, flag: 'πŸ‡ΊπŸ‡Έ' }
9
+ // { value: 'KR', label: 'Korea', dial: 82, flag: 'πŸ‡°πŸ‡·' },
10
+ // { value: 'JP', label: 'Japan', dial: 81, flag: 'πŸ‡―πŸ‡΅' },
11
+ // { value: 'TH', label: 'Thailand', dial: 66, flag: 'πŸ‡ΉπŸ‡­' },
12
+ ];
13
+ const selected = ref(countries[0]);
14
+ const error = ref('');
15
+ const select = (c) => {
16
+ selected.value = c;
17
+ open.value = false;
18
+ };
19
+ const handleInput = () => {
20
+ error.value = '';
21
+ phoneValue.value = keepOnlyNumbers(phoneValue.value);
22
+ };
23
+ const keepOnlyNumbers = (str) => {
24
+ return str.replace(/\D/g, '');
25
+ };
26
+ const onSubmit = () => { };
27
+ debugger; /* PartiallyEnd: #3632/scriptSetup.vue */
28
+ const __VLS_ctx = {
29
+ ...{},
30
+ ...{},
31
+ };
32
+ let __VLS_elements;
33
+ let __VLS_components;
34
+ let __VLS_directives;
35
+ __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({});
36
+ __VLS_asFunctionalElement(__VLS_elements.p, __VLS_elements.p)({
37
+ ...{ class: "text-xl font-semibold text-chat-haze-600 mb-4" },
38
+ });
39
+ __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
40
+ ...{ class: "flex items-center gap-2 chat-input border border-chat-haze-200 p-2 bg-white shadow-md" },
41
+ });
42
+ __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
43
+ ...{ class: "relative" },
44
+ });
45
+ /** @type {[typeof SelectBase, typeof SelectBase, ]} */ ;
46
+ // @ts-ignore
47
+ const __VLS_0 = __VLS_asFunctionalComponent(SelectBase, new SelectBase({
48
+ options: (__VLS_ctx.countries),
49
+ placement: "bottom",
50
+ disabled: true,
51
+ }));
52
+ const __VLS_1 = __VLS_0({
53
+ options: (__VLS_ctx.countries),
54
+ placement: "bottom",
55
+ disabled: true,
56
+ }, ...__VLS_functionalComponentArgsRest(__VLS_0));
57
+ const { default: __VLS_3 } = __VLS_2.slots;
58
+ // @ts-ignore
59
+ [countries,];
60
+ __VLS_asFunctionalElement(__VLS_elements.button, __VLS_elements.button)({
61
+ ...{ class: "flex items-center gap-1 px-2 py-1 rounded-lg hover:bg-gray-100" },
62
+ });
63
+ __VLS_asFunctionalElement(__VLS_elements.span, __VLS_elements.span)({});
64
+ (__VLS_ctx.selected.flag);
65
+ // @ts-ignore
66
+ [selected,];
67
+ __VLS_asFunctionalElement(__VLS_elements.span, __VLS_elements.span)({
68
+ ...{ class: "text-sm text-chat-haze-700" },
69
+ });
70
+ (__VLS_ctx.selected.dial);
71
+ // @ts-ignore
72
+ [selected,];
73
+ __VLS_asFunctionalElement(__VLS_elements.svg, __VLS_elements.svg)({
74
+ ...{ class: "w-4 h-4 text-chat-haze-500" },
75
+ fill: "none",
76
+ stroke: "currentColor",
77
+ viewBox: "0 0 20 20",
78
+ });
79
+ __VLS_asFunctionalElement(__VLS_elements.path)({
80
+ 'stroke-linecap': "round",
81
+ 'stroke-linejoin': "round",
82
+ 'stroke-width': "2",
83
+ d: "M5 7l5 5 5-5",
84
+ });
85
+ var __VLS_2;
86
+ __VLS_asFunctionalElement(__VLS_elements.input)({
87
+ ...{ onInput: (__VLS_ctx.handleInput) },
88
+ ...{ onKeyup: (__VLS_ctx.onSubmit) },
89
+ ...{ class: "!outline-none" },
90
+ type: "tel",
91
+ maxlength: (10),
92
+ placeholder: "Enter phone number",
93
+ });
94
+ (__VLS_ctx.phoneValue);
95
+ // @ts-ignore
96
+ [handleInput, onSubmit, phoneValue,];
97
+ /** @type {__VLS_StyleScopedClasses['text-xl']} */ ;
98
+ /** @type {__VLS_StyleScopedClasses['font-semibold']} */ ;
99
+ /** @type {__VLS_StyleScopedClasses['text-chat-haze-600']} */ ;
100
+ /** @type {__VLS_StyleScopedClasses['mb-4']} */ ;
101
+ /** @type {__VLS_StyleScopedClasses['flex']} */ ;
102
+ /** @type {__VLS_StyleScopedClasses['items-center']} */ ;
103
+ /** @type {__VLS_StyleScopedClasses['gap-2']} */ ;
104
+ /** @type {__VLS_StyleScopedClasses['chat-input']} */ ;
105
+ /** @type {__VLS_StyleScopedClasses['border']} */ ;
106
+ /** @type {__VLS_StyleScopedClasses['border-chat-haze-200']} */ ;
107
+ /** @type {__VLS_StyleScopedClasses['p-2']} */ ;
108
+ /** @type {__VLS_StyleScopedClasses['bg-white']} */ ;
109
+ /** @type {__VLS_StyleScopedClasses['shadow-md']} */ ;
110
+ /** @type {__VLS_StyleScopedClasses['relative']} */ ;
111
+ /** @type {__VLS_StyleScopedClasses['flex']} */ ;
112
+ /** @type {__VLS_StyleScopedClasses['items-center']} */ ;
113
+ /** @type {__VLS_StyleScopedClasses['gap-1']} */ ;
114
+ /** @type {__VLS_StyleScopedClasses['px-2']} */ ;
115
+ /** @type {__VLS_StyleScopedClasses['py-1']} */ ;
116
+ /** @type {__VLS_StyleScopedClasses['rounded-lg']} */ ;
117
+ /** @type {__VLS_StyleScopedClasses['hover:bg-gray-100']} */ ;
118
+ /** @type {__VLS_StyleScopedClasses['text-sm']} */ ;
119
+ /** @type {__VLS_StyleScopedClasses['text-chat-haze-700']} */ ;
120
+ /** @type {__VLS_StyleScopedClasses['w-4']} */ ;
121
+ /** @type {__VLS_StyleScopedClasses['h-4']} */ ;
122
+ /** @type {__VLS_StyleScopedClasses['text-chat-haze-500']} */ ;
123
+ /** @type {__VLS_StyleScopedClasses['!outline-none']} */ ;
124
+ const __VLS_export = (await import('vue')).defineComponent({});
125
+ export default {};