vue-wiguet-chatweb 0.1.16 โ†’ 0.1.17

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-wiguet-chatweb",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -15,6 +15,7 @@
15
15
  :canLoadMoreMessages="messagesData.canLoadMoreMessages"
16
16
  @loadMore="getMessages"
17
17
  @retry="retryMessage"
18
+ @on-qualifying="(args) => onQualifying(args)"
18
19
  />
19
20
  </div>
20
21
 
@@ -70,6 +71,7 @@ import {
70
71
  getMessagesApi,
71
72
  sendMessageApi,
72
73
  setVistoToTrueApi,
74
+ updateMessageApi,
73
75
  } from "../store/index";
74
76
  import { getInformationApi } from "../store";
75
77
  import MessageList from "./MessageList.vue";
@@ -96,6 +98,7 @@ const emit = defineEmits([
96
98
  "new-message",
97
99
  "clear-new-messages",
98
100
  "not-viewed-total",
101
+ "onQualifying",
99
102
  ]);
100
103
 
101
104
  const props = defineProps({
@@ -413,6 +416,42 @@ function getOS() {
413
416
  return os;
414
417
  }
415
418
 
419
+ function onQualifying({ message, emoji }: { message: Message, emoji: {icon: string, value: number } }) {
420
+ const callback = async () => {
421
+ if (!message.id || !emoji) return;
422
+
423
+ const idx = searchFromLast<Message>(
424
+ messagesData.value.data,
425
+ "id",
426
+ message.id
427
+ );
428
+
429
+ let prevMessage = messagesData.value?.data?.[idx].message
430
+ messagesData.value?.data?.[idx] && (messagesData.value.data[idx].message = emoji.icon);
431
+
432
+ const msg = await updateMessageApi(message.id, { message: emoji.icon, tipoCalificacionId: emoji.value }, props.tokenAuth);
433
+
434
+ if (!msg) {
435
+ messagesData.value?.data?.[idx] && (messagesData.value.data[idx].message = prevMessage);
436
+ emit("show-toast", {
437
+ severity: "error",
438
+ summary: "Error",
439
+ detail: "Ocurrio un error al enviar el mensaje, intente nuevamente",
440
+ life: 5000,
441
+ });
442
+ return
443
+ }
444
+
445
+ socketService.value?.emit("sendMessage", {
446
+ roomId: information?.value?.appChat.id,
447
+ message,
448
+ });
449
+ }
450
+
451
+ emit('onQualifying', callback)
452
+ };
453
+
454
+
416
455
  onMounted(async () => {
417
456
  if (appChatId.value) return;
418
457
 
@@ -26,7 +26,25 @@
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 class="message-text" style="white-space: pre-line" v-html="textToRichFormat(message.message)"></div>
29
+ <div v-if="message.message === '๐Ÿ˜Š๐Ÿ˜„๐Ÿ™‚๐Ÿ˜๐Ÿ™'" class="flex gap-2" >
30
+ <div>
31
+ <strong style="display: block; margin-bottom: 0.5rem;">Ayรบdanos a mejorar nuestro servicio.</strong>
32
+ <span>Que le pareciรณ la atenciรณn:</span>
33
+ </div>
34
+ <a
35
+ v-for="emoji in emojis"
36
+ href="javascript:"
37
+ class="btn-icon"
38
+ :key="emoji.value"
39
+ @click="emit('onQualifying', { message, emoji })"
40
+ >
41
+ <div class="flex flex-col items-center">
42
+ <div class="icon">{{ emoji.icon }}</div>
43
+ <span>{{ emoji.label }}</span>
44
+ </div>
45
+ </a>
46
+ </div>
47
+ <div v-else class="message-text" style="white-space: pre-line" v-html="textToRichFormat(message.message)"></div>
30
48
  <div class="detail-message flex justify-content-between">
31
49
  <span class="mr-5" v-if="message.sender?.nombreCompleto">
32
50
  {{
@@ -53,13 +71,13 @@
53
71
  </template>
54
72
 
55
73
  <script setup lang="ts">
56
- import { PropType, onBeforeMount, ref, watch } from "vue";
74
+ import { PropType, onBeforeMount, ref, watch, h } from 'vue';
57
75
  import { useIntersectionObserver } from "@vueuse/core";
58
76
  import { type Message } from "../dto/app.dto";
59
77
  import { DateTime } from "luxon";
60
78
  import DangerIcon from "./DangerIcon.vue";
61
79
 
62
- const emit = defineEmits(["loadMore", "retry"]);
80
+ const emit = defineEmits(["loadMore", "retry", "onQualifying"]);
63
81
  const props = defineProps({
64
82
  messages: {
65
83
  type: Array as PropType<Message[]>,
@@ -135,6 +153,14 @@ function textToRichFormat(text: string) {
135
153
  return newMessage().replace(/--custom-tag/g, '');
136
154
  }
137
155
 
156
+ const emojis = [
157
+ { label: 'Excelente', value: 1, icon: '๐Ÿ˜Š' },
158
+ { label: 'Buena', value: 2, icon: '๐Ÿ˜„' },
159
+ { label: 'Aceptable', value: 3, icon: '๐Ÿ™‚' },
160
+ { label: 'Mala', value: 4, icon: '๐Ÿ˜' },
161
+ { label: 'Muy Mala', value: 5, icon: '๐Ÿ™' },
162
+ ]
163
+
138
164
  </script>
139
165
 
140
166
  <style scoped>
@@ -260,4 +286,32 @@ function textToRichFormat(text: string) {
260
286
  .messages-container-list {
261
287
  width: 100%;
262
288
  }
289
+
290
+ .btn-icon {
291
+ text-decoration: none;
292
+ border: none;
293
+ }
294
+ .btn-icon span {
295
+ color: currentColor;
296
+ text-wrap: nowrap;
297
+ }
298
+
299
+ .btn-icon .icon {
300
+ font-size: 2rem;
301
+ }
302
+
303
+ .flex {
304
+ display: flex;
305
+ flex-wrap: wrap;
306
+ }
307
+ .flex-col {
308
+ flex-direction: column;
309
+ }
310
+ .items-center {
311
+ align-items: center;
312
+ }
313
+ .gap-2 {
314
+ gap: 0.5rem;
315
+ }
316
+
263
317
  </style>
@@ -50,6 +50,7 @@
50
50
  @clear-new-messages="newMessages = 0"
51
51
  @new-message="() => newMessages++"
52
52
  @not-viewed-total="(val) => (newMessages = val)"
53
+ @on-qualifying="(args)=> emit('onQualifying', args)"
53
54
  />
54
55
  </div>
55
56
  </div>
@@ -63,7 +64,7 @@ import IconTelegram from "./IconTelegram.vue";
63
64
  import IconWhatsApp from "./IconWhatsApp.vue";
64
65
  import IconChat from "./IconChat.vue";
65
66
 
66
- const emit = defineEmits(["show-toast", "show-confirm"]);
67
+ const emit = defineEmits(["show-toast", "show-confirm", "onQualifying"]);
67
68
 
68
69
  const enum MeansCommunication{
69
70
  WHATSAPP,