@@ -3,7 +3,7 @@ import * as React from 'react';
33import { useTranslation } from 'react-i18next' ;
44import { Link , generatePath } from 'react-router-dom' ;
55
6- import { PATHS } from '@/constants' ;
6+ import { LanguageEnum , PATHS } from '@/constants' ;
77import { getValidLanguage } from '@/helpers/langHelper' ;
88import { useCurrentPath } from '@/hooks/useCurrentPath' ;
99
@@ -14,7 +14,7 @@ export interface LayoutTemplateContainerProps {
1414export const LayoutTemplateContainer : React . FC < LayoutTemplateContainerProps > = ( { children } ) => {
1515 const { i18n, t } = useTranslation ( ) ;
1616 const currentPath = useCurrentPath ( ) ;
17- const languageForChange = i18n . language === 'fr' ? 'en' : 'fr' ;
17+ const languageForChange = i18n . language === LanguageEnum . FR ? LanguageEnum . EN : LanguageEnum . FR ;
1818
1919 return (
2020 < Flex alignItems = "center" flexDirection = "column" gap = "m" height = "full" justifyContent = "center" >
@@ -38,8 +38,10 @@ export const LayoutTemplateContainer: React.FC<LayoutTemplateContainerProps> = (
3838 </ Button >
3939 </ Flex >
4040 < Button
41+ to = { generatePath ( ! currentPath || currentPath === PATHS . ROOT ? PATHS . HOME : currentPath , {
42+ lang : languageForChange ,
43+ } ) }
4144 as = { Link }
42- to = { generatePath ( currentPath === PATHS . ROOT ? PATHS . HOME : currentPath , { lang : languageForChange } ) }
4345 variant = "secondary"
4446 >
4547 { t ( 'layout.change-lang' , { lang : languageForChange } ) }
0 commit comments