@phonghq/go-chat 1.0.9 → 1.0.10

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.
@@ -2,7 +2,7 @@
2
2
  import ChatList from '../chat/page/home/ChatList.vue';
3
3
  import HomeComponent from '../chat/page/home/Home.vue';
4
4
  import IconArrowLeft from '../assets/icons/IconArrowLeft.vue';
5
- import { computed, nextTick, ref } from 'vue';
5
+ import { computed, nextTick, onMounted, onUnmounted, ref } from 'vue';
6
6
  import { PAGE } from '../constant/general';
7
7
  import CustomerDetail from '../chat/page/customer-detail/CustomerDetail.vue';
8
8
  import CustomerCheckIn from '../chat/page/customer-check-in/CustomerCheckIn.vue';
@@ -15,7 +15,8 @@ import Calling from '../components/chat/call/Calling.vue';
15
15
  import { logout } from '../utils/chat/auth';
16
16
  import MobileFooter from '../components/chat/layout/mobile/Footer.vue';
17
17
  import { initWebSocket } from '../plugins/websocket';
18
- import "../style/index.scss";
18
+ import '../style/index.scss';
19
+ import { useDebounce } from '../utils/debounce';
19
20
  const routerConfig = [
20
21
  { id: PAGE.HOME, backFunc: null, backTitle: '' },
21
22
  {
@@ -33,8 +34,16 @@ const routerConfig = [
33
34
  backTitle: 'Appointments'
34
35
  }
35
36
  ];
36
- const routerMobileConfig = [
37
- { id: PAGE.CHAT_LIST, backFunc: logout, backTitle: 'ChatBiz' },
37
+ const routerMobileConfig = computed(() => [
38
+ {
39
+ id: PAGE.CHAT_LIST,
40
+ backFunc: props.isLib
41
+ ? undefined
42
+ : () => {
43
+ logout();
44
+ },
45
+ backTitle: 'ChatBiz'
46
+ },
38
47
  {
39
48
  id: PAGE.HOME,
40
49
  backFunc: () => {
@@ -56,17 +65,29 @@ const routerMobileConfig = [
56
65
  },
57
66
  backTitle: 'Appointments'
58
67
  }
59
- ];
68
+ ]);
60
69
  const props = withDefaults(defineProps(), {
61
70
  response: 'tablet'
62
71
  });
63
72
  const { initPage } = useInitData();
73
+ onMounted(() => {
74
+ getResponsiveObserver();
75
+ window.addEventListener('resize', getResponsiveObserver);
76
+ });
77
+ onUnmounted(() => {
78
+ window.removeEventListener('resize', getResponsiveObserver);
79
+ });
64
80
  const currentPageConfig = computed(() => {
65
- if (props.response === 'mobile') {
66
- return routerMobileConfig.find((e) => e.id == currentPage.value);
81
+ if (responsiveRender.value === 'mobile') {
82
+ return routerMobileConfig.value.find((e) => e.id == currentPage.value);
67
83
  }
68
84
  return routerConfig.find((e) => e.id == currentPage.value);
69
85
  });
86
+ const responsiveRender = computed(() => {
87
+ return props.response == 'mobile' ? props.response : responsiveObserver.value;
88
+ });
89
+ const responsiveObserver = ref('tablet');
90
+ const appChatRef = ref();
70
91
  const callingRef = ref(null);
71
92
  const receiverId = ref(null);
72
93
  const customerDetailRef = ref(null);
@@ -86,6 +107,25 @@ const selectReceiver = async (data) => {
86
107
  const handleCall = (user) => {
87
108
  callingRef.value?.startCall(user);
88
109
  };
110
+ const getResponsiveObserver = useDebounce(() => {
111
+ // const div = document.getElementById('appChatMain')
112
+ if (!appChatRef.value)
113
+ return;
114
+ const width = appChatRef.value?.offsetWidth ?? 0;
115
+ if (width >= 640) {
116
+ if (responsiveObserver.value != 'tablet') {
117
+ responsiveObserver.value = 'tablet';
118
+ }
119
+ }
120
+ else {
121
+ if (responsiveObserver.value != 'mobile') {
122
+ if (currentPage.value == PAGE.HOME) {
123
+ currentPage.value = PAGE.CHAT_LIST;
124
+ }
125
+ responsiveObserver.value = 'mobile';
126
+ }
127
+ }
128
+ }, 50);
89
129
  initWebSocket('https://web-socket.dev01.dtsmart.dev');
90
130
  initPage({ id: props.id, domain: props.domain, token: props.token, response: props.response });
91
131
  debugger; /* PartiallyEnd: #3632/scriptSetup.vue */
@@ -102,8 +142,13 @@ let __VLS_elements;
102
142
  let __VLS_components;
103
143
  let __VLS_directives;
104
144
  __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
105
- ...{ class: "go-chat-main p-8" },
145
+ ...{ class: "go-chat-main max-w-full p-8" },
146
+ id: "appChatMain",
147
+ ref: "appChatRef",
106
148
  });
149
+ /** @type {typeof __VLS_ctx.appChatRef} */ ;
150
+ // @ts-ignore
151
+ [appChatRef,];
107
152
  if (!__VLS_ctx.isRouterReady) {
108
153
  // @ts-ignore
109
154
  [isRouterReady,];
@@ -123,12 +168,27 @@ else if (__VLS_ctx.currentPage == __VLS_ctx.PAGE.TENANT_ERROR) {
123
168
  const __VLS_4 = __VLS_asFunctionalComponent(Error, new Error({}));
124
169
  const __VLS_5 = __VLS_4({}, ...__VLS_functionalComponentArgsRest(__VLS_4));
125
170
  }
126
- else if (__VLS_ctx.response == 'mobile') {
171
+ else if (__VLS_ctx.responsiveRender == 'mobile') {
127
172
  // @ts-ignore
128
- [response,];
173
+ [responsiveRender,];
129
174
  __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
130
175
  ...{ class: "relative flex flex-col mx-auto w-max max-w-[350px] h-full bg-[#F9FAFC] overflow-hidden chat-mobile pt-4" },
131
176
  });
177
+ /** @type {[typeof Calling, ]} */ ;
178
+ // @ts-ignore
179
+ const __VLS_8 = __VLS_asFunctionalComponent(Calling, new Calling({
180
+ ref: "callingRef",
181
+ responsive: (__VLS_ctx.responsiveRender),
182
+ }));
183
+ const __VLS_9 = __VLS_8({
184
+ ref: "callingRef",
185
+ responsive: (__VLS_ctx.responsiveRender),
186
+ }, ...__VLS_functionalComponentArgsRest(__VLS_8));
187
+ /** @type {typeof __VLS_ctx.callingRef} */ ;
188
+ var __VLS_11 = {};
189
+ // @ts-ignore
190
+ [responsiveRender, callingRef,];
191
+ var __VLS_10;
132
192
  if (__VLS_ctx.currentPageConfig?.backFunc) {
133
193
  // @ts-ignore
134
194
  [currentPageConfig,];
@@ -141,7 +201,7 @@ else if (__VLS_ctx.response == 'mobile') {
141
201
  return;
142
202
  if (!!(__VLS_ctx.currentPage == __VLS_ctx.PAGE.TENANT_ERROR))
143
203
  return;
144
- if (!(__VLS_ctx.response == 'mobile'))
204
+ if (!(__VLS_ctx.responsiveRender == 'mobile'))
145
205
  return;
146
206
  if (!(__VLS_ctx.currentPageConfig?.backFunc))
147
207
  return;
@@ -153,8 +213,8 @@ else if (__VLS_ctx.response == 'mobile') {
153
213
  });
154
214
  /** @type {[typeof IconArrowLeft, ]} */ ;
155
215
  // @ts-ignore
156
- const __VLS_8 = __VLS_asFunctionalComponent(IconArrowLeft, new IconArrowLeft({}));
157
- const __VLS_9 = __VLS_8({}, ...__VLS_functionalComponentArgsRest(__VLS_8));
216
+ const __VLS_14 = __VLS_asFunctionalComponent(IconArrowLeft, new IconArrowLeft({}));
217
+ const __VLS_15 = __VLS_14({}, ...__VLS_functionalComponentArgsRest(__VLS_14));
158
218
  __VLS_asFunctionalElement(__VLS_elements.span, __VLS_elements.span)({
159
219
  ...{ class: "text-xl font-semibold text-chat-haze-900 ml-3" },
160
220
  });
@@ -167,145 +227,145 @@ else if (__VLS_ctx.response == 'mobile') {
167
227
  });
168
228
  /** @type {[typeof ChatList, ]} */ ;
169
229
  // @ts-ignore
170
- const __VLS_12 = __VLS_asFunctionalComponent(ChatList, new ChatList({
230
+ const __VLS_18 = __VLS_asFunctionalComponent(ChatList, new ChatList({
171
231
  ...{ 'onSelectReceiver': {} },
172
232
  ref: "chatListRef",
173
233
  ...{ class: "w-full max-w-[500px] !bg-[#F9FAFC]" },
174
- response: (__VLS_ctx.response),
234
+ response: (__VLS_ctx.responsiveRender),
175
235
  receiverId: (__VLS_ctx.receiverId),
176
236
  }));
177
- const __VLS_13 = __VLS_12({
237
+ const __VLS_19 = __VLS_18({
178
238
  ...{ 'onSelectReceiver': {} },
179
239
  ref: "chatListRef",
180
240
  ...{ class: "w-full max-w-[500px] !bg-[#F9FAFC]" },
181
- response: (__VLS_ctx.response),
241
+ response: (__VLS_ctx.responsiveRender),
182
242
  receiverId: (__VLS_ctx.receiverId),
183
- }, ...__VLS_functionalComponentArgsRest(__VLS_12));
184
- let __VLS_15;
185
- let __VLS_16;
186
- const __VLS_17 = ({ selectReceiver: {} },
243
+ }, ...__VLS_functionalComponentArgsRest(__VLS_18));
244
+ let __VLS_21;
245
+ let __VLS_22;
246
+ const __VLS_23 = ({ selectReceiver: {} },
187
247
  { onSelectReceiver: (__VLS_ctx.selectReceiver) });
188
248
  __VLS_asFunctionalDirective(__VLS_directives.vShow)(null, { ...__VLS_directiveBindingRestFields, value: (__VLS_ctx.currentPage == __VLS_ctx.PAGE.CHAT_LIST) }, null, null);
189
249
  /** @type {typeof __VLS_ctx.chatListRef} */ ;
190
- var __VLS_18 = {};
250
+ var __VLS_24 = {};
191
251
  // @ts-ignore
192
- [currentPage, PAGE, response, receiverId, selectReceiver, chatListRef,];
193
- var __VLS_14;
252
+ [currentPage, PAGE, responsiveRender, receiverId, selectReceiver, chatListRef,];
253
+ var __VLS_20;
194
254
  /** @type {[typeof HomeComponent, ]} */ ;
195
255
  // @ts-ignore
196
- const __VLS_21 = __VLS_asFunctionalComponent(HomeComponent, new HomeComponent({
256
+ const __VLS_27 = __VLS_asFunctionalComponent(HomeComponent, new HomeComponent({
197
257
  ...{ 'onCall': {} },
198
258
  ref: "homeComponentRef",
199
259
  receiverId: (__VLS_ctx.receiverId),
200
260
  ...{ class: "h-full pt-4" },
201
- response: (__VLS_ctx.response),
261
+ response: (__VLS_ctx.responsiveRender),
202
262
  }));
203
- const __VLS_22 = __VLS_21({
263
+ const __VLS_28 = __VLS_27({
204
264
  ...{ 'onCall': {} },
205
265
  ref: "homeComponentRef",
206
266
  receiverId: (__VLS_ctx.receiverId),
207
267
  ...{ class: "h-full pt-4" },
208
- response: (__VLS_ctx.response),
209
- }, ...__VLS_functionalComponentArgsRest(__VLS_21));
210
- let __VLS_24;
211
- let __VLS_25;
212
- const __VLS_26 = ({ call: {} },
268
+ response: (__VLS_ctx.responsiveRender),
269
+ }, ...__VLS_functionalComponentArgsRest(__VLS_27));
270
+ let __VLS_30;
271
+ let __VLS_31;
272
+ const __VLS_32 = ({ call: {} },
213
273
  { onCall: (__VLS_ctx.handleCall) });
214
274
  __VLS_asFunctionalDirective(__VLS_directives.vShow)(null, { ...__VLS_directiveBindingRestFields, value: (__VLS_ctx.currentPage == __VLS_ctx.PAGE.HOME) }, null, null);
215
275
  /** @type {typeof __VLS_ctx.homeComponentRef} */ ;
216
- var __VLS_27 = {};
276
+ var __VLS_33 = {};
217
277
  // @ts-ignore
218
- [currentPage, PAGE, response, receiverId, handleCall, homeComponentRef,];
219
- var __VLS_23;
278
+ [currentPage, PAGE, responsiveRender, receiverId, handleCall, homeComponentRef,];
279
+ var __VLS_29;
220
280
  if (__VLS_ctx.currentPage == __VLS_ctx.PAGE.CUSTOMER_DETAIL) {
221
281
  // @ts-ignore
222
282
  [currentPage, PAGE,];
223
283
  /** @type {[typeof CustomerDetail, ]} */ ;
224
284
  // @ts-ignore
225
- const __VLS_30 = __VLS_asFunctionalComponent(CustomerDetail, new CustomerDetail({
285
+ const __VLS_36 = __VLS_asFunctionalComponent(CustomerDetail, new CustomerDetail({
226
286
  ref: "customerDetailRef",
227
287
  receiverId: (__VLS_ctx.receiverId),
228
288
  ...{ class: "h-full" },
229
- response: (__VLS_ctx.response),
289
+ response: (__VLS_ctx.responsiveRender),
230
290
  }));
231
- const __VLS_31 = __VLS_30({
291
+ const __VLS_37 = __VLS_36({
232
292
  ref: "customerDetailRef",
233
293
  receiverId: (__VLS_ctx.receiverId),
234
294
  ...{ class: "h-full" },
235
- response: (__VLS_ctx.response),
236
- }, ...__VLS_functionalComponentArgsRest(__VLS_30));
295
+ response: (__VLS_ctx.responsiveRender),
296
+ }, ...__VLS_functionalComponentArgsRest(__VLS_36));
237
297
  /** @type {typeof __VLS_ctx.customerDetailRef} */ ;
238
- var __VLS_33 = {};
298
+ var __VLS_39 = {};
239
299
  // @ts-ignore
240
- [response, receiverId, customerDetailRef,];
241
- var __VLS_32;
300
+ [responsiveRender, receiverId, customerDetailRef,];
301
+ var __VLS_38;
242
302
  }
243
303
  if (__VLS_ctx.currentPage == __VLS_ctx.PAGE.CUSTOMER_CHECK_IN) {
244
304
  // @ts-ignore
245
305
  [currentPage, PAGE,];
246
306
  /** @type {[typeof CustomerCheckIn, ]} */ ;
247
307
  // @ts-ignore
248
- const __VLS_36 = __VLS_asFunctionalComponent(CustomerCheckIn, new CustomerCheckIn({
308
+ const __VLS_42 = __VLS_asFunctionalComponent(CustomerCheckIn, new CustomerCheckIn({
249
309
  ...{ class: "h-full" },
250
310
  }));
251
- const __VLS_37 = __VLS_36({
311
+ const __VLS_43 = __VLS_42({
252
312
  ...{ class: "h-full" },
253
- }, ...__VLS_functionalComponentArgsRest(__VLS_36));
313
+ }, ...__VLS_functionalComponentArgsRest(__VLS_42));
254
314
  }
255
315
  if (__VLS_ctx.currentPage == __VLS_ctx.PAGE.CUSTOMER_APPOINTMENT) {
256
316
  // @ts-ignore
257
317
  [currentPage, PAGE,];
258
318
  /** @type {[typeof CustomerAppointment, ]} */ ;
259
319
  // @ts-ignore
260
- const __VLS_40 = __VLS_asFunctionalComponent(CustomerAppointment, new CustomerAppointment({
320
+ const __VLS_46 = __VLS_asFunctionalComponent(CustomerAppointment, new CustomerAppointment({
261
321
  ...{ class: "h-full" },
262
322
  }));
263
- const __VLS_41 = __VLS_40({
323
+ const __VLS_47 = __VLS_46({
264
324
  ...{ class: "h-full" },
265
- }, ...__VLS_functionalComponentArgsRest(__VLS_40));
325
+ }, ...__VLS_functionalComponentArgsRest(__VLS_46));
266
326
  }
267
327
  if (__VLS_ctx.currentPage != __VLS_ctx.PAGE.HOME) {
268
328
  // @ts-ignore
269
329
  [currentPage, PAGE,];
270
330
  /** @type {[typeof MobileFooter, ]} */ ;
271
331
  // @ts-ignore
272
- const __VLS_44 = __VLS_asFunctionalComponent(MobileFooter, new MobileFooter({
332
+ const __VLS_50 = __VLS_asFunctionalComponent(MobileFooter, new MobileFooter({
273
333
  ...{ class: "shrink-0" },
274
334
  }));
275
- const __VLS_45 = __VLS_44({
335
+ const __VLS_51 = __VLS_50({
276
336
  ...{ class: "shrink-0" },
277
- }, ...__VLS_functionalComponentArgsRest(__VLS_44));
337
+ }, ...__VLS_functionalComponentArgsRest(__VLS_50));
278
338
  }
279
339
  }
280
340
  else {
281
341
  __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
282
- ...{ class: "flex gap-4 h-full" },
342
+ ...{ class: "flex gap-4 h-full relative" },
283
343
  });
284
344
  /** @type {[typeof ChatList, ]} */ ;
285
345
  // @ts-ignore
286
- const __VLS_48 = __VLS_asFunctionalComponent(ChatList, new ChatList({
346
+ const __VLS_54 = __VLS_asFunctionalComponent(ChatList, new ChatList({
287
347
  ...{ 'onSelectReceiver': {} },
288
348
  ref: "chatListRef",
289
- ...{ class: "w-[38%] max-w-[500px]" },
290
- response: (__VLS_ctx.response),
349
+ ...{ class: "w-[38%] max-w-[500px] min-w-[450px]" },
350
+ response: (__VLS_ctx.responsiveRender),
291
351
  receiverId: (__VLS_ctx.receiverId),
292
352
  }));
293
- const __VLS_49 = __VLS_48({
353
+ const __VLS_55 = __VLS_54({
294
354
  ...{ 'onSelectReceiver': {} },
295
355
  ref: "chatListRef",
296
- ...{ class: "w-[38%] max-w-[500px]" },
297
- response: (__VLS_ctx.response),
356
+ ...{ class: "w-[38%] max-w-[500px] min-w-[450px]" },
357
+ response: (__VLS_ctx.responsiveRender),
298
358
  receiverId: (__VLS_ctx.receiverId),
299
- }, ...__VLS_functionalComponentArgsRest(__VLS_48));
300
- let __VLS_51;
301
- let __VLS_52;
302
- const __VLS_53 = ({ selectReceiver: {} },
359
+ }, ...__VLS_functionalComponentArgsRest(__VLS_54));
360
+ let __VLS_57;
361
+ let __VLS_58;
362
+ const __VLS_59 = ({ selectReceiver: {} },
303
363
  { onSelectReceiver: (__VLS_ctx.selectReceiver) });
304
364
  /** @type {typeof __VLS_ctx.chatListRef} */ ;
305
- var __VLS_54 = {};
365
+ var __VLS_60 = {};
306
366
  // @ts-ignore
307
- [response, receiverId, selectReceiver, chatListRef,];
308
- var __VLS_50;
367
+ [responsiveRender, receiverId, selectReceiver, chatListRef,];
368
+ var __VLS_56;
309
369
  __VLS_asFunctionalElement(__VLS_elements.div, __VLS_elements.div)({
310
370
  ...{ class: "chat-box-white grow flex flex-col h-full pt-6 overflow-hidden" },
311
371
  });
@@ -321,7 +381,7 @@ else {
321
381
  return;
322
382
  if (!!(__VLS_ctx.currentPage == __VLS_ctx.PAGE.TENANT_ERROR))
323
383
  return;
324
- if (!!(__VLS_ctx.response == 'mobile'))
384
+ if (!!(__VLS_ctx.responsiveRender == 'mobile'))
325
385
  return;
326
386
  if (!(__VLS_ctx.currentPageConfig?.backFunc))
327
387
  return;
@@ -333,8 +393,8 @@ else {
333
393
  });
334
394
  /** @type {[typeof IconArrowLeft, ]} */ ;
335
395
  // @ts-ignore
336
- const __VLS_57 = __VLS_asFunctionalComponent(IconArrowLeft, new IconArrowLeft({}));
337
- const __VLS_58 = __VLS_57({}, ...__VLS_functionalComponentArgsRest(__VLS_57));
396
+ const __VLS_63 = __VLS_asFunctionalComponent(IconArrowLeft, new IconArrowLeft({}));
397
+ const __VLS_64 = __VLS_63({}, ...__VLS_functionalComponentArgsRest(__VLS_63));
338
398
  __VLS_asFunctionalElement(__VLS_elements.span, __VLS_elements.span)({
339
399
  ...{ class: "text-xl font-semibold text-chat-haze-900 ml-3" },
340
400
  });
@@ -347,92 +407,95 @@ else {
347
407
  });
348
408
  /** @type {[typeof HomeComponent, ]} */ ;
349
409
  // @ts-ignore
350
- const __VLS_61 = __VLS_asFunctionalComponent(HomeComponent, new HomeComponent({
410
+ const __VLS_67 = __VLS_asFunctionalComponent(HomeComponent, new HomeComponent({
351
411
  ...{ 'onCall': {} },
352
412
  ref: "homeComponentRef",
353
413
  receiverId: (__VLS_ctx.receiverId),
354
414
  ...{ class: "h-full" },
355
- response: (__VLS_ctx.response),
415
+ response: (__VLS_ctx.responsiveRender),
356
416
  }));
357
- const __VLS_62 = __VLS_61({
417
+ const __VLS_68 = __VLS_67({
358
418
  ...{ 'onCall': {} },
359
419
  ref: "homeComponentRef",
360
420
  receiverId: (__VLS_ctx.receiverId),
361
421
  ...{ class: "h-full" },
362
- response: (__VLS_ctx.response),
363
- }, ...__VLS_functionalComponentArgsRest(__VLS_61));
364
- let __VLS_64;
365
- let __VLS_65;
366
- const __VLS_66 = ({ call: {} },
422
+ response: (__VLS_ctx.responsiveRender),
423
+ }, ...__VLS_functionalComponentArgsRest(__VLS_67));
424
+ let __VLS_70;
425
+ let __VLS_71;
426
+ const __VLS_72 = ({ call: {} },
367
427
  { onCall: (__VLS_ctx.handleCall) });
368
428
  __VLS_asFunctionalDirective(__VLS_directives.vShow)(null, { ...__VLS_directiveBindingRestFields, value: (__VLS_ctx.currentPage == __VLS_ctx.PAGE.HOME) }, null, null);
369
429
  /** @type {typeof __VLS_ctx.homeComponentRef} */ ;
370
- var __VLS_67 = {};
430
+ var __VLS_73 = {};
371
431
  // @ts-ignore
372
- [currentPage, PAGE, response, receiverId, handleCall, homeComponentRef,];
373
- var __VLS_63;
432
+ [currentPage, PAGE, responsiveRender, receiverId, handleCall, homeComponentRef,];
433
+ var __VLS_69;
374
434
  if (__VLS_ctx.currentPage == __VLS_ctx.PAGE.CUSTOMER_DETAIL) {
375
435
  // @ts-ignore
376
436
  [currentPage, PAGE,];
377
437
  /** @type {[typeof CustomerDetail, ]} */ ;
378
438
  // @ts-ignore
379
- const __VLS_70 = __VLS_asFunctionalComponent(CustomerDetail, new CustomerDetail({
439
+ const __VLS_76 = __VLS_asFunctionalComponent(CustomerDetail, new CustomerDetail({
380
440
  ref: "customerDetailRef",
381
441
  receiverId: (__VLS_ctx.receiverId),
382
442
  ...{ class: "h-full" },
383
- response: (__VLS_ctx.response),
443
+ response: (__VLS_ctx.responsiveRender),
384
444
  }));
385
- const __VLS_71 = __VLS_70({
445
+ const __VLS_77 = __VLS_76({
386
446
  ref: "customerDetailRef",
387
447
  receiverId: (__VLS_ctx.receiverId),
388
448
  ...{ class: "h-full" },
389
- response: (__VLS_ctx.response),
390
- }, ...__VLS_functionalComponentArgsRest(__VLS_70));
449
+ response: (__VLS_ctx.responsiveRender),
450
+ }, ...__VLS_functionalComponentArgsRest(__VLS_76));
391
451
  /** @type {typeof __VLS_ctx.customerDetailRef} */ ;
392
- var __VLS_73 = {};
452
+ var __VLS_79 = {};
393
453
  // @ts-ignore
394
- [response, receiverId, customerDetailRef,];
395
- var __VLS_72;
454
+ [responsiveRender, receiverId, customerDetailRef,];
455
+ var __VLS_78;
396
456
  }
397
457
  if (__VLS_ctx.currentPage == __VLS_ctx.PAGE.CUSTOMER_CHECK_IN) {
398
458
  // @ts-ignore
399
459
  [currentPage, PAGE,];
400
460
  /** @type {[typeof CustomerCheckIn, ]} */ ;
401
461
  // @ts-ignore
402
- const __VLS_76 = __VLS_asFunctionalComponent(CustomerCheckIn, new CustomerCheckIn({
462
+ const __VLS_82 = __VLS_asFunctionalComponent(CustomerCheckIn, new CustomerCheckIn({
403
463
  ...{ class: "h-full" },
404
464
  }));
405
- const __VLS_77 = __VLS_76({
465
+ const __VLS_83 = __VLS_82({
406
466
  ...{ class: "h-full" },
407
- }, ...__VLS_functionalComponentArgsRest(__VLS_76));
467
+ }, ...__VLS_functionalComponentArgsRest(__VLS_82));
408
468
  }
409
469
  if (__VLS_ctx.currentPage == __VLS_ctx.PAGE.CUSTOMER_APPOINTMENT) {
410
470
  // @ts-ignore
411
471
  [currentPage, PAGE,];
412
472
  /** @type {[typeof CustomerAppointment, ]} */ ;
413
473
  // @ts-ignore
414
- const __VLS_80 = __VLS_asFunctionalComponent(CustomerAppointment, new CustomerAppointment({
474
+ const __VLS_86 = __VLS_asFunctionalComponent(CustomerAppointment, new CustomerAppointment({
415
475
  ...{ class: "h-full" },
416
476
  }));
417
- const __VLS_81 = __VLS_80({
477
+ const __VLS_87 = __VLS_86({
418
478
  ...{ class: "h-full" },
419
- }, ...__VLS_functionalComponentArgsRest(__VLS_80));
479
+ }, ...__VLS_functionalComponentArgsRest(__VLS_86));
420
480
  }
481
+ /** @type {[typeof Calling, ]} */ ;
482
+ // @ts-ignore
483
+ const __VLS_90 = __VLS_asFunctionalComponent(Calling, new Calling({
484
+ ref: "callingRef",
485
+ responsive: (__VLS_ctx.responsiveRender),
486
+ }));
487
+ const __VLS_91 = __VLS_90({
488
+ ref: "callingRef",
489
+ responsive: (__VLS_ctx.responsiveRender),
490
+ }, ...__VLS_functionalComponentArgsRest(__VLS_90));
491
+ /** @type {typeof __VLS_ctx.callingRef} */ ;
492
+ var __VLS_93 = {};
493
+ // @ts-ignore
494
+ [responsiveRender, callingRef,];
495
+ var __VLS_92;
421
496
  }
422
- /** @type {[typeof Calling, ]} */ ;
423
- // @ts-ignore
424
- const __VLS_84 = __VLS_asFunctionalComponent(Calling, new Calling({
425
- ref: "callingRef",
426
- }));
427
- const __VLS_85 = __VLS_84({
428
- ref: "callingRef",
429
- }, ...__VLS_functionalComponentArgsRest(__VLS_84));
430
- /** @type {typeof __VLS_ctx.callingRef} */ ;
431
- var __VLS_87 = {};
432
- // @ts-ignore
433
- [callingRef,];
434
- var __VLS_86;
435
497
  /** @type {__VLS_StyleScopedClasses['go-chat-main']} */ ;
498
+ /** @type {__VLS_StyleScopedClasses['max-w-full']} */ ;
436
499
  /** @type {__VLS_StyleScopedClasses['p-8']} */ ;
437
500
  /** @type {__VLS_StyleScopedClasses['m-auto']} */ ;
438
501
  /** @type {__VLS_StyleScopedClasses['flex-center']} */ ;
@@ -471,8 +534,10 @@ var __VLS_86;
471
534
  /** @type {__VLS_StyleScopedClasses['flex']} */ ;
472
535
  /** @type {__VLS_StyleScopedClasses['gap-4']} */ ;
473
536
  /** @type {__VLS_StyleScopedClasses['h-full']} */ ;
537
+ /** @type {__VLS_StyleScopedClasses['relative']} */ ;
474
538
  /** @type {__VLS_StyleScopedClasses['w-[38%]']} */ ;
475
539
  /** @type {__VLS_StyleScopedClasses['max-w-[500px]']} */ ;
540
+ /** @type {__VLS_StyleScopedClasses['min-w-[450px]']} */ ;
476
541
  /** @type {__VLS_StyleScopedClasses['chat-box-white']} */ ;
477
542
  /** @type {__VLS_StyleScopedClasses['grow']} */ ;
478
543
  /** @type {__VLS_StyleScopedClasses['flex']} */ ;
@@ -495,7 +560,7 @@ var __VLS_86;
495
560
  /** @type {__VLS_StyleScopedClasses['h-full']} */ ;
496
561
  /** @type {__VLS_StyleScopedClasses['h-full']} */ ;
497
562
  // @ts-ignore
498
- var __VLS_19 = __VLS_18, __VLS_28 = __VLS_27, __VLS_34 = __VLS_33, __VLS_55 = __VLS_54, __VLS_68 = __VLS_67, __VLS_74 = __VLS_73, __VLS_88 = __VLS_87;
563
+ var __VLS_12 = __VLS_11, __VLS_25 = __VLS_24, __VLS_34 = __VLS_33, __VLS_40 = __VLS_39, __VLS_61 = __VLS_60, __VLS_74 = __VLS_73, __VLS_80 = __VLS_79, __VLS_94 = __VLS_93;
499
564
  const __VLS_export = (await import('vue')).defineComponent({
500
565
  __typeProps: {},
501
566
  props: {},
@@ -12,8 +12,32 @@ import { dataProfile } from '../../../utils/chat/auth';
12
12
  import { readMessages } from '../../../utils/chat/message';
13
13
  import dayjs from 'dayjs';
14
14
  import relativeTime from 'dayjs/plugin/relativeTime';
15
+ import updateLocale from 'dayjs/plugin/updateLocale';
16
+ import utc from 'dayjs/plugin/utc';
17
+ import timezone from 'dayjs/plugin/timezone';
15
18
  import { useDigibot } from '../../../composable/useDigibot';
19
+ import { TIME_ZONE_UTC } from '../../../constant/datetime';
20
+ dayjs.extend(updateLocale);
16
21
  dayjs.extend(relativeTime);
22
+ dayjs.extend(utc);
23
+ dayjs.extend(timezone);
24
+ dayjs.updateLocale('en', {
25
+ relativeTime: {
26
+ future: '%s',
27
+ past: '%s',
28
+ s: 'a few seconds',
29
+ m: 'a minute',
30
+ mm: '%d minutes',
31
+ h: 'an hour',
32
+ hh: '%d hours',
33
+ d: 'a day',
34
+ dd: '%d days',
35
+ M: 'a month',
36
+ MM: '%d months',
37
+ y: 'a year',
38
+ yy: '%d years'
39
+ }
40
+ });
17
41
  const props = withDefaults(defineProps(), {});
18
42
  const emit = defineEmits();
19
43
  const { digibotData, digibotId } = useDigibot();
@@ -64,10 +88,17 @@ const mqttMessageHandler = (topic, data) => {
64
88
  getDataMqtt();
65
89
  if (topic === TOPIC_HOME[0] + dataProfile.value?.id) {
66
90
  const index = listConversations.value.findIndex((item) => item.id === data.id);
91
+ const hasChatBox = listConversations.value.findIndex((item) => item.id === digibotId);
67
92
  if (index != -1) {
68
93
  listConversations.value.splice(index, 1);
69
94
  }
70
- listConversations.value.unshift(data);
95
+ console.log(hasChatBox);
96
+ if (hasChatBox > -1) {
97
+ listConversations.value.splice(1, 0, data);
98
+ }
99
+ else {
100
+ listConversations.value.unshift(data);
101
+ }
71
102
  }
72
103
  if (topic === TOPIC_HOME[1] + dataProfile.value?.id) {
73
104
  const index = listConversations.value.findIndex((item) => item.id === data.id);
@@ -100,7 +131,7 @@ const getData = async (data, option) => {
100
131
  await nextTick();
101
132
  }
102
133
  listConversations.value.push(...(res?.items ?? []));
103
- console.log(listConversations.value, 'listConversations');
134
+ console.log(listConversations.value);
104
135
  checkHasReceiveId();
105
136
  params.value.page = res?._meta?.currentPage || 1;
106
137
  pageCount = res?._meta?.pageCount || 1;
@@ -144,6 +175,12 @@ const handleReadMessage = () => {
144
175
  }
145
176
  }
146
177
  };
178
+ const getTimeFromNow = (data) => {
179
+ if (data && dayjs(data).isValid()) {
180
+ return dayjs.tz(data, TIME_ZONE_UTC).local().fromNow();
181
+ }
182
+ return data ?? '';
183
+ };
147
184
  getData({}, { reset: true });
148
185
  const __VLS_exposed = { handleReadMessage };
149
186
  defineExpose(__VLS_exposed);
@@ -301,11 +338,9 @@ for (const [user] of __VLS_getVForSourceType((__VLS_ctx.listConversations))) {
301
338
  __VLS_asFunctionalElement(__VLS_elements.span, __VLS_elements.span)({
302
339
  ...{ class: "text-sm text-right text-chat-gray-4 w-[130px]" },
303
340
  });
304
- (__VLS_ctx.dayjs(user.last_message_time).isValid()
305
- ? __VLS_ctx.dayjs(user.last_message_time).fromNow()
306
- : (user.last_message_time ?? ''));
341
+ (__VLS_ctx.getTimeFromNow(user.last_message_time ?? ''));
307
342
  // @ts-ignore
308
- [dayjs, dayjs,];
343
+ [getTimeFromNow,];
309
344
  }
310
345
  var __VLS_17;
311
346
  /** @type {__VLS_StyleScopedClasses['']} */ ;
@@ -9,7 +9,7 @@ import { addHandleMqttMessage, connectMqtt, publishMessage, removeHandleMqttMess
9
9
  import { TOPIC_DETAIL_CHAT, TOPIC_HOME } from '../../../constant/mqtt';
10
10
  import { dataProfile } from '../../../utils/chat/auth';
11
11
  import dayjs from 'dayjs';
12
- import { DATE_FORMATS } from '../../../constant/datetime';
12
+ import { DATE_FORMATS, TIME_ZONE_UTC } from '../../../constant/datetime';
13
13
  import { MessageState } from '../../../constant/message';
14
14
  const props = withDefaults(defineProps(), {});
15
15
  const emit = defineEmits();
@@ -172,7 +172,7 @@ const publicTopicConversationUpdate = async (isSendImg, message) => {
172
172
  conversation_id: infoUser.value?.conversation_id ?? 0,
173
173
  receiver_id: Number(infoUser.value?.id)
174
174
  });
175
- const current = dayjs().format(DATE_FORMATS['DATE_FORMAT_FULL']);
175
+ const current = dayjs().tz(TIME_ZONE_UTC).format(DATE_FORMATS['DATE_FORMAT_FULL']);
176
176
  const dataMessageForReceiver = {
177
177
  id: infoUser.value?.conversation_id ?? 0,
178
178
  receiver_id: Number(dataProfile.value?.id ?? 0),
@@ -294,6 +294,11 @@ else if (!__VLS_ctx.isLoading) {
294
294
  // @ts-ignore
295
295
  [infoUser,];
296
296
  }
297
+ else {
298
+ __VLS_asFunctionalElement(__VLS_elements.span, __VLS_elements.span)({
299
+ ...{ class: "grow" },
300
+ });
301
+ }
297
302
  /** @type {[typeof InputChat, ]} */ ;
298
303
  // @ts-ignore
299
304
  const __VLS_20 = __VLS_asFunctionalComponent(InputChat, new InputChat({
@@ -320,6 +325,7 @@ var __VLS_22;
320
325
  /** @type {__VLS_StyleScopedClasses['shrink-0']} */ ;
321
326
  /** @type {__VLS_StyleScopedClasses['grow']} */ ;
322
327
  /** @type {__VLS_StyleScopedClasses['grow']} */ ;
328
+ /** @type {__VLS_StyleScopedClasses['grow']} */ ;
323
329
  /** @type {__VLS_StyleScopedClasses['p-6']} */ ;
324
330
  // @ts-ignore
325
331
  var __VLS_14 = __VLS_13;