@dev.smartpricing/message-composer-layer 4.2.9-toast.0 → 4.2.9-ux.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/app/api/client.ts CHANGED
@@ -45,7 +45,7 @@ export const apiClient = createApiClient({
45
45
  onResponseError({ response, options }) {
46
46
  if ((options as { _skipErrorToast?: boolean })._skipErrorToast) return
47
47
 
48
- const { t } = useI18n()
48
+ const t = useNuxtApp().$i18n.t
49
49
  const code = assertAppError(response._data) ? response._data.code : undefined
50
50
  const toast = resolveErrorToast({ status: response.status, code }, t)
51
51
  useToast().add({ ...toast, color: 'error' })
@@ -1,8 +1,8 @@
1
1
  <script setup lang="ts">
2
- import type { RenderType } from '@dev.smartpricing/message-composer-utils/types'
2
+ import type { RenderType, MessageStatus } from '@dev.smartpricing/message-composer-utils/types'
3
3
  import { useMessageGroupsQuery } from '~/queries/messageGroups'
4
4
 
5
- defineOptions({ name: 'TemplateSelect' })
5
+ defineOptions({ name: 'MessageGroupSelect' })
6
6
 
7
7
  const props = withDefaults(
8
8
  defineProps<{
@@ -11,7 +11,7 @@ const props = withDefaults(
11
11
  searchPlaceholder?: string
12
12
  }>(),
13
13
  {
14
- placeholder: 'Select a template',
14
+ placeholder: 'Select a message group',
15
15
  searchPlaceholder: 'Search...',
16
16
  },
17
17
  )
@@ -22,16 +22,38 @@ const emit = defineEmits<{
22
22
  select: [item: { id: string; name: string }]
23
23
  }>()
24
24
 
25
+ const { t } = useI18n()
26
+
25
27
  const { data: messageGroups, isLoading } = useMessageGroupsQuery(() => ({
26
28
  renderType: props.renderType,
27
29
  }))
28
30
 
31
+ const hideInactive = ref(false)
32
+
33
+ function isGroupActive(messages: Array<{ status: MessageStatus }>): boolean {
34
+ return messages.length > 0 && messages.every((m) => m.status === 'approved')
35
+ }
36
+
29
37
  const items = computed(() => {
30
38
  if (!messageGroups.value) return []
31
- return messageGroups.value.map((group) => ({
32
- label: group.name,
33
- value: group.id,
34
- }))
39
+ return messageGroups.value.reduce<
40
+ Array<{
41
+ label: string
42
+ value: string
43
+ disabled: boolean
44
+ chip: { color: 'success' | 'neutral' }
45
+ }>
46
+ >((acc, group) => {
47
+ const active = isGroupActive(group.messages)
48
+ if (hideInactive.value && !active) return acc
49
+ acc.push({
50
+ label: group.name,
51
+ value: group.id,
52
+ disabled: !active,
53
+ chip: { color: active ? 'success' : 'neutral' },
54
+ })
55
+ return acc
56
+ }, [])
35
57
  })
36
58
 
37
59
  function handleUpdate(value: string) {
@@ -50,7 +72,21 @@ function handleUpdate(value: string) {
50
72
  searchable
51
73
  :placeholder="placeholder"
52
74
  :search-input="{ placeholder: searchPlaceholder }"
53
- :data-testid="templateSelectTestIds.root"
75
+ :data-testid="messageGroupSelectTestIds.root"
54
76
  @update:model-value="handleUpdate"
55
- />
77
+ >
78
+ <template #item-label="{ item }">
79
+ <UTooltip v-if="item.disabled" :text="t('common.messageGroupSelect.inactive_tooltip')">
80
+ <span class="text-muted">{{ item.label }}</span>
81
+ </UTooltip>
82
+ <span v-else>{{ item.label }}</span>
83
+ </template>
84
+
85
+ <template #content-top>
86
+ <div class="flex items-center gap-2 px-2 py-1.5 border-b border-default">
87
+ <USwitch v-model="hideInactive" size="xs" />
88
+ <span class="text-xs text-muted">{{ t('common.messageGroupSelect.hide_inactive') }}</span>
89
+ </div>
90
+ </template>
91
+ </USelectMenu>
56
92
  </template>
@@ -738,6 +738,9 @@ export const previewByIdTestIds = {
738
738
  loading: 'preview-by-id-loading',
739
739
  } as const
740
740
 
741
- export const templateSelectTestIds = {
742
- root: 'template-select-root',
741
+ export const messageGroupSelectTestIds = {
742
+ root: 'message-group-select-root',
743
743
  } as const
744
+
745
+ /** @deprecated Use `messageGroupSelectTestIds` instead */
746
+ export const templateSelectTestIds = messageGroupSelectTestIds
@@ -54,6 +54,11 @@ export default {
54
54
  search: 'Suchen...',
55
55
  success: 'Erfolg',
56
56
  translation_failed: 'Übersetzung fehlgeschlagen',
57
+ messageGroupSelect: {
58
+ inactive_tooltip:
59
+ 'Diese Nachrichtengruppe enthält nicht genehmigte oder fehlende Nachrichten',
60
+ hide_inactive: 'Inaktive ausblenden',
61
+ },
57
62
  view_less: 'Weniger anzeigen',
58
63
  view_more: 'Mehr anzeigen',
59
64
  },
@@ -53,6 +53,10 @@ export default {
53
53
  search: 'Search...',
54
54
  success: 'Success',
55
55
  translation_failed: 'Translation failed',
56
+ messageGroupSelect: {
57
+ inactive_tooltip: 'This message group has unapproved or missing messages',
58
+ hide_inactive: 'Hide inactive',
59
+ },
56
60
  view_less: 'View less',
57
61
  view_more: 'View more',
58
62
  },
@@ -54,6 +54,10 @@ export default {
54
54
  search: 'Buscar...',
55
55
  success: 'Éxito',
56
56
  translation_failed: 'La traducción ha fallado',
57
+ messageGroupSelect: {
58
+ inactive_tooltip: 'Este grupo de mensajes tiene mensajes no aprobados o faltantes',
59
+ hide_inactive: 'Ocultar inactivos',
60
+ },
57
61
  view_less: 'Ver menos',
58
62
  view_more: 'Ver más',
59
63
  },
@@ -54,6 +54,10 @@ export default {
54
54
  search: 'Rechercher...',
55
55
  success: 'Succès',
56
56
  translation_failed: 'Échec de la traduction',
57
+ messageGroupSelect: {
58
+ inactive_tooltip: 'Ce groupe de messages contient des messages non approuvés ou manquants',
59
+ hide_inactive: 'Masquer inactifs',
60
+ },
57
61
  view_less: 'Afficher moins',
58
62
  view_more: 'Afficher plus',
59
63
  },
@@ -53,6 +53,10 @@ export default {
53
53
  search: 'Cerca...',
54
54
  success: 'Successo',
55
55
  translation_failed: 'Traduzione non riuscita',
56
+ messageGroupSelect: {
57
+ inactive_tooltip: 'Questo gruppo di messaggi contiene messaggi non approvati o mancanti',
58
+ hide_inactive: 'Nascondi inattivi',
59
+ },
56
60
  view_less: 'Mostra meno',
57
61
  view_more: 'Mostra di più',
58
62
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev.smartpricing/message-composer-layer",
3
- "version": "4.2.9-toast.0",
3
+ "version": "4.2.9-ux.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",
@@ -36,7 +36,7 @@
36
36
  "vue-router": "^5.0.7",
37
37
  "vue3-emoji-picker": "^1.1.8",
38
38
  "zod": "^4.4.3",
39
- "@dev.smartpricing/message-composer-utils": "4.2.9-toast.0"
39
+ "@dev.smartpricing/message-composer-utils": "4.2.9-ux.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@nuxt/eslint": "^1.15.2",