From e525f87ccdb7b1cc7cdf9833b63e6d10f9c189a6 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 15 Dec 2023 09:57:03 +0100 Subject: [PATCH] refs #6172 feat:enable translation when ticketIsLocked --- src/boot/axios.js | 14 ++++++++------ src/i18n/en/index.js | 7 ++++++- src/i18n/es/index.js | 5 +++++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/boot/axios.js b/src/boot/axios.js index c58cc2d08..1f17d8c8c 100644 --- a/src/boot/axios.js +++ b/src/boot/axios.js @@ -39,12 +39,9 @@ const onResponse = (response) => { const onResponseError = (error) => { let message = ''; - const response = error.response; - const responseData = response && response.data; - const responseError = responseData && response.data.error; - if (responseError) { - message = responseError.message; - } + const { response } = error; + const dataError = response?.data?.error; + const code = dataError?.code; switch (response?.status) { case 500: @@ -56,7 +53,12 @@ const onResponseError = (error) => { case 504: message = 'errors.statusGatewayTimeout'; break; + + default: + message = `errors.${dataError?.message}`; + break; } + if (code) message = code; if (session.isLoggedIn() && response?.status === 401) { session.destroy(); diff --git a/src/i18n/en/index.js b/src/i18n/en/index.js index 5e7e116c5..3f97d6bf9 100644 --- a/src/i18n/en/index.js +++ b/src/i18n/en/index.js @@ -71,7 +71,9 @@ export default { statusGatewayTimeout: 'Could not contact the server', userConfig: 'Error fetching user config', create: 'Error during creation', + 'This ticket is locked': 'dEste ticket está bloqueado', }, + 'This ticket is locked': 'dEste ticket está bloqueado', login: { title: 'Login', username: 'Username', @@ -232,7 +234,7 @@ export default { agency: 'Agency', shipped: 'Shipped', warehouse: 'Warehouse', - customerCard: 'Customer card', + customerCard: 'Customer card' }, boxing: { expedition: 'Expedition', @@ -243,6 +245,9 @@ export default { selectVideo: 'Select video:', notFound: 'No videos available', }, + error:{ + locked: 'This item is locked' + }, summary: { state: 'State', salesPerson: 'Sales person', diff --git a/src/i18n/es/index.js b/src/i18n/es/index.js index 4e570e7b4..ff412dc1d 100644 --- a/src/i18n/es/index.js +++ b/src/i18n/es/index.js @@ -70,7 +70,9 @@ export default { statusGatewayTimeout: 'No se ha podido contactar con el servidor', userConfig: 'Error al obtener configuración de usuario', create: 'Error al crear', + 'This ticket is locked': 'Este ticket está bloqueado', }, + 'This ticket is locked': 'Este ticket está bloqueado', login: { title: 'Inicio de sesión', username: 'Nombre de usuario', @@ -241,6 +243,9 @@ export default { selectVideo: 'Seleccionar vídeo:', notFound: 'No hay vídeos disponibles', }, + error:{ + locked: 'Este item está bloqueado' + }, summary: { state: 'Estado', salesPerson: 'Comercial',