From 5b48f92246c7085bdb192a3418d04a4f0548edfd Mon Sep 17 00:00:00 2001 From: Radhika Patel Date: Tue, 10 Sep 2024 15:45:07 +0530 Subject: [PATCH] fix value check bug from production --- src/layout/TopBar/TopBar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/layout/TopBar/TopBar.js b/src/layout/TopBar/TopBar.js index 842bbfdd..c5ca3ffd 100644 --- a/src/layout/TopBar/TopBar.js +++ b/src/layout/TopBar/TopBar.js @@ -128,7 +128,7 @@ const TopBar = ({ const lng = LANGUAGES.find((item) => _.isEqual(item.value, googtransLng)); if (user && lng && !_.isEqual(user.user_language, lng.label)) { const newLng = LANGUAGES.find((item) => _.isEqual(item.label, user.user_language)); - document.cookie = `googtrans=/auto/${newLng.value}; Path=/; Domain=${window.location.hostname}`; + document.cookie = `googtrans=/auto/${(newLng && newLng.value) || 'en'}; Path=/; Domain=${window.location.hostname}`; // eslint-disable-next-line no-alert alert('Detected language change. So need to reload the website. It might take a little while for this.'); window.location.reload(); @@ -136,7 +136,7 @@ const TopBar = ({ } else if (user && user.user_language) { const isReloaded = sessionStorage.getItem('isReloaded'); const newLng = LANGUAGES.find((item) => _.isEqual(item.label, user.user_language)); - document.cookie = `googtrans=/auto/${newLng.value}; Path=/; Domain=${window.location.hostname}`; + document.cookie = `googtrans=/auto/${(newLng && newLng.value) || 'en'}; Path=/; Domain=${window.location.hostname}`; if (!isReloaded && !_.isEqual(user.user_language, 'English')) { sessionStorage.setItem('isReloaded', 'true'); // eslint-disable-next-line no-alert