@weni/unnnic-system 2.29.0 → 2.30.0

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": "@weni/unnnic-system",
3
- "version": "2.29.0",
3
+ "version": "2.30.0",
4
4
  "type": "commonjs",
5
5
  "files": [
6
6
  "dist",
@@ -53,6 +53,21 @@
53
53
  >
54
54
  {{ i18n('waiting_for', waitingTime, { waitingTime }) }}
55
55
  </p>
56
+ <template v-else-if="lastMessageMedia.isMedia">
57
+ <section class="chats-contact__infos__media">
58
+ <UnnnicIcon
59
+ :icon="lastMessageMedia.mediaIcon"
60
+ scheme="neutral-cloudy"
61
+ size="sm"
62
+ />
63
+ <p
64
+ :title="lastMessageMedia.mediaText"
65
+ class="ellipsis"
66
+ >
67
+ {{ lastMessageMedia.mediaText }}
68
+ </p>
69
+ </section>
70
+ </template>
56
71
  <p
57
72
  v-else-if="subtitle"
58
73
  class="ellipsis"
@@ -133,7 +148,7 @@ export default {
133
148
  required: true,
134
149
  },
135
150
  lastMessage: {
136
- type: String,
151
+ type: String || Object,
137
152
  default: '',
138
153
  },
139
154
  lastInteractionTime: {
@@ -193,6 +208,21 @@ export default {
193
208
  en: 'Discussion about {discussionGoal}',
194
209
  es: 'Discusión sobre {discussionGoal}',
195
210
  },
211
+ audio_message: {
212
+ 'pt-br': 'Mensagem de áudio',
213
+ en: 'Audio message',
214
+ es: 'Mensaje de audio',
215
+ },
216
+ image_message: {
217
+ 'pt-br': 'Imagem',
218
+ en: 'Image',
219
+ es: 'Imagen',
220
+ },
221
+ video_message: {
222
+ 'pt-br': 'Vídeo',
223
+ en: 'Video',
224
+ es: 'Video',
225
+ },
196
226
  },
197
227
  };
198
228
  },
@@ -228,11 +258,45 @@ export default {
228
258
 
229
259
  return lastInteractionMoment.format('HH:mm');
230
260
  },
261
+
262
+ lastMessageMedia() {
263
+ const { lastMessage } = this;
264
+
265
+ const isMedia =
266
+ typeof lastMessage === 'object' && lastMessage?.media?.[0];
267
+
268
+ if (!isMedia) return { isMedia };
269
+
270
+ const contentType =
271
+ lastMessage?.media?.[0]?.content_type?.split('/')?.[0];
272
+
273
+ const mediaIconMapper = {
274
+ audio: 'mic',
275
+ image: 'image',
276
+ video: 'videocam',
277
+ application: 'article',
278
+ geo: 'location_on',
279
+ };
280
+
281
+ const mediaIcon = mediaIconMapper[contentType];
282
+
283
+ const mediaTextMapper = {
284
+ audio: this.i18n('audio_message'),
285
+ image: this.i18n('image_message'),
286
+ video: this.i18n('video_message'),
287
+ application: lastMessage.media[0].url.split('/').at(-1),
288
+ geo: lastMessage.text,
289
+ };
290
+
291
+ const mediaText = mediaTextMapper[contentType];
292
+
293
+ return { isMedia, contentType, lastMessage, mediaIcon, mediaText };
294
+ },
231
295
  subtitle() {
232
296
  const { discussionGoal, lastMessage } = this;
233
297
  return discussionGoal
234
298
  ? this.i18n('discussion_about', discussionGoal, { discussionGoal })
235
- : lastMessage;
299
+ : lastMessage?.text;
236
300
  },
237
301
  },
238
302
  };
@@ -350,6 +414,12 @@ export default {
350
414
  overflow: hidden;
351
415
  gap: $unnnic-spacing-nano;
352
416
 
417
+ &__media {
418
+ display: flex;
419
+ align-items: center;
420
+ gap: $unnnic-spacing-nano;
421
+ }
422
+
353
423
  &__title,
354
424
  &__additional-information {
355
425
  font-size: $unnnic-font-size-body-gt;
@@ -6,7 +6,7 @@ exports[`UnnnicChatsContact > should match snapshot 1`] = `
6
6
  <div data-v-8ce6efd5="" class="chats-contact__infos">
7
7
  <h1 data-v-8ce6efd5="" class="chats-contact__infos__title ellipsis" title="Contact Name">Contact Name</h1>
8
8
  <div data-v-8ce6efd5="" class="chats-contact__infos__additional-information">
9
- <p data-v-8ce6efd5="" class="ellipsis" title="Message">Message</p>
9
+ <!--v-if-->
10
10
  </div>
11
11
  </div>
12
12
  <section data-v-8ce6efd5="" class="chats-contact__infos__unread-messages-container">
@@ -6,6 +6,60 @@ setup((app) => {
6
6
  app.use(i18n);
7
7
  });
8
8
 
9
+ const lastMessageMedia = {
10
+ geo: {
11
+ text: '-1.111111,-2.222222',
12
+ media: [
13
+ {
14
+ content_type: 'geo',
15
+ message: 'f0c74bfa-d405-4d20-8f75-42edc7543883',
16
+ url: '-1.111111,-2.222222',
17
+ created_on: '2025-04-15T15:20:56.030692-03:00',
18
+ },
19
+ ],
20
+ },
21
+ image: {
22
+ media: [
23
+ {
24
+ content_type: 'image/jpeg',
25
+ message: 'a997421d-6238-4bef-912d-e689c1c0db3f',
26
+ url: 'https://example.com/photo.jpg',
27
+ created_on: '2025-04-15T14:58:56.163027-03:00',
28
+ },
29
+ ],
30
+ },
31
+ audio: {
32
+ media: [
33
+ {
34
+ content_type: 'audio/ogg',
35
+ message: 'bd8ec88a-83b8-45ed-b861-20e8c98dd5ef',
36
+ url: 'https://example.com/audio.oga',
37
+ created_on: '2025-04-15T14:56:51.539059-03:00',
38
+ },
39
+ ],
40
+ },
41
+ document: {
42
+ media: [
43
+ {
44
+ content_type: 'application/pdf',
45
+ message: '46f58626-1623-4c66-9b16-746831e60130',
46
+ url: 'https://example.com/DocumentName.pdf',
47
+ created_on: '2025-04-15T14:50:14.854262-03:00',
48
+ },
49
+ ],
50
+ },
51
+ video: {
52
+ media: [
53
+ {
54
+ content_type: 'video/mp4',
55
+ message: 'aade7c9f-e42a-4c3d-9372-c9c0af4ad2a8',
56
+ url: 'https://example/video.mp4',
57
+ created_on: '2025-04-15T14:48:57.295346-03:00',
58
+ },
59
+ ],
60
+ },
61
+ };
62
+
9
63
  export default {
10
64
  title: 'Chats/Contact',
11
65
  component: unnnicChatsContact,
@@ -92,3 +146,20 @@ export const ContactList = {
92
146
  `,
93
147
  }),
94
148
  };
149
+
150
+ export const MediaLastMessage = {
151
+ args: {
152
+ ...defaultArgs,
153
+ },
154
+ render: (args) => ({
155
+ setup() {
156
+ return { args, lastMessageMedia };
157
+ },
158
+ components: { unnnicChatsContact },
159
+ template: `
160
+ <div style="display: grid;">
161
+ <unnnic-chats-contact v-for="mediaType in ['geo', 'audio', 'image', 'video', 'document']" v-bind="args" :lastMessage="lastMessageMedia[mediaType]"/>
162
+ </div>
163
+ `,
164
+ }),
165
+ };