@dev.smartpricing/message-composer-layer 4.2.9-toast.1 → 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/i18n/locales/de.ts +0 -9
- package/i18n/locales/en.ts +0 -8
- package/i18n/locales/es.ts +0 -9
- package/i18n/locales/fr.ts +0 -9
- package/i18n/locales/it.ts +0 -8
- 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
|
})
|
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.',
|
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.',
|
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.',
|
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.',
|
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.',
|
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
|
-
}
|