@phonghq/go-chat 1.0.26 → 1.0.28

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 (35) hide show
  1. package/README.md +2 -1
  2. package/dist/chat/page/home/Home.vue.d.ts +2 -0
  3. package/dist/chat/page/home/InputChat.vue.d.ts +2 -0
  4. package/dist/components/chat/common/modal/Modal.vue.d.ts +94 -0
  5. package/dist/components/chat/common/spin/BaseSpin.vue.d.ts +8 -1
  6. package/dist/components/chat/common/switch/SwitchBase.vue.d.ts +3 -0
  7. package/dist/components/common/drawer/DrawerBase.vue.d.ts +1 -1
  8. package/dist/constant/mqtt.d.ts +1 -0
  9. package/dist/go-chat.es.js +7538 -7477
  10. package/dist/go-chat.umd.js +13 -13
  11. package/dist/style.css +1 -1
  12. package/dist/test/chat/App.vue.js +77 -66
  13. package/dist/test/chat/page/customer-appointment/CustomerAppointment.vue.js +3 -3
  14. package/dist/test/chat/page/home/ChatList.vue.js +14 -115
  15. package/dist/test/chat/page/home/ChatMessage.vue.js +1 -3
  16. package/dist/test/chat/page/home/ChatMessageItem.vue.js +3 -3
  17. package/dist/test/chat/page/home/Home.vue.js +30 -15
  18. package/dist/test/chat/page/home/InputChat.vue.js +78 -28
  19. package/dist/test/components/chat/call/Calling.vue.js +4 -3
  20. package/dist/test/components/chat/common/modal/Modal.vue.js +260 -0
  21. package/dist/test/components/chat/common/spin/BaseSpin.vue.js +29 -2
  22. package/dist/test/components/chat/common/switch/SwitchBase.vue.js +8 -2
  23. package/dist/test/components/common/modal/ModalBase.vue.js +49 -26
  24. package/dist/test/components/ui/button/c-button.js +7 -7
  25. package/dist/test/composable/useInitData.js +2 -1
  26. package/dist/test/composable/useListConversations.js +1 -1
  27. package/dist/test/composable/usePlivo.js +11 -7
  28. package/dist/test/constant/mqtt.js +1 -0
  29. package/dist/test/utils/chat/call.js +4 -3
  30. package/dist/test/utils/chat/conversation.js +1 -1
  31. package/dist/test/utils/chat/message.js +4 -0
  32. package/dist/utils/chat/message.d.ts +4 -0
  33. package/package.json +2 -2
  34. package/dist/assets/icons/IconSetting.vue.d.ts +0 -2
  35. package/dist/test/assets/icons/IconSetting.vue.js +0 -33
@@ -55,111 +55,14 @@ const listConversations = computed(() => {
55
55
  return listConversationsAll.value;
56
56
  return listConversationsUnknown.value;
57
57
  });
58
- const isOpen = ref(false);
59
58
  const keyword = ref('');
60
59
  const activeTabs = ref(TAB_VALUE.ALL);
61
60
  const scrollEventRef = ref(null);
62
- // const listConversations = ref<IConversation[]>([])
63
- // const params = ref({
64
- // page: 1,
65
- // search: ''
66
- // })
67
- // let pageCount = 0
68
61
  const isLoadingSearch = ref(false);
69
- //
70
- // onMounted(() => {
71
- // handleConnectMqtt()
72
- // })
73
- //
74
- // onUnmounted(() => {
75
- // handleDisconnectMqtt
76
- // })
77
- //
78
- // const handleDisconnectMqtt = () => {
79
- // TOPIC_HOME.forEach((item: string) => {
80
- // unsubscribeFromTopic(item + dataProfile.value?.id)
81
- // removeHandleMqttMessage('chat-list-' + item)
82
- // })
83
- // if (dataProfile.value?.user_type == 'tenant') {
84
- // subscribeToTopic(TOPIC_STATUS_USER + dataProfile.value?.id)
85
- // removeHandleMqttMessage('chat-list-' + TOPIC_STATUS_USER)
86
- // }
87
- // }
88
- //
89
- // const handleConnectMqtt = async () => {
90
- // try {
91
- // if (dataProfile.value) {
92
- // await connectMqtt()
93
- // TOPIC_HOME.forEach((item: string) => {
94
- // subscribeToTopic(item + dataProfile.value?.id)
95
- // addHandleMqttMessage('chat-list-' + item, item + dataProfile.value?.id, mqttMessageHandler)
96
- // })
97
- // subscribeToTopic(TOPIC_STATUS_USER + dataProfile.value?.id)
98
- // addHandleMqttMessage(
99
- // 'chat-list-' + TOPIC_STATUS_USER,
100
- // TOPIC_STATUS_USER + dataProfile.value?.id,
101
- // mqttMessageHandler
102
- // )
103
- // }
104
- // } catch (error) {
105
- // console.error(error)
106
- // }
107
- // }
108
- //
109
- // const mqttMessageHandler = (topic: string, data: any) => {
110
- // getDataMqtt()
111
- // if (topic === TOPIC_HOME[0] + dataProfile.value?.id) {
112
- // const index = listConversations.value.findIndex((item: any) => item.id === data.id)
113
- // const hasChatBox = listConversations.value.findIndex((item: any) => item.id === digibotId)
114
- // if (index != -1) {
115
- // listConversations.value.splice(index, 1)
116
- // }
117
- // if (hasChatBox > -1) {
118
- // listConversations.value.splice(1, 0, data)
119
- // } else {
120
- // listConversations.value.unshift(data)
121
- // }
122
- // }
123
- //
124
- // if (topic === TOPIC_HOME[1] + dataProfile.value?.id) {
125
- // const index = listConversations.value.findIndex((item: any) => item.id === data.id)
126
- // if (index != -1) {
127
- // listConversations.value[index].unread_count = 0
128
- // }
129
- // }
130
- //
131
- // if (topic === TOPIC_HOME[2] + dataProfile.value?.id) {
132
- // listConversations.value.unshift(data?.conversations)
133
- // }
134
- //
135
- // if (topic === TOPIC_STATUS_USER + dataProfile.value?.id) {
136
- // const index = listConversations.value.findIndex(
137
- // (e) => e.receiver_id == Number(data?.customer_id)
138
- // )
139
- // if (index != -1) {
140
- // listConversations.value[index].status = data.is_online ? 1 : 0
141
- // }
142
- // }
143
- // }
144
- //
145
- // const getDataMqtt = useDebounce(() => {
146
- // getData(undefined, { hideLoading: true, reset: true })
147
- // }, 5000)
148
- //
149
62
  const getData = async (data, option) => {
150
63
  try {
151
64
  if (!option?.hideLoading)
152
65
  isLoadingSearch.value = true;
153
- // params.value = { ...params.value, ...(data ?? {}) }
154
- // const res = await getConversation({ ...params.value, is_unknown: activeTabs.value })
155
- // if (option?.reset) {
156
- // listConversations.value = []
157
- // listConversations.value.push(digibotData)
158
- // await nextTick()
159
- // }
160
- // listConversations.value.push(...(res?.items ?? []))
161
- // params.value.page = res?._meta?.currentPage || 1
162
- // pageCount = res?._meta?.pageCount || 1
163
66
  if (activeTabs.value == TAB_VALUE.ALL) {
164
67
  await getDataAll(data, option);
165
68
  }
@@ -236,15 +139,7 @@ const handleReadMessage = () => {
236
139
  else if (activeTabs.value == TAB_VALUE.UNKNOWN) {
237
140
  handleReadMessageUnknown(receiver_id.value);
238
141
  }
239
- // const index = listConversations.value.findIndex((e) => e.receiver_id == receiver_id.value)
240
- // if (index > -1) {
241
- // if (listConversations.value[index].unread_count) {
242
- // readMessages(listConversations.value[index].id)
243
- // listConversations.value[index].unread_count = 0
244
- // }
245
- // }
246
142
  };
247
- //
248
143
  const getTimeFromNow = (data) => {
249
144
  if (data && dayjs(data).isValid()) {
250
145
  return dayjs.tz(data, TIME_ZONE_UTC).local().fromNow();
@@ -290,13 +185,13 @@ __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
290
185
  // @ts-ignore
291
186
  const __VLS_0 = __VLS_asFunctionalComponent(InputSearch, new InputSearch({
292
187
  ...{ 'onSearch': {} },
293
- ...{ class: "h-[45px] grow" },
188
+ ...{ class: "h-11 grow" },
294
189
  responsive: (__VLS_ctx.responsive),
295
190
  modelValue: (__VLS_ctx.keyword),
296
191
  }));
297
192
  const __VLS_1 = __VLS_0({
298
193
  ...{ 'onSearch': {} },
299
- ...{ class: "h-[45px] grow" },
194
+ ...{ class: "h-11 grow" },
300
195
  responsive: (__VLS_ctx.responsive),
301
196
  modelValue: (__VLS_ctx.keyword),
302
197
  }, ...__VLS_functionalComponentArgsRest(__VLS_0));
@@ -308,7 +203,7 @@ const __VLS_5 = ({ search: {} },
308
203
  [responsive, keyword, handleSearch,];
309
204
  var __VLS_2;
310
205
  __VLS_asFunctionalElement(__VLS_elements.button, __VLS_elements.button)({
311
- ...{ class: "h-[45px] w-[45px] rounded-full flex-center bg-[#C7DEFF]" },
206
+ ...{ class: "h-11 w-11 rounded-full flex-center bg-[#C7DEFF]" },
312
207
  });
313
208
  /** @type {[typeof IconPlus, ]} */ ;
314
209
  // @ts-ignore
@@ -413,10 +308,10 @@ for (const [user] of __VLS_getVForSourceType((__VLS_ctx.listConversations))) {
413
308
  ...{ class: "truncate" },
414
309
  });
415
310
  __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
416
- ...{ class: "flex items-center" },
311
+ ...{ class: "flex items-center text-left" },
417
312
  });
418
313
  __VLS_asFunctionalElement(__VLS_elements.p, __VLS_elements.p)({
419
- ...{ class: "font-semibold" },
314
+ ...{ class: "truncate font-semibold" },
420
315
  });
421
316
  (user.username);
422
317
  if (user.id == __VLS_ctx.digibotId) {
@@ -433,7 +328,7 @@ for (const [user] of __VLS_getVForSourceType((__VLS_ctx.listConversations))) {
433
328
  }
434
329
  if (user.unread_count) {
435
330
  __VLS_asFunctionalElement(__VLS_elements.span, __VLS_elements.span)({
436
- ...{ class: "ml-2 bg-[#E60000] text-white text-xs font-bold px-2 py-[1px] flex-center rounded-full" },
331
+ ...{ class: "shrink-0 ml-2 bg-[#E60000] text-white text-xs font-bold px-2 py-[1px] flex-center rounded-full" },
437
332
  });
438
333
  (user.unread_count);
439
334
  }
@@ -446,7 +341,7 @@ for (const [user] of __VLS_getVForSourceType((__VLS_ctx.listConversations))) {
446
341
  });
447
342
  (user.last_message ?? 'No messages');
448
343
  __VLS_asFunctionalElement(__VLS_elements.span, __VLS_elements.span)({
449
- ...{ class: "text-sm text-right text-chat-gray-4 w-[130px]" },
344
+ ...{ class: "shrink-0 text-sm text-right text-chat-gray-4 w-[130px]" },
450
345
  });
451
346
  (__VLS_ctx.getTimeFromNow(user.last_message_time ?? ''));
452
347
  // @ts-ignore
@@ -465,10 +360,10 @@ var __VLS_20;
465
360
  /** @type {__VLS_StyleScopedClasses['flex']} */ ;
466
361
  /** @type {__VLS_StyleScopedClasses['gap-2']} */ ;
467
362
  /** @type {__VLS_StyleScopedClasses['mb-4']} */ ;
468
- /** @type {__VLS_StyleScopedClasses['h-[45px]']} */ ;
363
+ /** @type {__VLS_StyleScopedClasses['h-11']} */ ;
469
364
  /** @type {__VLS_StyleScopedClasses['grow']} */ ;
470
- /** @type {__VLS_StyleScopedClasses['h-[45px]']} */ ;
471
- /** @type {__VLS_StyleScopedClasses['w-[45px]']} */ ;
365
+ /** @type {__VLS_StyleScopedClasses['h-11']} */ ;
366
+ /** @type {__VLS_StyleScopedClasses['w-11']} */ ;
472
367
  /** @type {__VLS_StyleScopedClasses['rounded-full']} */ ;
473
368
  /** @type {__VLS_StyleScopedClasses['flex-center']} */ ;
474
369
  /** @type {__VLS_StyleScopedClasses['bg-[#C7DEFF]']} */ ;
@@ -500,8 +395,11 @@ var __VLS_20;
500
395
  /** @type {__VLS_StyleScopedClasses['truncate']} */ ;
501
396
  /** @type {__VLS_StyleScopedClasses['flex']} */ ;
502
397
  /** @type {__VLS_StyleScopedClasses['items-center']} */ ;
398
+ /** @type {__VLS_StyleScopedClasses['text-left']} */ ;
399
+ /** @type {__VLS_StyleScopedClasses['truncate']} */ ;
503
400
  /** @type {__VLS_StyleScopedClasses['font-semibold']} */ ;
504
401
  /** @type {__VLS_StyleScopedClasses['ml-2']} */ ;
402
+ /** @type {__VLS_StyleScopedClasses['shrink-0']} */ ;
505
403
  /** @type {__VLS_StyleScopedClasses['ml-2']} */ ;
506
404
  /** @type {__VLS_StyleScopedClasses['bg-[#E60000]']} */ ;
507
405
  /** @type {__VLS_StyleScopedClasses['text-white']} */ ;
@@ -515,6 +413,7 @@ var __VLS_20;
515
413
  /** @type {__VLS_StyleScopedClasses['truncate']} */ ;
516
414
  /** @type {__VLS_StyleScopedClasses['font-semibold']} */ ;
517
415
  /** @type {__VLS_StyleScopedClasses['text-chat-gray-3']} */ ;
416
+ /** @type {__VLS_StyleScopedClasses['shrink-0']} */ ;
518
417
  /** @type {__VLS_StyleScopedClasses['text-sm']} */ ;
519
418
  /** @type {__VLS_StyleScopedClasses['text-right']} */ ;
520
419
  /** @type {__VLS_StyleScopedClasses['text-chat-gray-4']} */ ;
@@ -115,7 +115,6 @@ for (const [item, index] of __VLS_getVForSourceType((__VLS_ctx.message))) {
115
115
  ...{ 'onCallAgain': {} },
116
116
  message: (item),
117
117
  index: (index),
118
- listMessage: (__VLS_ctx.message),
119
118
  responsive: (__VLS_ctx.responsive),
120
119
  isMyMessage: (item.sender_id == __VLS_ctx.dataProfile?.id),
121
120
  data: (__VLS_ctx.data),
@@ -128,7 +127,6 @@ for (const [item, index] of __VLS_getVForSourceType((__VLS_ctx.message))) {
128
127
  ...{ 'onCallAgain': {} },
129
128
  message: (item),
130
129
  index: (index),
131
- listMessage: (__VLS_ctx.message),
132
130
  responsive: (__VLS_ctx.responsive),
133
131
  isMyMessage: (item.sender_id == __VLS_ctx.dataProfile?.id),
134
132
  data: (__VLS_ctx.data),
@@ -143,7 +141,7 @@ for (const [item, index] of __VLS_getVForSourceType((__VLS_ctx.message))) {
143
141
  { onCallAgain: (...[$event]) => {
144
142
  __VLS_ctx.emit('callBack');
145
143
  // @ts-ignore
146
- [data, message, message, responsive, dataProfile, shouldShowAvatar, isEndMessage, isChatFinished, emit,];
144
+ [data, message, responsive, dataProfile, shouldShowAvatar, isEndMessage, isChatFinished, emit,];
147
145
  } });
148
146
  var __VLS_15;
149
147
  }
@@ -127,7 +127,7 @@ if (__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending) {
127
127
  }
128
128
  }
129
129
  __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
130
- ...{ class: "px-3 py-2 rounded-2xl max-w-xs" },
130
+ ...{ class: "px-3 py-2 rounded-2xl max-w-xs text-left" },
131
131
  ...{ class: ({
132
132
  'rounded-tl-none': !__VLS_ctx.shouldShowAvatar && !__VLS_ctx.isMyMessage,
133
133
  'rounded-bl-none': !__VLS_ctx.isEndMessage && !__VLS_ctx.isMyMessage,
@@ -135,7 +135,7 @@ if (__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending) {
135
135
  'rounded-br-none': !__VLS_ctx.isEndMessage && __VLS_ctx.isMyMessage,
136
136
  '!text-[#14532D] !bg-[#d4f8d4]': __VLS_ctx.message.message_uuid && !__VLS_ctx.message.is_call,
137
137
  'bg-[#D0DFEC] text-[#266699]': __VLS_ctx.isMyMessage,
138
- 'bg-[#E4E4E4D4] text-chat-haze-600 text-left w-max ': !__VLS_ctx.isMyMessage
138
+ 'bg-[#E4E4E4D4] text-chat-haze-600 w-max ': !__VLS_ctx.isMyMessage
139
139
  }) },
140
140
  });
141
141
  // @ts-ignore
@@ -277,6 +277,7 @@ if (__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending) {
277
277
  /** @type {__VLS_StyleScopedClasses['py-2']} */ ;
278
278
  /** @type {__VLS_StyleScopedClasses['rounded-2xl']} */ ;
279
279
  /** @type {__VLS_StyleScopedClasses['max-w-xs']} */ ;
280
+ /** @type {__VLS_StyleScopedClasses['text-left']} */ ;
280
281
  /** @type {__VLS_StyleScopedClasses['rounded-tl-none']} */ ;
281
282
  /** @type {__VLS_StyleScopedClasses['rounded-bl-none']} */ ;
282
283
  /** @type {__VLS_StyleScopedClasses['rounded-tr-none']} */ ;
@@ -287,7 +288,6 @@ if (__VLS_ctx.message.state != __VLS_ctx.MessageState.Sending) {
287
288
  /** @type {__VLS_StyleScopedClasses['text-[#266699]']} */ ;
288
289
  /** @type {__VLS_StyleScopedClasses['bg-[#E4E4E4D4]']} */ ;
289
290
  /** @type {__VLS_StyleScopedClasses['text-chat-haze-600']} */ ;
290
- /** @type {__VLS_StyleScopedClasses['text-left']} */ ;
291
291
  /** @type {__VLS_StyleScopedClasses['w-max']} */ ;
292
292
  /** @type {__VLS_StyleScopedClasses['flex']} */ ;
293
293
  /** @type {__VLS_StyleScopedClasses['flex-col']} */ ;
@@ -3,17 +3,19 @@ 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
5
  import { getDetailReceiver, getMessage, sendMessage, upLoadImage } from '../../../utils/chat/message';
6
- import { nextTick, onMounted, onUnmounted, ref, shallowRef } from 'vue';
6
+ import { computed, 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 } from '../../../constant/mqtt';
9
+ import { TOPIC_DETAIL_CHAT, TOPIC_PLIVO_SMS } from '../../../constant/mqtt';
10
10
  import { MessageState } from '../../../constant/message';
11
11
  import { publicTopicConversationUpdate } from '../../../utils/chat/conversation';
12
12
  const props = withDefaults(defineProps(), {});
13
13
  const emit = defineEmits();
14
+ const reversedList = computed(() => listMessage.value.slice().reverse());
14
15
  let page = 1;
15
16
  let pageCount = 1;
16
17
  let topic = '';
18
+ let topic_plivo_chat = '';
17
19
  const isLoading = ref(false);
18
20
  const infoUser = shallowRef(null);
19
21
  const listMessage = ref([]);
@@ -22,12 +24,13 @@ onMounted(() => { });
22
24
  onUnmounted(() => {
23
25
  handleDisconnectMqtt();
24
26
  });
25
- const showNewCustomer = ref(false);
26
27
  const handleConnectMqtt = async () => {
27
28
  try {
28
29
  await connectMqtt();
29
30
  topic = TOPIC_DETAIL_CHAT + infoUser.value?.conversation_id;
31
+ topic_plivo_chat = TOPIC_PLIVO_SMS + infoUser.value?.conversation_id;
30
32
  subscribeToTopic(topic);
33
+ subscribeToTopic(topic_plivo_chat);
31
34
  addHandleMqttMessage('chat-home', topic, mqttMessageHandler);
32
35
  }
33
36
  catch (error) {
@@ -35,15 +38,17 @@ const handleConnectMqtt = async () => {
35
38
  }
36
39
  };
37
40
  const handleDisconnectMqtt = async () => {
38
- const topic = TOPIC_DETAIL_CHAT + infoUser.value?.conversation_id;
39
41
  unsubscribeFromTopic(topic);
42
+ unsubscribeFromTopic(topic_plivo_chat);
40
43
  removeHandleMqttMessage('chat-home');
41
44
  };
42
45
  const mqttMessageHandler = (topic, message) => {
46
+ console.log(message);
43
47
  if ((infoUser.value?.id && message?.sender_id?.toString() == infoUser.value?.id?.toString())) {
44
48
  const index = listMessage.value.findIndex((item) => item.id === message?.id);
45
49
  if (index < 0) {
46
- listMessage.value.push(message);
50
+ listMessage.value.unshift(message);
51
+ // listMessage.value.push(message)
47
52
  }
48
53
  else {
49
54
  listMessage.value[index] = message;
@@ -56,7 +61,7 @@ const handleGetMessage = async (option) => {
56
61
  const id = props.receiverId;
57
62
  const params = { page: option?.resetList ? 1 : page, receiver_id: props.receiverId };
58
63
  let res = await getMessage(params);
59
- res.items = res.items.reverse();
64
+ // res.items = res.items.reverse()
60
65
  page = res._meta?.currentPage || 1;
61
66
  pageCount = res._meta?.pageCount || 1;
62
67
  if (id == props.receiverId) {
@@ -65,7 +70,8 @@ const handleGetMessage = async (option) => {
65
70
  chatMessageRef.value?.scrollBottom();
66
71
  }
67
72
  else {
68
- listMessage.value.unshift(...res.items);
73
+ listMessage.value.push(...res.items);
74
+ // listMessage.value.unshift(...res.items)
69
75
  }
70
76
  }
71
77
  }
@@ -90,6 +96,7 @@ const handleGetDetailReceiver = async (data) => {
90
96
  const res = (await getDetailReceiver(props.receiverId)) ?? null;
91
97
  if (id == props.receiverId) {
92
98
  infoUser.value = res;
99
+ handleDisconnectMqtt();
93
100
  await handleConnectMqtt();
94
101
  }
95
102
  };
@@ -119,7 +126,8 @@ const updateMessageItem = (id, data) => {
119
126
  };
120
127
  const handleSendMessage = async (data) => {
121
128
  try {
122
- listMessage.value.push({ ...data, state: MessageState.Sending });
129
+ // listMessage.value.push({ ...data, state: MessageState.Sending })
130
+ listMessage.value.unshift({ ...data, state: MessageState.Sending });
123
131
  publishMessage(topic, {
124
132
  ...data,
125
133
  state: MessageState.Sending
@@ -134,7 +142,7 @@ const handleSendMessage = async (data) => {
134
142
  const formData = new FormData();
135
143
  formData.append('message', data.message ?? '');
136
144
  formData.append('receiver_id', infoUser.value?.id ?? '');
137
- if (file_upload.length) {
145
+ if (file_upload?.length) {
138
146
  formData.append('url', file_upload[0]?.url ?? '');
139
147
  }
140
148
  await sendMessage(formData);
@@ -151,14 +159,15 @@ const handleSendMessage = async (data) => {
151
159
  : []
152
160
  });
153
161
  updateMessageItem(data.id, { state: MessageState.Sent });
162
+ chatMessageRef.value?.scrollBottom();
154
163
  publicTopicConversationUpdate({ message: data?.message ?? '', isSendImg: !!file_upload?.length, infoUser: infoUser.value });
155
164
  }
156
165
  catch (error) {
166
+ console.log(error);
157
167
  updateMessageItem(data.id, {
158
168
  state: MessageState.Failed,
159
169
  error: typeof error?.message == 'string' ? error.message : ''
160
170
  });
161
- console.log(error.message);
162
171
  }
163
172
  };
164
173
  const handleUploadImage = async (file) => {
@@ -223,7 +232,7 @@ if (__VLS_ctx.listMessage?.length) {
223
232
  ...{ 'onCallBack': {} },
224
233
  ref: "chatMessageRef",
225
234
  data: (__VLS_ctx.infoUser),
226
- message: (__VLS_ctx.listMessage),
235
+ message: (__VLS_ctx.reversedList),
227
236
  ...{ class: "grow" },
228
237
  responsive: (__VLS_ctx.responsive),
229
238
  showNewCustomer: (__VLS_ctx.page >= __VLS_ctx.pageCount),
@@ -233,7 +242,7 @@ if (__VLS_ctx.listMessage?.length) {
233
242
  ...{ 'onCallBack': {} },
234
243
  ref: "chatMessageRef",
235
244
  data: (__VLS_ctx.infoUser),
236
- message: (__VLS_ctx.listMessage),
245
+ message: (__VLS_ctx.reversedList),
237
246
  ...{ class: "grow" },
238
247
  responsive: (__VLS_ctx.responsive),
239
248
  showNewCustomer: (__VLS_ctx.page >= __VLS_ctx.pageCount),
@@ -247,7 +256,7 @@ if (__VLS_ctx.listMessage?.length) {
247
256
  /** @type {typeof __VLS_ctx.chatMessageRef} */ ;
248
257
  var __VLS_14 = {};
249
258
  // @ts-ignore
250
- [infoUser, call, listMessage, responsive, page, pageCount, handleScrollTop, chatMessageRef,];
259
+ [infoUser, call, reversedList, responsive, page, pageCount, handleScrollTop, chatMessageRef,];
251
260
  var __VLS_9;
252
261
  }
253
262
  else if (!__VLS_ctx.isLoading) {
@@ -275,11 +284,13 @@ else {
275
284
  // @ts-ignore
276
285
  const __VLS_21 = __VLS_asFunctionalComponent(InputChat, new InputChat({
277
286
  ...{ 'onSendMessage': {} },
287
+ ...{ 'onFocus': {} },
278
288
  data: (__VLS_ctx.infoUser),
279
289
  ...{ class: "p-6" },
280
290
  }));
281
291
  const __VLS_22 = __VLS_21({
282
292
  ...{ 'onSendMessage': {} },
293
+ ...{ 'onFocus': {} },
283
294
  data: (__VLS_ctx.infoUser),
284
295
  ...{ class: "p-6" },
285
296
  }, ...__VLS_functionalComponentArgsRest(__VLS_21));
@@ -287,8 +298,12 @@ let __VLS_24;
287
298
  let __VLS_25;
288
299
  const __VLS_26 = ({ sendMessage: {} },
289
300
  { onSendMessage: (__VLS_ctx.handleSendMessage) });
290
- // @ts-ignore
291
- [infoUser, handleSendMessage,];
301
+ const __VLS_27 = ({ focus: {} },
302
+ { onFocus: (...[$event]) => {
303
+ __VLS_ctx.emit('inputFocus');
304
+ // @ts-ignore
305
+ [infoUser, handleSendMessage, emit,];
306
+ } });
292
307
  var __VLS_23;
293
308
  /** @type {__VLS_StyleScopedClasses['h-full']} */ ;
294
309
  /** @type {__VLS_StyleScopedClasses['flex']} */ ;
@@ -8,6 +8,8 @@ import { dataProfile } from '../../../utils/chat/auth';
8
8
  import { computed, ref } from 'vue';
9
9
  import PopoverBase from '../../../components/chat/common/popover/PopoverBase.vue';
10
10
  import SwitchBase from '../../../components/chat/common/switch/SwitchBase.vue';
11
+ import { activePlivoMode } from '../../../utils/chat/message';
12
+ import BaseSpin from '../../../components/chat/common/spin/BaseSpin.vue';
11
13
  const props = withDefaults(defineProps(), {});
12
14
  const emit = defineEmits();
13
15
  const ChatModeOptions = [
@@ -19,6 +21,8 @@ const keyword = defineModel();
19
21
  let chatId = 1;
20
22
  const refInputImage = ref(null);
21
23
  const isLoadingImage = ref([]);
24
+ const activePlivoSms = ref(false);
25
+ const loading = ref(false);
22
26
  const chatInputRef = ref(null);
23
27
  const emojiOpen = ref(false);
24
28
  const mode = ref('0');
@@ -70,6 +74,20 @@ const onSelectEmoji = (value) => {
70
74
  emojiOpen.value = false;
71
75
  chatInputRef.value?.focus?.();
72
76
  };
77
+ const handleActivePlivoSmsChange = async (is_active) => {
78
+ try {
79
+ loading.value = true;
80
+ await activePlivoMode({ id: dataProfile.value?.id, is_sms: is_active ? 1 : 0 });
81
+ }
82
+ catch (e) {
83
+ activePlivoSms.value = !is_active;
84
+ console.log(e);
85
+ }
86
+ loading.value = false;
87
+ };
88
+ const handleInput = () => {
89
+ emit('focus');
90
+ };
73
91
  debugger; /* PartiallyEnd: #3632/scriptSetup.vue */
74
92
  const __VLS_modelEmit = defineEmits();
75
93
  const __VLS_defaults = {};
@@ -91,16 +109,41 @@ if (__VLS_ctx.dataProfile?.user_type == 'tenant') {
91
109
  // @ts-ignore
92
110
  [dataProfile,];
93
111
  __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
94
- ...{ class: "mb-2" },
112
+ ...{ class: "flex gap-2 mb-2" },
95
113
  });
96
114
  /** @type {[typeof SwitchBase, ]} */ ;
97
115
  // @ts-ignore
98
116
  const __VLS_0 = __VLS_asFunctionalComponent(SwitchBase, new SwitchBase({
117
+ ...{ 'onChange': {} },
118
+ modelValue: (__VLS_ctx.activePlivoSms),
99
119
  label: "Active sms",
100
120
  }));
101
121
  const __VLS_1 = __VLS_0({
122
+ ...{ 'onChange': {} },
123
+ modelValue: (__VLS_ctx.activePlivoSms),
102
124
  label: "Active sms",
103
125
  }, ...__VLS_functionalComponentArgsRest(__VLS_0));
126
+ let __VLS_3;
127
+ let __VLS_4;
128
+ const __VLS_5 = ({ change: {} },
129
+ { onChange: (__VLS_ctx.handleActivePlivoSmsChange) });
130
+ // @ts-ignore
131
+ [activePlivoSms, handleActivePlivoSmsChange,];
132
+ var __VLS_2;
133
+ if (__VLS_ctx.loading) {
134
+ // @ts-ignore
135
+ [loading,];
136
+ /** @type {[typeof BaseSpin, ]} */ ;
137
+ // @ts-ignore
138
+ const __VLS_7 = __VLS_asFunctionalComponent(BaseSpin, new BaseSpin({
139
+ size: (24),
140
+ border: (3),
141
+ }));
142
+ const __VLS_8 = __VLS_7({
143
+ size: (24),
144
+ border: (3),
145
+ }, ...__VLS_functionalComponentArgsRest(__VLS_7));
146
+ }
104
147
  }
105
148
  __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
106
149
  ...{ class: "flex gap-2" },
@@ -114,6 +157,11 @@ __VLS_asFunctionalElement(__VLS_elements.input)({
114
157
  // @ts-ignore
115
158
  [handleSendMessage,];
116
159
  } },
160
+ ...{ onFocus: (...[$event]) => {
161
+ __VLS_ctx.handleInput();
162
+ // @ts-ignore
163
+ [handleInput,];
164
+ } },
117
165
  ...{ class: "w-full chat-input !rounded-xl h-11 px-4 border border-chat-haze-200" },
118
166
  ref: "chatInputRef",
119
167
  placeholder: "Send Message",
@@ -127,17 +175,17 @@ __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
127
175
  });
128
176
  /** @type {[typeof PopoverBase, typeof PopoverBase, ]} */ ;
129
177
  // @ts-ignore
130
- const __VLS_4 = __VLS_asFunctionalComponent(PopoverBase, new PopoverBase({
178
+ const __VLS_11 = __VLS_asFunctionalComponent(PopoverBase, new PopoverBase({
131
179
  open: (__VLS_ctx.emojiOpen),
132
180
  align: "end",
133
181
  side: "top",
134
182
  }));
135
- const __VLS_5 = __VLS_4({
183
+ const __VLS_12 = __VLS_11({
136
184
  open: (__VLS_ctx.emojiOpen),
137
185
  align: "end",
138
186
  side: "top",
139
- }, ...__VLS_functionalComponentArgsRest(__VLS_4));
140
- const { default: __VLS_7 } = __VLS_6.slots;
187
+ }, ...__VLS_functionalComponentArgsRest(__VLS_11));
188
+ const { default: __VLS_14 } = __VLS_13.slots;
141
189
  // @ts-ignore
142
190
  [emojiOpen,];
143
191
  __VLS_asFunctionalElement(__VLS_elements.button, __VLS_elements.button)({
@@ -149,61 +197,61 @@ __VLS_asFunctionalElement(__VLS_elements.button, __VLS_elements.button)({
149
197
  ...{ class: "h-11 w-10" },
150
198
  });
151
199
  {
152
- const { content: __VLS_8 } = __VLS_6.slots;
153
- const __VLS_9 = {}.EmojiPicker;
200
+ const { content: __VLS_15 } = __VLS_13.slots;
201
+ const __VLS_16 = {}.EmojiPicker;
154
202
  /** @type {[typeof __VLS_components.EmojiPicker, typeof __VLS_components.emojiPicker, ]} */ ;
155
203
  // @ts-ignore
156
204
  EmojiPicker;
157
205
  // @ts-ignore
158
- const __VLS_10 = __VLS_asFunctionalComponent(__VLS_9, new __VLS_9({
206
+ const __VLS_17 = __VLS_asFunctionalComponent(__VLS_16, new __VLS_16({
159
207
  ...{ 'onSelect': {} },
160
208
  ...{ class: "!w-[300px]" },
161
209
  native: (true),
162
210
  offset: (2),
163
211
  hideSearch: true,
164
212
  }));
165
- const __VLS_11 = __VLS_10({
213
+ const __VLS_18 = __VLS_17({
166
214
  ...{ 'onSelect': {} },
167
215
  ...{ class: "!w-[300px]" },
168
216
  native: (true),
169
217
  offset: (2),
170
218
  hideSearch: true,
171
- }, ...__VLS_functionalComponentArgsRest(__VLS_10));
172
- let __VLS_13;
173
- let __VLS_14;
174
- const __VLS_15 = ({ select: {} },
219
+ }, ...__VLS_functionalComponentArgsRest(__VLS_17));
220
+ let __VLS_20;
221
+ let __VLS_21;
222
+ const __VLS_22 = ({ select: {} },
175
223
  { onSelect: (__VLS_ctx.onSelectEmoji) });
176
224
  // @ts-ignore
177
225
  [onSelectEmoji,];
178
- var __VLS_12;
226
+ var __VLS_19;
179
227
  }
180
- var __VLS_6;
181
- const __VLS_17 = {}.EmojiPicker;
228
+ var __VLS_13;
229
+ const __VLS_24 = {}.EmojiPicker;
182
230
  /** @type {[typeof __VLS_components.EmojiPicker, typeof __VLS_components.emojiPicker, ]} */ ;
183
231
  // @ts-ignore
184
232
  EmojiPicker;
185
233
  // @ts-ignore
186
- const __VLS_18 = __VLS_asFunctionalComponent(__VLS_17, new __VLS_17({
234
+ const __VLS_25 = __VLS_asFunctionalComponent(__VLS_24, new __VLS_24({
187
235
  ...{ 'onSelect': {} },
188
236
  ...{ class: "opacity-0 pointer-events-none absolute" },
189
237
  native: (true),
190
238
  offset: (2),
191
239
  hideSearch: true,
192
240
  }));
193
- const __VLS_19 = __VLS_18({
241
+ const __VLS_26 = __VLS_25({
194
242
  ...{ 'onSelect': {} },
195
243
  ...{ class: "opacity-0 pointer-events-none absolute" },
196
244
  native: (true),
197
245
  offset: (2),
198
246
  hideSearch: true,
199
- }, ...__VLS_functionalComponentArgsRest(__VLS_18));
200
- let __VLS_21;
201
- let __VLS_22;
202
- const __VLS_23 = ({ select: {} },
247
+ }, ...__VLS_functionalComponentArgsRest(__VLS_25));
248
+ let __VLS_28;
249
+ let __VLS_29;
250
+ const __VLS_30 = ({ select: {} },
203
251
  { onSelect: (__VLS_ctx.onSelectEmoji) });
204
252
  // @ts-ignore
205
253
  [onSelectEmoji,];
206
- var __VLS_20;
254
+ var __VLS_27;
207
255
  __VLS_asFunctionalElement(__VLS_elements.button, __VLS_elements.button)({
208
256
  ...{ onClick: (...[$event]) => {
209
257
  __VLS_ctx.handleSendMessage('message');
@@ -214,8 +262,8 @@ __VLS_asFunctionalElement(__VLS_elements.button, __VLS_elements.button)({
214
262
  });
215
263
  /** @type {[typeof IconPlan, ]} */ ;
216
264
  // @ts-ignore
217
- const __VLS_25 = __VLS_asFunctionalComponent(IconPlan, new IconPlan({}));
218
- const __VLS_26 = __VLS_25({}, ...__VLS_functionalComponentArgsRest(__VLS_25));
265
+ const __VLS_32 = __VLS_asFunctionalComponent(IconPlan, new IconPlan({}));
266
+ const __VLS_33 = __VLS_32({}, ...__VLS_functionalComponentArgsRest(__VLS_32));
219
267
  __VLS_asFunctionalElement(__VLS_elements.label, __VLS_elements.label)({
220
268
  ...{ class: "shrink-0 cursor-pointer relative" },
221
269
  });
@@ -234,13 +282,15 @@ __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
234
282
  });
235
283
  /** @type {[typeof IconPlus, ]} */ ;
236
284
  // @ts-ignore
237
- const __VLS_29 = __VLS_asFunctionalComponent(IconPlus, new IconPlus({
285
+ const __VLS_36 = __VLS_asFunctionalComponent(IconPlus, new IconPlus({
238
286
  ...{ class: "text-white" },
239
287
  }));
240
- const __VLS_30 = __VLS_29({
288
+ const __VLS_37 = __VLS_36({
241
289
  ...{ class: "text-white" },
242
- }, ...__VLS_functionalComponentArgsRest(__VLS_29));
290
+ }, ...__VLS_functionalComponentArgsRest(__VLS_36));
243
291
  /** @type {__VLS_StyleScopedClasses['z-10']} */ ;
292
+ /** @type {__VLS_StyleScopedClasses['flex']} */ ;
293
+ /** @type {__VLS_StyleScopedClasses['gap-2']} */ ;
244
294
  /** @type {__VLS_StyleScopedClasses['mb-2']} */ ;
245
295
  /** @type {__VLS_StyleScopedClasses['flex']} */ ;
246
296
  /** @type {__VLS_StyleScopedClasses['gap-2']} */ ;