11"use client" ;
22
33import React , { MouseEvent , useState } from "react" ;
4+ import Select , { SingleValue , OptionsOrGroups , GroupBase , NonceProvider } from "react-select" ;
45import { FooterIconsComponent } from "./footer-Icons.component" ;
56import { MonoFont , SecondaryFont } from "@/libs/theme/fonts" ;
67import Image from "next/image" ;
@@ -18,6 +19,8 @@ import { SiteBrandComponent } from "@/features/common/components/site-brand/site
1819import { Button } from "react-aria-components" ;
1920import { Auth0LogoComponent } from "../../assets/auth0-logo.component" ;
2021import { getBrandDictionary } from "@/features/localization/services/brand-dictionary.service" ;
22+ import { savePreferredLanguage } from "@/features/localization/services/ui-language.utils" ;
23+ import { UiLanguageModel } from "../../models/ui-language.model" ;
2124
2225interface FooterComponentProps {
2326 languageCode : string ;
@@ -28,8 +31,19 @@ export const FooterComponent: React.FC<FooterComponentProps> = ({
2831 languageCode,
2932 dictionary,
3033} ) => {
34+ const currentLanguage = dictionary . languagePicker . options . filter (
35+ ( element ) => element . value === languageCode
36+ ) [ 0 ] ;
37+
38+ const handleChange = ( selection : SingleValue < UiLanguageModel > ) => {
39+ if ( ! selection ) {
40+ return ;
41+ }
42+ savePreferredLanguage ( selection . value ) ;
43+ } ;
44+
3145 const [ modalState , setModalState ] = useState < ModalStateValues > (
32- ModalStateValues . CLOSED ,
46+ ModalStateValues . CLOSED
3347 ) ;
3448 const images = getBrandDictionary ( languageCode ) ;
3549
@@ -64,7 +78,10 @@ export const FooterComponent: React.FC<FooterComponentProps> = ({
6478 contentClassName = { styles . content }
6579 >
6680 < div className = { styles . siteLogo } >
67- < SiteBrandComponent path = { languagePathPrefix } languageCode = { languageCode } />
81+ < SiteBrandComponent
82+ path = { languagePathPrefix }
83+ languageCode = { languageCode }
84+ />
6885 </ div >
6986 < div className = { styles . resources } >
7087 < span className = { clsx ( styles . resources__title , MonoFont . className ) } >
@@ -110,7 +127,7 @@ export const FooterComponent: React.FC<FooterComponentProps> = ({
110127 } }
111128 className = { clsx (
112129 styles . resource__button ,
113- SecondaryFont . className ,
130+ SecondaryFont . className
114131 ) }
115132 >
116133 { trigger . text }
@@ -158,11 +175,59 @@ export const FooterComponent: React.FC<FooterComponentProps> = ({
158175 target = "_blank"
159176 href = "https://auth0.com/"
160177 >
161- < Auth0LogoComponent title = { images . tooltip } />
178+ < Auth0LogoComponent title = { images . tooltip } />
162179 </ Link >
163180 < span className = { styles . bottomSection__copyright } >
164181 { dictionary . copyright }
165182 </ span >
183+ { dictionary . languagePicker . options . length > 1 && (
184+ < Select
185+ aria-label = { "Language picker" }
186+ className = { styles . languageSelect__container }
187+ onChange = { handleChange }
188+ options = { dictionary . languagePicker . options as OptionsOrGroups < UiLanguageModel , GroupBase < UiLanguageModel > > }
189+ menuPortalTarget = { document . body }
190+ classNamePrefix = { "language-select" }
191+ isSearchable = { false }
192+ placeholder = { currentLanguage . label }
193+ value = { currentLanguage }
194+ styles = { {
195+ control : ( base ) => ( {
196+ ...base ,
197+ background : "transparent" ,
198+ border : "none" ,
199+ borderRadius : "0px" ,
200+ display : "flex" ,
201+ alignItems : "center" ,
202+ cursor : "pointer" ,
203+ minHeight : "2.5rem" ,
204+ boxSizing : "border-box" ,
205+ } ) ,
206+
207+ input : ( base ) => ( {
208+ ...base ,
209+ margin : "0px" ,
210+ } ) ,
211+ indicatorSeparator : ( ) => ( {
212+ display : "none" ,
213+ } ) ,
214+ indicatorsContainer : ( base ) => ( {
215+ ...base ,
216+ height : "20px" ,
217+ alignSelf : "center" ,
218+ } ) ,
219+ dropdownIndicator : ( base ) => ( {
220+ padding : "0px" ,
221+ height : "100%" ,
222+ alignSelf : "center" ,
223+ } ) ,
224+ singleValue : ( base ) => ( {
225+ ...base ,
226+ color : "unset" ,
227+ } )
228+ } }
229+ > </ Select >
230+ ) }
166231 </ div >
167232 </ BoxComponent >
168233 </ footer >
0 commit comments