@@ -136,23 +136,43 @@ export class HeaderComponent implements OnInit, AfterViewInit, DoCheck, OnDestro
136136
137137 async ngOnInit ( ) {
138138 this . langs = this . translate . getLangs ( ) ;
139- console . log ( 'langs' )
140- console . log ( this . langs )
141- //this.defaultLang = this.translate.getDefaultLang();
139+
142140 let currLang = this . localStorage . getItem ( 'current_language' )
143141 if ( ! currLang || currLang == null ) {
144142 this . defaultLang = this . translate . getDefaultLang ( ) ;
145143 } else {
146144 this . defaultLang = currLang ;
147145 }
148- console . log ( 'default' )
149- console . log ( this . defaultLang )
150146
151147 this . themeSubscription = this . themeService . currentTheme$ . subscribe ( theme => {
152148 this . currentTheme = theme ;
153149 this . headerLinks = theme ?. links ?. headerLinks || [ ] ;
154150 this . themeAuthUrls = theme ?. authUrls ;
155- // Podrías hacer más cosas aquí cuando el tema cambia si es necesario
151+
152+ if ( theme ?. links ?. headerLinks ) {
153+ // Recorremos recursivamente todos los links y actualizamos URL si tiene environmentName
154+ const updateLinks = ( links : NavLink [ ] ) => {
155+ return links . map ( link => {
156+ const updatedLink = { ...link } ;
157+
158+ // Actualizamos url dinámicamente
159+ if ( link . environmentName ) {
160+ updatedLink . url = ( environment as any ) [ link . environmentName ] || '' ;
161+ }
162+
163+ // Si tiene children, hacemos la misma operación recursivamente
164+ if ( link . children ?. length ) {
165+ updatedLink . children = updateLinks ( link . children ) ;
166+ }
167+
168+ return updatedLink ;
169+ } ) ;
170+ } ;
171+
172+ this . headerLinks = updateLinks ( theme . links . headerLinks ) ;
173+
174+ theme . links . headerLinks = this . headerLinks ;
175+ }
156176 } ) ;
157177
158178
0 commit comments