From 14c50c04c3e4d6e0588a30c907c8df2a1a6afb15 Mon Sep 17 00:00:00 2001
From: Debora Crescenzo <dcrescenzo@sipwise.com>
Date: Tue, 6 Aug 2024 09:36:56 +0100
Subject: [PATCH] MT#60623 Add translations for invalid license error message

Add translations for the error message shown when license is invalid
and fix a small bug in the router guard, in fact we were checking
the licenses list against the attribute which are different values.

Change-Id: Ic595f731cd770f932e30fe9b649d68bcc3af7119
(cherry picked from commit f301d02b3f84247fb275227aedc04acc8e3ff7fa)
(cherry picked from commit 7002e660ce8f315baaeadc0733e119ab2b2362cd)
---
 src/api/common.js  | 4 +++-
 src/boot/routes.js | 2 +-
 src/i18n/de.json   | 1 +
 src/i18n/en.json   | 1 +
 src/i18n/es.json   | 1 +
 src/i18n/fr.json   | 1 +
 src/i18n/it.json   | 1 +
 7 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/api/common.js b/src/api/common.js
index e8e99c6e..44569ece 100644
--- a/src/api/common.js
+++ b/src/api/common.js
@@ -9,6 +9,8 @@ import {
     hasJwt
 } from 'src/auth'
 import { getCurrentLangAsV1Format } from 'src/i18n'
+import { i18n } from 'src/boot/i18n'
+
 import saveAs from 'file-saver'
 export const LIST_DEFAULT_PAGE = 1
 export const LIST_DEFAULT_ROWS = 24
@@ -170,7 +172,7 @@ function handleResponseError (err) {
     const code = _.get(err, 'response.data.code', null)
     let message = _.get(err, 'response.data.message', null)
     if (code === 403 && message === 'Invalid license') {
-        message = 'Invalid or expired license. Contact your administrator to activate this functionality'
+        message = i18n.global.tc('Contact your administrator to activate this functionality')
     }
     if (code !== null && message !== null) {
         throw new ApiResponseError(code, message)
diff --git a/src/boot/routes.js b/src/boot/routes.js
index 24ac9e5f..94c378c4 100644
--- a/src/boot/routes.js
+++ b/src/boot/routes.js
@@ -38,7 +38,7 @@ export default ({ app, router, store }) => {
                     if (to.meta.license && hasSubscriberProfileAttribute) {
                         // Guard to assure that users cannot click on menu if
                         // it is mistakenly visible when the license is inactive
-                        store.getters['user/isLicenseActive'](to.meta.profileAttribute) ? next() : next('/')
+                        store.getters['user/isLicenseActive'](to.meta.license) ? next() : next('/')
                     }
 
                     hasSubscriberProfileAttribute ? next() : next('/')
diff --git a/src/i18n/de.json b/src/i18n/de.json
index 267f126d..e46d6895 100644
--- a/src/i18n/de.json
+++ b/src/i18n/de.json
@@ -107,6 +107,7 @@
     "Conference name": "Konferenzname",
     "Confirm": "Bestätigen",
     "Contact": "Kontakt",
+    "Contact your administrator to activate this functionality":"Zur Aktivierung dieser Funktion kontaktieren Sie Ihren Administrator.",
     "Content": "Inhalt",
     "Conversations": "Konversationen",
     "Copy link": "Link kopieren",
diff --git a/src/i18n/en.json b/src/i18n/en.json
index b84f8af5..7226aaf3 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -105,6 +105,7 @@
     "Conference": "Conference",
     "Confirm": "Confirm",
     "Contact": "Contact",
+    "Contact your administrator to activate this functionality":"Contact your administrator to activate this functionality",
     "Content": "Content",
     "Conversations": "Conversations",
     "Cost": "Cost",
diff --git a/src/i18n/es.json b/src/i18n/es.json
index 09813ac8..dfe5e448 100644
--- a/src/i18n/es.json
+++ b/src/i18n/es.json
@@ -107,6 +107,7 @@
     "Conference name": "Nombre de la conferencia",
     "Confirm": "Confirmar",
     "Contact": "Contacto",
+    "Contact your administrator to activate this functionality":"Póngase en contacto con su administrador para activar esta funcionalidad",
     "Content": "Contenido",
     "Conversations": "Conversaciones",
     "Copy link": "Copiar enlace",
diff --git a/src/i18n/fr.json b/src/i18n/fr.json
index 9033fdb4..48f300e1 100644
--- a/src/i18n/fr.json
+++ b/src/i18n/fr.json
@@ -107,6 +107,7 @@
     "Conference name": "Nom de la conférence",
     "Confirm": "Confirmer",
     "Contact": "Contact",
+    "Contact your administrator to activate this functionality":"Contactez votre administrateur pour activer cette fonctionnalité",
     "Content": "Contenu",
     "Conversations": "Conversations",
     "Copy link": "Copier le lien",
diff --git a/src/i18n/it.json b/src/i18n/it.json
index d617b5e0..b41e2c94 100644
--- a/src/i18n/it.json
+++ b/src/i18n/it.json
@@ -105,6 +105,7 @@
     "Conference name": "Nome conferenza",
     "Confirm": "Conferma",
     "Contact": "Contatto",
+    "Contact your administrator to activate this functionality": "Contatta l'amministratore per attivare questa funzionalità",
     "Content": "Contenuto",
     "Conversations": "Conversazioni",
     "Copy link": "Copia il link",