diff --git a/public/locales/uk/translation.json b/public/locales/ua/translation.json similarity index 100% rename from public/locales/uk/translation.json rename to public/locales/ua/translation.json diff --git a/src/App.tsx b/src/App.tsx index 8499418..187b47b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,18 +1,10 @@ -/* eslint-disable react-hooks/exhaustive-deps */ -import React, {useEffect} from 'react'; +import React from 'react'; import {Provider} from 'react-redux'; -import {useTranslation} from 'react-i18next'; import store from './redux/store'; import Theme from './Theme'; const App = () => { - const {i18n} = useTranslation(); - - useEffect(() => { - i18n.changeLanguage(navigator.language); - }, []); - return ( diff --git a/src/Routes/Routes.tsx b/src/Routes/Routes.tsx index 1ea25bb..298c077 100644 --- a/src/Routes/Routes.tsx +++ b/src/Routes/Routes.tsx @@ -23,7 +23,6 @@ import RecoveryPassword from '../pages/Auth/RecoveryPassword'; import Plan from '../pages/Plan'; import CheckEmail from '../pages/Auth/CheckEmail'; import Main from '../pages/Main'; -import PlanLayout from '../layouts/PlanLayout'; import Profile from '../pages/Profile/Profile'; import ProtectedRoute from '../components/routes/ProtectedRoute'; @@ -93,9 +92,7 @@ const Routes: React.FC = () => { }> } /> - }> - } /> - + } /> diff --git a/src/components/Map/Map.tsx b/src/components/Map/Map.tsx index 3e55c5c..92eb7c2 100644 --- a/src/components/Map/Map.tsx +++ b/src/components/Map/Map.tsx @@ -1,20 +1,15 @@ import React, {useCallback, useEffect, useState} from 'react'; -import {GoogleMap, useJsApiLoader, Marker} from '@react-google-maps/api'; +import {GoogleMap, Marker} from '@react-google-maps/api'; import {useSelector} from 'react-redux'; import {selectUserCoords} from '../../redux/common/selectors'; import {useAppDispatch} from '../../redux/store'; import {setUserCoords} from '../../redux/common/commonSlice'; -import {containerStyle, libraries} from './constants'; +import {containerStyle} from './constants'; import {MapWrap} from './Styles'; const Map = () => { - const {isLoaded} = useJsApiLoader({ - googleMapsApiKey: process.env.REACT_APP_GOOGLE_API_KEY || '', - libraries, - }); - const [markersData, setMarkersData] = useState([]); const coords = useSelector(selectUserCoords); @@ -63,34 +58,32 @@ const Map = () => { return ( - {isLoaded ? ( - - {markersData.map((item, index) => ( - - ))} - - - ) : null} + + {markersData.map((item, index) => ( + + ))} + + ); }; diff --git a/src/components/Map/constants.ts b/src/components/Map/constants.ts index 3e69326..b9555f3 100644 --- a/src/components/Map/constants.ts +++ b/src/components/Map/constants.ts @@ -2,9 +2,3 @@ export const containerStyle = { width: '100%', height: '100%', }; - -export const libraries: ('drawing' | 'geometry' | 'places' | 'localContext' | 'visualization')[] = [ - 'drawing', - 'geometry', - 'places', -]; diff --git a/src/components/common/Navigation/Navigation.tsx b/src/components/common/Navigation/Navigation.tsx index 09a9aa9..cba13ba 100644 --- a/src/components/common/Navigation/Navigation.tsx +++ b/src/components/common/Navigation/Navigation.tsx @@ -2,6 +2,7 @@ import React, {useState} from 'react'; import {useSelector} from 'react-redux'; import {useNavigate} from 'react-router-dom'; import {Grid, IconButton} from '@mui/material'; +import {changeLanguage} from 'i18next'; import {ReactComponent as ProfileIcon} from '../../../assets/icons/profile.svg'; import {ReactComponent as LogoIcon} from '../../../assets/icons/logo.svg'; @@ -24,6 +25,7 @@ const Navigation = () => { const navigate = useNavigate(); const dispatch = useAppDispatch(); const user = useSelector(selectUser); + const handleRedirect = (path: string) => { navigate(path); }; @@ -40,8 +42,12 @@ const Navigation = () => { setAnchorEl(null); }; - const handleLanguage = () => { - dispatch(changeUserLanguage(user.language)); + const handleLanguage = (value: string) => { + if (value === user.language) return; + + dispatch(changeUserLanguage(value)).then((res) => { + res.meta.requestStatus === 'fulfilled' && changeLanguage(res.payload as string); + }); }; return ( @@ -59,7 +65,7 @@ const Navigation = () => { {isEditing && ( - ); + return