From 40ce52dcee8f076bac12534b05093b63dbba7778 Mon Sep 17 00:00:00 2001 From: Viet Date: Thu, 19 Sep 2024 13:59:41 +0700 Subject: [PATCH] Language switcher --- package.json | 1 + src/Components/ConsentCustom.tsx | 56 ++---- src/Components/ConsentHeader.tsx | 79 +++++++++ src/Components/Terms.tsx | 56 +----- src/analytics.tsx | 1 + src/styles/style.scss | 14 ++ yarn.lock | 288 ++++++++++++++++++++++++++++++- 7 files changed, 398 insertions(+), 97 deletions(-) create mode 100644 src/Components/ConsentHeader.tsx diff --git a/package.json b/package.json index f3fed87..9bcf849 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "react-content-loader": "^7.0.0", "react-device-detect": "^2.2.3", "react-dom": "18", + "react-select": "^5.8.0", "react-toastify": "^9.1.3", "wagmi": "^1.3.2" }, diff --git a/src/Components/ConsentCustom.tsx b/src/Components/ConsentCustom.tsx index e82a002..3ee4fcf 100644 --- a/src/Components/ConsentCustom.tsx +++ b/src/Components/ConsentCustom.tsx @@ -51,6 +51,7 @@ import { useAccount, useSignMessage } from 'wagmi'; import SSOEthereumProvider from './Ethereum'; import { getWeb3ID } from '../utils/Concordium'; import { trackEvent } from '../utils'; +import ConsentHeader from './ConsentHeader'; declare global { interface Window { dataLayer: any; @@ -69,6 +70,7 @@ const ConsentComponentCustom = ({ layout, isOptInReplaceAnalytics, customConsentText, + languageSwitcher, }: any) => { return ( <> @@ -86,6 +88,7 @@ const ConsentComponentCustom = ({ gtmId={gtmId} layout={layout} customConsentText={customConsentText} + languageSwitcher={languageSwitcher} /> )} @@ -124,6 +127,7 @@ const ConsentComponentCustomWrapper = (props: any) => { gtmId={props?.gtmId} layout={props?.layout} customConsentText={props?.customConsentText} + languageSwitcher={props?.languageSwitcher} uuid={uuid} level={level} connection={connection} @@ -150,6 +154,7 @@ const ConsentComponentCustomApp = (props: any) => { gtmId, layout, customConsentText, + languageSwitcher, activeConnectorType, activeConnector, activeConnectorError, @@ -262,8 +267,7 @@ const ConsentComponentCustomApp = (props: any) => { jwt, 'metamask', gtagId, - gtmId, - layout + gtmId ); sessionStorage.setItem('aesirx-analytics-uuid', uuid); sessionStorage.setItem('aesirx-analytics-allow', '1'); @@ -363,8 +367,7 @@ const ConsentComponentCustomApp = (props: any) => { jwt, 'concordium', gtagId, - gtmId, - layout + gtmId ); sessionStorage.setItem('aesirx-analytics-consent-type', 'concordium'); setUpgradeLayout(false); @@ -402,8 +405,7 @@ const ConsentComponentCustomApp = (props: any) => { null, null, gtagId, - gtmId, - layout + gtmId ); } else if ( !!existConsent?.consent_uuid && @@ -421,8 +423,7 @@ const ConsentComponentCustomApp = (props: any) => { null, null, gtagId, - gtmId, - layout + gtmId ); } }); @@ -492,8 +493,7 @@ const ConsentComponentCustomApp = (props: any) => { response?.jwt, 'concordium', gtagId, - gtmId, - layout + gtmId ); setShow(false); handleRevoke(true, level); @@ -551,8 +551,7 @@ const ConsentComponentCustomApp = (props: any) => { response?.jwt, 'concordium', gtagId, - gtmId, - layout + gtmId ); setShow(false); handleRevoke(true, level); @@ -853,36 +852,7 @@ const ConsentComponentCustomApp = (props: any) => { {showExpandRevoke && ( <> -
-
- {(window as any)?.aesirx_analytics_translate?.txt_tracking_data_privacy ?? - t('txt_tracking_data_privacy')} -
-
- - Background Image -
- SoP Icon - {(window as any)?.aesirx_analytics_translate?.txt_shield_of_privacy ?? - t('txt_shield_of_privacy')} -
-
-
-
+
{ @@ -1298,6 +1268,7 @@ const ConsentComponentCustomApp = (props: any) => { isCustom={true} layout={layout} isRejectedLayout={true} + languageSwitcher={languageSwitcher} >
{ isCustom={true} layout={layout} customConsentText={customConsentText} + languageSwitcher={languageSwitcher} > { + const { t } = useTranslation(); + const { listLanguages } = useI18nextContext(); + const currentLanguage = listLanguages.filter( + (lang: any) => lang.value == i18n.language || i18n.language?.includes(lang.value) + ); + const customStyles: StylesConfig = { + menuList: (base) => ({ + ...base, + maxHeight: '160px', + }), + }; + return ( +
+
+ {(window as any)?.aesirx_analytics_translate?.txt_tracking_data_privacy ?? + t('txt_tracking_data_privacy')} +
+ {languageSwitcher ? ( +
+