@dev.smartpricing/message-composer-layer 4.2.9-ux.0 → 4.2.9
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/brands.ts +2 -5
- package/app/api/client.ts +15 -8
- package/app/components/Common/MessageGroupSelect.vue +9 -45
- package/app/utils/testIds.const.ts +2 -5
- package/i18n/locales/de.ts +0 -14
- package/i18n/locales/en.ts +0 -12
- package/i18n/locales/es.ts +0 -13
- package/i18n/locales/fr.ts +0 -13
- package/i18n/locales/it.ts +0 -12
- package/package.json +2 -2
- package/app/composables/apiErrorMessages.ts +0 -26
package/app/api/brands.ts
CHANGED
|
@@ -30,16 +30,13 @@ export const brandsApi = {
|
|
|
30
30
|
apiClient<BrandCreateResponse>('/brands', {
|
|
31
31
|
method: 'POST',
|
|
32
32
|
body: data,
|
|
33
|
-
|
|
34
|
-
_skipErrorToast: true,
|
|
35
|
-
} as Record<string, unknown>),
|
|
33
|
+
}),
|
|
36
34
|
|
|
37
35
|
update: (id: string, data: BrandUpdateBody) =>
|
|
38
36
|
apiClient<BrandFromDb>(`/brands/${id}`, {
|
|
39
37
|
method: 'PUT',
|
|
40
38
|
body: data,
|
|
41
|
-
|
|
42
|
-
} as Record<string, unknown>),
|
|
39
|
+
}),
|
|
43
40
|
|
|
44
41
|
delete: (id: string) => apiClient<BrandDeleteResponse>(`/brands/${id}`, { method: 'DELETE' }),
|
|
45
42
|
|
package/app/api/client.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { AppError } from '@dev.smartpricing/message-composer-utils/types'
|
|
2
2
|
import { useAppContextStore } from '@/stores/appContext'
|
|
3
|
-
import { resolveErrorToast } from '~/composables/apiErrorMessages'
|
|
4
3
|
|
|
5
4
|
function assertAppError(data: unknown): data is AppError {
|
|
6
5
|
if (typeof data !== 'object' || data === null) {
|
|
@@ -42,12 +41,20 @@ export const apiClient = createApiClient({
|
|
|
42
41
|
options.headers.set('sm-default-tags', store.default_tags.join(','))
|
|
43
42
|
}
|
|
44
43
|
},
|
|
45
|
-
onResponseError({ response
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
onResponseError({ response }) {
|
|
45
|
+
const error = response._data
|
|
46
|
+
if (assertAppError(error)) {
|
|
47
|
+
useToast().add({
|
|
48
|
+
color: 'error',
|
|
49
|
+
title: error.code,
|
|
50
|
+
description: error.message,
|
|
51
|
+
})
|
|
52
|
+
} else {
|
|
53
|
+
useToast().add({
|
|
54
|
+
color: 'error',
|
|
55
|
+
title: 'Error',
|
|
56
|
+
description: 'An error occurred',
|
|
57
|
+
})
|
|
58
|
+
}
|
|
52
59
|
},
|
|
53
60
|
})
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import type { RenderType
|
|
2
|
+
import type { RenderType } from '@dev.smartpricing/message-composer-utils/types'
|
|
3
3
|
import { useMessageGroupsQuery } from '~/queries/messageGroups'
|
|
4
4
|
|
|
5
|
-
defineOptions({ name: '
|
|
5
|
+
defineOptions({ name: 'TemplateSelect' })
|
|
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
|
|
14
|
+
placeholder: 'Select a template',
|
|
15
15
|
searchPlaceholder: 'Search...',
|
|
16
16
|
},
|
|
17
17
|
)
|
|
@@ -22,38 +22,16 @@ const emit = defineEmits<{
|
|
|
22
22
|
select: [item: { id: string; name: string }]
|
|
23
23
|
}>()
|
|
24
24
|
|
|
25
|
-
const { t } = useI18n()
|
|
26
|
-
|
|
27
25
|
const { data: messageGroups, isLoading } = useMessageGroupsQuery(() => ({
|
|
28
26
|
renderType: props.renderType,
|
|
29
27
|
}))
|
|
30
28
|
|
|
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
|
-
|
|
37
29
|
const items = computed(() => {
|
|
38
30
|
if (!messageGroups.value) return []
|
|
39
|
-
return messageGroups.value.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
}, [])
|
|
31
|
+
return messageGroups.value.map((group) => ({
|
|
32
|
+
label: group.name,
|
|
33
|
+
value: group.id,
|
|
34
|
+
}))
|
|
57
35
|
})
|
|
58
36
|
|
|
59
37
|
function handleUpdate(value: string) {
|
|
@@ -72,21 +50,7 @@ function handleUpdate(value: string) {
|
|
|
72
50
|
searchable
|
|
73
51
|
:placeholder="placeholder"
|
|
74
52
|
:search-input="{ placeholder: searchPlaceholder }"
|
|
75
|
-
:data-testid="
|
|
53
|
+
:data-testid="templateSelectTestIds.root"
|
|
76
54
|
@update:model-value="handleUpdate"
|
|
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>
|
|
55
|
+
/>
|
|
92
56
|
</template>
|
|
@@ -738,9 +738,6 @@ export const previewByIdTestIds = {
|
|
|
738
738
|
loading: 'preview-by-id-loading',
|
|
739
739
|
} as const
|
|
740
740
|
|
|
741
|
-
export const
|
|
742
|
-
root: '
|
|
741
|
+
export const templateSelectTestIds = {
|
|
742
|
+
root: 'template-select-root',
|
|
743
743
|
} as const
|
|
744
|
-
|
|
745
|
-
/** @deprecated Use `messageGroupSelectTestIds` instead */
|
|
746
|
-
export const templateSelectTestIds = messageGroupSelectTestIds
|
package/i18n/locales/de.ts
CHANGED
|
@@ -21,15 +21,6 @@ export default {
|
|
|
21
21
|
desktop: 'Desktop',
|
|
22
22
|
error: 'Fehler',
|
|
23
23
|
errore: 'Fehler',
|
|
24
|
-
errors: {
|
|
25
|
-
forbidden: 'Sie haben keine Berechtigung, diese Aktion auszuführen.',
|
|
26
|
-
generic: 'Ein unerwarteter Fehler ist aufgetreten. Bitte versuchen Sie es erneut.',
|
|
27
|
-
not_found: 'Die angeforderte Ressource wurde nicht gefunden.',
|
|
28
|
-
server_error: 'Ein Serverfehler ist aufgetreten. Bitte versuchen Sie es später erneut.',
|
|
29
|
-
service_unavailable:
|
|
30
|
-
'Der Dienst ist vorübergehend nicht verfügbar. Bitte versuchen Sie es später erneut.',
|
|
31
|
-
session_expired: 'Ihre Sitzung ist abgelaufen. Bitte melden Sie sich erneut an.',
|
|
32
|
-
},
|
|
33
24
|
imageUpload: {
|
|
34
25
|
imageJpgPngOnly: 'Es werden nur JPG- und PNG-Bilddateien unterstützt.',
|
|
35
26
|
mediaFileTooLarge: 'Die Datei ist zu groß. Maximale Größe: {maxSize}MB.',
|
|
@@ -54,11 +45,6 @@ export default {
|
|
|
54
45
|
search: 'Suchen...',
|
|
55
46
|
success: 'Erfolg',
|
|
56
47
|
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
|
-
},
|
|
62
48
|
view_less: 'Weniger anzeigen',
|
|
63
49
|
view_more: 'Mehr anzeigen',
|
|
64
50
|
},
|
package/i18n/locales/en.ts
CHANGED
|
@@ -21,14 +21,6 @@ export default {
|
|
|
21
21
|
desktop: 'Desktop',
|
|
22
22
|
error: 'Error',
|
|
23
23
|
errore: 'Error',
|
|
24
|
-
errors: {
|
|
25
|
-
forbidden: "You don't have permission to perform this action.",
|
|
26
|
-
generic: 'An unexpected error occurred. Please try again.',
|
|
27
|
-
not_found: 'The requested resource was not found.',
|
|
28
|
-
server_error: 'A server error occurred. Please try again later.',
|
|
29
|
-
service_unavailable: 'The service is temporarily unavailable. Please try again later.',
|
|
30
|
-
session_expired: 'Your session has expired. Please log in again.',
|
|
31
|
-
},
|
|
32
24
|
imageUpload: {
|
|
33
25
|
imageJpgPngOnly: 'Only JPG and PNG image files are supported.',
|
|
34
26
|
mediaFileTooLarge: 'File is too large. Maximum size: {maxSize}MB.',
|
|
@@ -53,10 +45,6 @@ export default {
|
|
|
53
45
|
search: 'Search...',
|
|
54
46
|
success: 'Success',
|
|
55
47
|
translation_failed: 'Translation failed',
|
|
56
|
-
messageGroupSelect: {
|
|
57
|
-
inactive_tooltip: 'This message group has unapproved or missing messages',
|
|
58
|
-
hide_inactive: 'Hide inactive',
|
|
59
|
-
},
|
|
60
48
|
view_less: 'View less',
|
|
61
49
|
view_more: 'View more',
|
|
62
50
|
},
|
package/i18n/locales/es.ts
CHANGED
|
@@ -21,15 +21,6 @@ export default {
|
|
|
21
21
|
desktop: 'Escritorio',
|
|
22
22
|
error: 'Error',
|
|
23
23
|
errore: 'Error',
|
|
24
|
-
errors: {
|
|
25
|
-
forbidden: 'No tienes permiso para realizar esta acción.',
|
|
26
|
-
generic: 'Se ha producido un error inesperado. Inténtalo de nuevo.',
|
|
27
|
-
not_found: 'El recurso solicitado no fue encontrado.',
|
|
28
|
-
server_error: 'Se ha producido un error en el servidor. Inténtalo de nuevo más tarde.',
|
|
29
|
-
service_unavailable:
|
|
30
|
-
'El servicio no está disponible temporalmente. Inténtalo de nuevo más tarde.',
|
|
31
|
-
session_expired: 'Tu sesión ha expirado. Inicia sesión de nuevo.',
|
|
32
|
-
},
|
|
33
24
|
imageUpload: {
|
|
34
25
|
imageJpgPngOnly: 'Solo se admiten archivos de imagen JPG y PNG.',
|
|
35
26
|
mediaFileTooLarge: 'El archivo es demasiado grande. Tamaño máximo: {maxSize}MB.',
|
|
@@ -54,10 +45,6 @@ export default {
|
|
|
54
45
|
search: 'Buscar...',
|
|
55
46
|
success: 'Éxito',
|
|
56
47
|
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
|
-
},
|
|
61
48
|
view_less: 'Ver menos',
|
|
62
49
|
view_more: 'Ver más',
|
|
63
50
|
},
|
package/i18n/locales/fr.ts
CHANGED
|
@@ -21,15 +21,6 @@ export default {
|
|
|
21
21
|
desktop: 'Bureau',
|
|
22
22
|
error: 'Erreur',
|
|
23
23
|
errore: 'Erreur',
|
|
24
|
-
errors: {
|
|
25
|
-
forbidden: "Vous n'avez pas la permission d'effectuer cette action.",
|
|
26
|
-
generic: 'Une erreur inattendue est survenue. Veuillez réessayer.',
|
|
27
|
-
not_found: "La ressource demandée n'a pas été trouvée.",
|
|
28
|
-
server_error: 'Une erreur serveur est survenue. Veuillez réessayer plus tard.',
|
|
29
|
-
service_unavailable:
|
|
30
|
-
'Le service est temporairement indisponible. Veuillez réessayer plus tard.',
|
|
31
|
-
session_expired: 'Votre session a expiré. Veuillez vous reconnecter.',
|
|
32
|
-
},
|
|
33
24
|
imageUpload: {
|
|
34
25
|
imageJpgPngOnly: 'Seuls les fichiers image JPG et PNG sont pris en charge.',
|
|
35
26
|
mediaFileTooLarge: 'Le fichier est trop volumineux. Taille maximale : {maxSize} Mo.',
|
|
@@ -54,10 +45,6 @@ export default {
|
|
|
54
45
|
search: 'Rechercher...',
|
|
55
46
|
success: 'Succès',
|
|
56
47
|
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
|
-
},
|
|
61
48
|
view_less: 'Afficher moins',
|
|
62
49
|
view_more: 'Afficher plus',
|
|
63
50
|
},
|
package/i18n/locales/it.ts
CHANGED
|
@@ -21,14 +21,6 @@ export default {
|
|
|
21
21
|
desktop: 'Desktop',
|
|
22
22
|
error: 'Errore',
|
|
23
23
|
errore: 'Errore',
|
|
24
|
-
errors: {
|
|
25
|
-
forbidden: 'Non hai i permessi per eseguire questa azione.',
|
|
26
|
-
generic: 'Si è verificato un errore imprevisto. Riprova.',
|
|
27
|
-
not_found: 'La risorsa richiesta non è stata trovata.',
|
|
28
|
-
server_error: 'Si è verificato un errore del server. Riprova più tardi.',
|
|
29
|
-
service_unavailable: 'Il servizio è temporaneamente non disponibile. Riprova più tardi.',
|
|
30
|
-
session_expired: "La sessione è scaduta. Effettua nuovamente l'accesso.",
|
|
31
|
-
},
|
|
32
24
|
imageUpload: {
|
|
33
25
|
imageJpgPngOnly: 'Sono supportati solo file immagine JPG e PNG.',
|
|
34
26
|
mediaFileTooLarge: 'Il file è troppo grande. Dimensione massima: {maxSize}MB.',
|
|
@@ -53,10 +45,6 @@ export default {
|
|
|
53
45
|
search: 'Cerca...',
|
|
54
46
|
success: 'Successo',
|
|
55
47
|
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
|
-
},
|
|
60
48
|
view_less: 'Mostra meno',
|
|
61
49
|
view_more: 'Mostra di più',
|
|
62
50
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dev.smartpricing/message-composer-layer",
|
|
3
|
-
"version": "4.2.9
|
|
3
|
+
"version": "4.2.9",
|
|
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
|
|
39
|
+
"@dev.smartpricing/message-composer-utils": "4.2.9"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@nuxt/eslint": "^1.15.2",
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const CODE_TO_KEY: Record<string, string> = {
|
|
2
|
-
'session.missing': 'common.errors.session_expired',
|
|
3
|
-
'session.expired': 'common.errors.session_expired',
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
function descriptionKeyByStatus(status: number): string {
|
|
7
|
-
if (status === 403) return 'common.errors.forbidden'
|
|
8
|
-
if (status === 404) return 'common.errors.not_found'
|
|
9
|
-
if (status === 503) return 'common.errors.service_unavailable'
|
|
10
|
-
if (status >= 500) return 'common.errors.server_error'
|
|
11
|
-
return 'common.errors.generic'
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function resolveErrorToast(
|
|
15
|
-
error: { status: number; code?: string },
|
|
16
|
-
t: (key: string) => string,
|
|
17
|
-
): { title: string; description: string; id: string } {
|
|
18
|
-
const descriptionKey =
|
|
19
|
-
(error.code && CODE_TO_KEY[error.code]) || descriptionKeyByStatus(error.status)
|
|
20
|
-
|
|
21
|
-
return {
|
|
22
|
-
title: t('common.error'),
|
|
23
|
-
description: t(descriptionKey),
|
|
24
|
-
id: `api-error-${error.status}-${error.code || 'unknown'}`,
|
|
25
|
-
}
|
|
26
|
-
}
|