@dev.smartpricing/message-composer-layer 4.2.9 → 4.2.10

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 CHANGED
@@ -30,13 +30,16 @@ export const brandsApi = {
30
30
  apiClient<BrandCreateResponse>('/brands', {
31
31
  method: 'POST',
32
32
  body: data,
33
- }),
33
+
34
+ _skipErrorToast: true,
35
+ } as Record<string, unknown>),
34
36
 
35
37
  update: (id: string, data: BrandUpdateBody) =>
36
38
  apiClient<BrandFromDb>(`/brands/${id}`, {
37
39
  method: 'PUT',
38
40
  body: data,
39
- }),
41
+ _skipErrorToast: true,
42
+ } as Record<string, unknown>),
40
43
 
41
44
  delete: (id: string) => apiClient<BrandDeleteResponse>(`/brands/${id}`, { method: 'DELETE' }),
42
45
 
package/app/api/client.ts CHANGED
@@ -1,5 +1,6 @@
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'
3
4
 
4
5
  function assertAppError(data: unknown): data is AppError {
5
6
  if (typeof data !== 'object' || data === null) {
@@ -41,20 +42,12 @@ export const apiClient = createApiClient({
41
42
  options.headers.set('sm-default-tags', store.default_tags.join(','))
42
43
  }
43
44
  },
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
- }
45
+ onResponseError({ response, options }) {
46
+ if ((options as { _skipErrorToast?: boolean })._skipErrorToast) return
47
+
48
+ const t = useNuxtApp().$i18n.t
49
+ const code = assertAppError(response._data) ? response._data.code : undefined
50
+ const toast = resolveErrorToast({ status: response.status, code }, t)
51
+ useToast().add({ ...toast, color: 'error' })
59
52
  },
60
53
  })
@@ -0,0 +1,26 @@
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
+ }
@@ -21,6 +21,15 @@ 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
+ },
24
33
  imageUpload: {
25
34
  imageJpgPngOnly: 'Es werden nur JPG- und PNG-Bilddateien unterstützt.',
26
35
  mediaFileTooLarge: 'Die Datei ist zu groß. Maximale Größe: {maxSize}MB.',
@@ -654,6 +663,7 @@ export default {
654
663
  button_bg_color: 'Hintergrund',
655
664
  button_text_color: 'Text',
656
665
  change_logo: 'Logo ändern',
666
+ colors: 'Farben',
657
667
  contact_address: 'Adresse',
658
668
  contact_address_placeholder: 'Z.B. Via Roma 1, 39100 Bolzano',
659
669
  contact_email: 'E-Mail',
@@ -664,7 +674,6 @@ export default {
664
674
  contact_telephone_placeholder: 'Z.B. +39 0471 123456',
665
675
  contact_website: 'Webseite',
666
676
  contact_website_placeholder: 'Z.B. https://www.hotel.com',
667
- colors: 'Farben',
668
677
  default_button_colors: 'Standard-Schaltflächen-Farben',
669
678
  default_email_colors: 'Standard-E-Mail-Farben',
670
679
  default_font: 'Standardschriftart',
@@ -21,6 +21,14 @@ 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
+ },
24
32
  imageUpload: {
25
33
  imageJpgPngOnly: 'Only JPG and PNG image files are supported.',
26
34
  mediaFileTooLarge: 'File is too large. Maximum size: {maxSize}MB.',
@@ -645,6 +653,7 @@ export default {
645
653
  button_bg_color: 'Background',
646
654
  button_text_color: 'Text',
647
655
  change_logo: 'Change logo',
656
+ colors: 'Brand colors',
648
657
  contact_address: 'Address',
649
658
  contact_address_placeholder: 'E.g. Via Roma 1, 39100 Bolzano',
650
659
  contact_email: 'Email',
@@ -655,7 +664,6 @@ export default {
655
664
  contact_telephone_placeholder: 'E.g. +39 0471 123456',
656
665
  contact_website: 'Website',
657
666
  contact_website_placeholder: 'E.g. https://www.hotel.com',
658
- colors: 'Brand colors',
659
667
  default_button_colors: 'Default button colors',
660
668
  default_email_colors: 'Default email colors',
661
669
  default_font: 'Default font',
@@ -21,6 +21,15 @@ 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
+ },
24
33
  imageUpload: {
25
34
  imageJpgPngOnly: 'Solo se admiten archivos de imagen JPG y PNG.',
26
35
  mediaFileTooLarge: 'El archivo es demasiado grande. Tamaño máximo: {maxSize}MB.',
@@ -653,6 +662,7 @@ export default {
653
662
  button_bg_color: 'Fondo',
654
663
  button_text_color: 'Texto',
655
664
  change_logo: 'Cambiar logo',
665
+ colors: 'Colores',
656
666
  contact_address: 'Dirección',
657
667
  contact_address_placeholder: 'Ej. Via Roma 1, 39100 Bolzano',
658
668
  contact_email: 'Email',
@@ -663,7 +673,6 @@ export default {
663
673
  contact_telephone_placeholder: 'Ej. +39 0471 123456',
664
674
  contact_website: 'Sitio web',
665
675
  contact_website_placeholder: 'Ej. https://www.hotel.com',
666
- colors: 'Colores',
667
676
  default_button_colors: 'Colores de botón predeterminados',
668
677
  default_email_colors: 'Colores de correo predeterminados',
669
678
  default_font: 'Fuente predeterminada',
@@ -21,6 +21,15 @@ 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
+ },
24
33
  imageUpload: {
25
34
  imageJpgPngOnly: 'Seuls les fichiers image JPG et PNG sont pris en charge.',
26
35
  mediaFileTooLarge: 'Le fichier est trop volumineux. Taille maximale : {maxSize} Mo.',
@@ -657,6 +666,7 @@ export default {
657
666
  button_bg_color: 'Fond',
658
667
  button_text_color: 'Texte',
659
668
  change_logo: 'Changer le logo',
669
+ colors: 'Couleurs',
660
670
  contact_address: 'Adresse',
661
671
  contact_address_placeholder: 'Ex. Via Roma 1, 39100 Bolzano',
662
672
  contact_email: 'Email',
@@ -667,7 +677,6 @@ export default {
667
677
  contact_telephone_placeholder: 'Ex. +39 0471 123456',
668
678
  contact_website: 'Site web',
669
679
  contact_website_placeholder: 'Ex. https://www.hotel.com',
670
- colors: 'Couleurs',
671
680
  default_button_colors: 'Couleurs de bouton par défaut',
672
681
  default_email_colors: "Couleurs d'e-mail par défaut",
673
682
  default_font: 'Police par défaut',
@@ -21,6 +21,14 @@ 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
+ },
24
32
  imageUpload: {
25
33
  imageJpgPngOnly: 'Sono supportati solo file immagine JPG e PNG.',
26
34
  mediaFileTooLarge: 'Il file è troppo grande. Dimensione massima: {maxSize}MB.',
@@ -651,6 +659,7 @@ export default {
651
659
  button_bg_color: 'Sfondo',
652
660
  button_text_color: 'Testo',
653
661
  change_logo: 'Cambia logo',
662
+ colors: 'Colori',
654
663
  contact_address: 'Indirizzo',
655
664
  contact_address_placeholder: 'Es. Via Roma 1, 39100 Bolzano',
656
665
  contact_email: 'Email',
@@ -661,7 +670,6 @@ export default {
661
670
  contact_telephone_placeholder: 'Es. +39 0471 123456',
662
671
  contact_website: 'Sito web',
663
672
  contact_website_placeholder: 'Es. https://www.hotel.com',
664
- colors: 'Colori',
665
673
  default_button_colors: 'Colori pulsante predefiniti',
666
674
  default_email_colors: 'Colori email predefiniti',
667
675
  default_font: 'Font predefinito',
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.10",
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.10"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@nuxt/eslint": "^1.15.2",