Skip to content

Commit

Permalink
Use user's locale from the backend
Browse files Browse the repository at this point in the history
  • Loading branch information
user890104 committed Aug 26, 2023
1 parent 3c83e91 commit f0a41c6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/layout/NavBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { getToken } from '../authStorage.js';
import DoorClosedIcon from '../widgets/icons/DoorClosedIcon.jsx';
import DoorOpenIcon from '../widgets/icons/DoorOpenIcon.jsx';
import { useGetCurrentUserQuery } from '../features/apiSlice.js';
import { useEffect } from 'react';
import i18n from '../i18n.js';

const NavBar = () => {
const {t} = useTranslation();
Expand All @@ -29,6 +31,12 @@ const NavBar = () => {
});
const isBoardMember = isSuccess && data.roles.includes('board_member');

useEffect(function() {
if (isSuccess) {
i18n.changeLanguage(data.locale);
}
}, [data.locale, isSuccess]);

return (<Navbar bg="primary" variant="dark" expand="lg" className="py-0">
<Container>
<Navbar.Brand as={NavLink} to="/">
Expand Down

0 comments on commit f0a41c6

Please sign in to comment.