1
1
import React , { useEffect , useState } from 'react'
2
+ import Cookies from 'js-cookie'
2
3
import { Footer } from '@deriv-com/blocks'
3
4
import { qtJoin } from '@deriv/quill-design'
4
5
import {
8
9
socialButtonsEU ,
9
10
socialButtonsROW ,
10
11
socialButtonsCPA ,
12
+ specialLanguageUrls ,
11
13
warnText ,
12
14
} from './data'
13
15
// import { socialIconROW, socialIconEU, socialIconCareer } from './validate-social-icons-data'
@@ -18,12 +20,22 @@ import useRegion from 'components/hooks/use-region'
18
20
import { getLocationPathname } from 'common/utility'
19
21
import useThirdPartyFlags from 'components/hooks/use-third-party-flags'
20
22
23
+ const overrideWithLang = ( buttons , lang ) =>
24
+ buttons . map ( ( button ) =>
25
+ lang in specialLanguageUrls
26
+ ? button [ 'aria-label' ] in specialLanguageUrls [ lang ]
27
+ ? { ...button , href : specialLanguageUrls [ lang ] [ button [ 'aria-label' ] ] }
28
+ : button
29
+ : button ,
30
+ )
31
+
21
32
export const MainFooter = ( ) => {
22
- const { is_eu, is_cpa_plan } = useRegion ( )
23
33
const [ is_career , setIsCareer ] = useState ( false )
34
+ const { is_eu, is_cpa_plan } = useRegion ( )
24
35
const [ social_buttons , setSocialButtons ] = useState ( socialButtonsROW )
25
36
const [ warn_text , setWarnText ] = useState ( warnText )
26
37
const [ nav_data , setNavData ] = useState ( RowFooterNavData )
38
+ const lang = Cookies . get ( 'user_language' ) || 'en'
27
39
28
40
useEffect ( ( ) => {
29
41
const current_path = getLocationPathname ( )
@@ -48,7 +60,8 @@ export const MainFooter = () => {
48
60
const socialIconCPA = filterSocialIcons ( cpa_social_media_icons , socialButtonsCPA )
49
61
50
62
const region_buttons = is_eu ? socialIconEU : is_cpa_plan ? socialIconCPA : socialIconROW
51
- setSocialButtons ( is_career ? socialIconCareer : region_buttons )
63
+ const buttons = is_career ? socialIconCareer : region_buttons
64
+ setSocialButtons ( overrideWithLang ( buttons , lang ) )
52
65
if ( is_eu ) setNavData ( EuFooterNavData )
53
66
setWarnText ( ! is_eu && ! is_cpa_plan ? warnText : null )
54
67
} , [
0 commit comments