vue-wiguet-chatweb 0.1.21 → 0.1.23

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-wiguet-chatweb",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -11,16 +11,20 @@
11
11
  <Loader />
12
12
  </div>
13
13
  <MessageList
14
+ v-if="messagesData.data.length > 0"
14
15
  :messages="messagesData.data"
15
16
  :canLoadMoreMessages="messagesData.canLoadMoreMessages"
16
17
  @loadMore="getMessages"
17
18
  @retry="retryMessage"
18
19
  @on-qualifying="(args) => onQualifying(args)"
19
20
  />
21
+ <div class="fit" v-else>
22
+ <span class="center">No tienes mensajes</span>
23
+ </div>
20
24
  </div>
21
25
 
22
26
  <div class="w-full">
23
- <form class="message-send" @submit.prevent="(event) => submitMessage(event)">
27
+ <form v-if="!isDisabledBoxMessage" class="message-send" @submit.prevent="(event) => submitMessage(event)">
24
28
  <div class="form-message">
25
29
  <div class="jl-inputgroup-chat">
26
30
  <textarea
@@ -44,6 +48,9 @@
44
48
  </div>
45
49
  </div>
46
50
  </form>
51
+ <span class="message-send-block" v-else>
52
+ Necesitamos que nos califique la atención para continuar
53
+ </span>
47
54
  </div>
48
55
  </div>
49
56
  </template>
@@ -80,6 +87,7 @@ import Loader from "./Loader.vue";
80
87
  import { searchFromLast } from "../resources/functions.helpers";
81
88
  import { io, Socket } from "socket.io-client";
82
89
  import { APP_TYPE } from "../dto/chat.dto";
90
+ import { MESSAGE_TYPE_CODES } from "../resources/constants/message-type.constant";
83
91
 
84
92
  //DATA
85
93
  const message = ref("");
@@ -281,6 +289,8 @@ const submitMessage = async (
281
289
 
282
290
  if(!messageUpdated) return
283
291
 
292
+ isDisabledBoxMessage.value = !!messagesData.value.data.find((msg) => msg.messageType?.code === MESSAGE_TYPE_CODES.PREGUNTA && msg.response == null);
293
+
284
294
  socketService.value?.emit(
285
295
  "sendMessage",
286
296
  { roomId: information?.value?.appChat.id, message: messageUpdated },
@@ -315,6 +325,8 @@ const getMessages = async () => {
315
325
  const resp = await getMessagesApi({ body, token: props.tokenAuth });
316
326
  isLoading.value = false;
317
327
 
328
+ isDisabledBoxMessage.value = !!resp.data.find((msg) => msg.messageType?.code === MESSAGE_TYPE_CODES.PREGUNTA && msg.response == null);
329
+
318
330
  messagesData.value.data.unshift(
319
331
  ...resp.data.sort((a, b) => -b.createdAt.localeCompare(a.createdAt))
320
332
  );
@@ -443,6 +455,8 @@ function connectMsWebSocket(
443
455
  messagesData.value.data.push(data.message);
444
456
  }
445
457
 
458
+ isDisabledBoxMessage.value = !!messagesData.value.data.find((msg) => msg.messageType?.code === MESSAGE_TYPE_CODES.PREGUNTA && msg.response == null);
459
+
446
460
  setVistoToTrueApi(data.message.appChatId, props.tokenAuth);
447
461
  scrollToBottom();
448
462
  !props.visible && emit("new-message");
@@ -500,6 +514,7 @@ function onQualifying({ message: messageParam, emoji }: { message: Message, emoj
500
514
  emit('onQualifying', { message: emoji.iconUnicode , callback})
501
515
  };
502
516
 
517
+ const isDisabledBoxMessage = ref(false);
503
518
 
504
519
  onMounted(async () => {
505
520
  if (appChatId.value) return;
@@ -551,4 +566,22 @@ onUnmounted(() => {
551
566
  left: 50%;
552
567
  transform: translate(-50%, -50%);
553
568
  }
569
+
570
+ .fit {
571
+ width: 100%;
572
+ height: 100%;
573
+ position: relative;
574
+ }
575
+ .center {
576
+ position: absolute;
577
+ top: 50%;
578
+ left: 50%;
579
+ transform: translate(-50%, -50%);
580
+ }
581
+
582
+ .message-send-block {
583
+ display: block;
584
+ margin: 1.5rem;
585
+ text-align: center;
586
+ }
554
587
  </style>
@@ -22,8 +22,8 @@
22
22
  </template>
23
23
 
24
24
  <script setup lang="ts">
25
- // TODO: parece que no se usa
26
- import {computed } from 'vue';
25
+ // TODO: parece que no se usa el componente
26
+ import { computed } from 'vue';
27
27
  import { formatTimeAPDate,textCapitalize } from '../resources/functions.helpers'
28
28
  const props = defineProps({
29
29
  message:{ type: Object, required: true },
@@ -26,25 +26,27 @@
26
26
  <div class="chat-message">
27
27
  <div class="bubble" :class="message.esCliente ? 'right' : 'left'">
28
28
  <div :class="message.esCliente ? 'content-right' : 'content-left'">
29
- <div v-if="message.message === '😊😄🙂😐🙁'" class="flex gap-2" >
29
+ <div v-if="message.message === '😊😄🙂😐🙁'" class="flex flex-col gap-2" >
30
30
  <div class="mb-2">
31
31
  <strong style="display: block;">Ayúdanos a mejorar nuestro servicio.</strong>
32
32
  <span>¿Que le pareció la atención?</span>
33
33
  </div>
34
34
 
35
- <a
36
- v-for="emojiParam in emojis"
37
- :key="emojiParam.value"
38
- :href="!message.response ? 'javascript:' : undefined"
39
- class="btn-icon"
40
- :class="{ 'content-disabled' : !showIcon(message, emojiParam) }"
41
- @click="!message.response && emit('onQualifying', { message, emoji: emojiParam })"
42
- >
43
- <div class="flex flex-col items-center">
44
- <img :src="emojiParam.icon" alt="icono" class="icon" />
45
- <span>{{ emojiParam.label }}</span>
46
- </div>
47
- </a>
35
+ <div style="font-size: 14px;" class="flex justify-between gap-2">
36
+ <a
37
+ v-for="emojiParam in emojis"
38
+ :key="emojiParam.value"
39
+ :href="!message.response ? 'javascript:' : undefined"
40
+ class="btn-icon"
41
+ :class="{ 'content-disabled' : !showIcon(message, emojiParam) }"
42
+ @click="!message.response && emit('onQualifying', { message, emoji: emojiParam })"
43
+ >
44
+ <div class="flex flex-col items-center">
45
+ <img :src="emojiParam.icon" alt="icono" class="icon" />
46
+ <span>{{ emojiParam.label }}</span>
47
+ </div>
48
+ </a>
49
+ </div>
48
50
  </div>
49
51
 
50
52
  <div v-else-if="emoji[message.message ?? '']">
@@ -52,7 +54,8 @@
52
54
  </div>
53
55
 
54
56
  <div v-else class="message-text" style="white-space: pre-line" v-html="textToRichFormat(message.message)"></div>
55
- <div class="detail-message flex justify-content-between">
57
+
58
+ <div class="detail-message flex justify-between mt-2">
56
59
  <span class="mr-5" v-if="message.sender?.nombreCompleto">
57
60
  {{
58
61
  message.esCliente
@@ -354,10 +357,17 @@ const emoji: { [key in string]: any } = {
354
357
  margin-bottom: 8px;
355
358
  }
356
359
 
360
+ .mt-2 {
361
+ margin-top: 8px;
362
+ }
363
+
357
364
  .content-disabled {
358
365
  -webkit-filter: grayscale(1); /* Google Chrome, Safari 6+ & Opera 15+ */
359
366
  filter: grayscale(1); /* Microsoft Edge and Firefox 35+ */
360
367
  opacity: 0.5;
361
368
  }
369
+ .justify-between {
370
+ justify-content: space-between;
371
+ }
362
372
 
363
373
  </style>